{"version":3,"file":"viewer3D.js","sources":["webpack://LMV/webpack/bootstrap","webpack://LMV/./extensions/DefaultTools/NavTools.js","webpack://LMV/./extensions/Explode/Explode.js","webpack://LMV/./extensions/Explode/ExplodeTool.js","webpack://LMV/./extensions/FullScreen/FullScreen.js","webpack://LMV/./extensions/FusionOrbit/FusionOrbit.css?f58a","webpack://LMV/./extensions/FusionOrbit/FusionOrbit.js","webpack://LMV/./extensions/FusionOrbit/FusionOrbitTool.js","webpack://LMV/./extensions/GoHome/GoHome.js","webpack://LMV/./extensions/ModelStructure/ModelStructure.js","webpack://LMV/./extensions/PropertiesManager/PropertiesManager.js","webpack://LMV/./extensions/ViewerSettings/ViewerSettings.js","webpack://LMV/./extensions/builtinExtensions.js","webpack://LMV/./extensions/externalExtensions.js","webpack://LMV/./extensions/registerExternalExtensions.js","webpack://LMV/./node_modules/clusterize.js/clusterize.js","webpack://LMV/./node_modules/core-js/internals/a-function.js","webpack://LMV/./node_modules/core-js/internals/a-possible-prototype.js","webpack://LMV/./node_modules/core-js/internals/add-to-unscopables.js","webpack://LMV/./node_modules/core-js/internals/advance-string-index.js","webpack://LMV/./node_modules/core-js/internals/an-instance.js","webpack://LMV/./node_modules/core-js/internals/an-object.js","webpack://LMV/./node_modules/core-js/internals/array-buffer-native.js","webpack://LMV/./node_modules/core-js/internals/array-buffer-view-core.js","webpack://LMV/./node_modules/core-js/internals/array-buffer.js","webpack://LMV/./node_modules/core-js/internals/array-copy-within.js","webpack://LMV/./node_modules/core-js/internals/array-fill.js","webpack://LMV/./node_modules/core-js/internals/array-for-each.js","webpack://LMV/./node_modules/core-js/internals/array-from.js","webpack://LMV/./node_modules/core-js/internals/array-includes.js","webpack://LMV/./node_modules/core-js/internals/array-iteration.js","webpack://LMV/./node_modules/core-js/internals/array-last-index-of.js","webpack://LMV/./node_modules/core-js/internals/array-method-has-species-support.js","webpack://LMV/./node_modules/core-js/internals/array-method-is-strict.js","webpack://LMV/./node_modules/core-js/internals/array-method-uses-to-length.js","webpack://LMV/./node_modules/core-js/internals/array-reduce.js","webpack://LMV/./node_modules/core-js/internals/array-species-create.js","webpack://LMV/./node_modules/core-js/internals/call-with-safe-iteration-closing.js","webpack://LMV/./node_modules/core-js/internals/check-correctness-of-iteration.js","webpack://LMV/./node_modules/core-js/internals/classof-raw.js","webpack://LMV/./node_modules/core-js/internals/classof.js","webpack://LMV/./node_modules/core-js/internals/collection-add-all.js","webpack://LMV/./node_modules/core-js/internals/collection-delete-all.js","webpack://LMV/./node_modules/core-js/internals/collection-from.js","webpack://LMV/./node_modules/core-js/internals/collection-of.js","webpack://LMV/./node_modules/core-js/internals/collection-strong.js","webpack://LMV/./node_modules/core-js/internals/collection-weak.js","webpack://LMV/./node_modules/core-js/internals/collection.js","webpack://LMV/./node_modules/core-js/internals/composite-key.js","webpack://LMV/./node_modules/core-js/internals/copy-constructor-properties.js","webpack://LMV/./node_modules/core-js/internals/correct-is-regexp-logic.js","webpack://LMV/./node_modules/core-js/internals/correct-prototype-getter.js","webpack://LMV/./node_modules/core-js/internals/create-html.js","webpack://LMV/./node_modules/core-js/internals/create-iterator-constructor.js","webpack://LMV/./node_modules/core-js/internals/create-non-enumerable-property.js","webpack://LMV/./node_modules/core-js/internals/create-property-descriptor.js","webpack://LMV/./node_modules/core-js/internals/create-property.js","webpack://LMV/./node_modules/core-js/internals/date-to-primitive.js","webpack://LMV/./node_modules/core-js/internals/define-iterator.js","webpack://LMV/./node_modules/core-js/internals/define-well-known-symbol.js","webpack://LMV/./node_modules/core-js/internals/descriptors.js","webpack://LMV/./node_modules/core-js/internals/document-create-element.js","webpack://LMV/./node_modules/core-js/internals/dom-iterables.js","webpack://LMV/./node_modules/core-js/internals/engine-is-ios.js","webpack://LMV/./node_modules/core-js/internals/engine-user-agent.js","webpack://LMV/./node_modules/core-js/internals/engine-v8-version.js","webpack://LMV/./node_modules/core-js/internals/enum-bug-keys.js","webpack://LMV/./node_modules/core-js/internals/export.js","webpack://LMV/./node_modules/core-js/internals/fails.js","webpack://LMV/./node_modules/core-js/internals/fix-regexp-well-known-symbol-logic.js","webpack://LMV/./node_modules/core-js/internals/flatten-into-array.js","webpack://LMV/./node_modules/core-js/internals/freezing.js","webpack://LMV/./node_modules/core-js/internals/function-bind-context.js","webpack://LMV/./node_modules/core-js/internals/function-bind.js","webpack://LMV/./node_modules/core-js/internals/get-built-in.js","webpack://LMV/./node_modules/core-js/internals/get-iterator-method.js","webpack://LMV/./node_modules/core-js/internals/get-iterator.js","webpack://LMV/./node_modules/core-js/internals/get-map-iterator.js","webpack://LMV/./node_modules/core-js/internals/get-set-iterator.js","webpack://LMV/./node_modules/core-js/internals/global.js","webpack://LMV/./node_modules/core-js/internals/has.js","webpack://LMV/./node_modules/core-js/internals/hidden-keys.js","webpack://LMV/./node_modules/core-js/internals/host-report-errors.js","webpack://LMV/./node_modules/core-js/internals/html.js","webpack://LMV/./node_modules/core-js/internals/ie8-dom-define.js","webpack://LMV/./node_modules/core-js/internals/ieee754.js","webpack://LMV/./node_modules/core-js/internals/indexed-object.js","webpack://LMV/./node_modules/core-js/internals/inherit-if-required.js","webpack://LMV/./node_modules/core-js/internals/inspect-source.js","webpack://LMV/./node_modules/core-js/internals/internal-metadata.js","webpack://LMV/./node_modules/core-js/internals/internal-state.js","webpack://LMV/./node_modules/core-js/internals/is-array-iterator-method.js","webpack://LMV/./node_modules/core-js/internals/is-array.js","webpack://LMV/./node_modules/core-js/internals/is-forced.js","webpack://LMV/./node_modules/core-js/internals/is-integer.js","webpack://LMV/./node_modules/core-js/internals/is-object.js","webpack://LMV/./node_modules/core-js/internals/is-pure.js","webpack://LMV/./node_modules/core-js/internals/is-regexp.js","webpack://LMV/./node_modules/core-js/internals/iterate.js","webpack://LMV/./node_modules/core-js/internals/iterators-core.js","webpack://LMV/./node_modules/core-js/internals/iterators.js","webpack://LMV/./node_modules/core-js/internals/math-expm1.js","webpack://LMV/./node_modules/core-js/internals/math-fround.js","webpack://LMV/./node_modules/core-js/internals/math-log1p.js","webpack://LMV/./node_modules/core-js/internals/math-scale.js","webpack://LMV/./node_modules/core-js/internals/math-sign.js","webpack://LMV/./node_modules/core-js/internals/microtask.js","webpack://LMV/./node_modules/core-js/internals/native-promise-constructor.js","webpack://LMV/./node_modules/core-js/internals/native-symbol.js","webpack://LMV/./node_modules/core-js/internals/native-url.js","webpack://LMV/./node_modules/core-js/internals/native-weak-map.js","webpack://LMV/./node_modules/core-js/internals/new-promise-capability.js","webpack://LMV/./node_modules/core-js/internals/not-a-regexp.js","webpack://LMV/./node_modules/core-js/internals/number-is-finite.js","webpack://LMV/./node_modules/core-js/internals/number-parse-float.js","webpack://LMV/./node_modules/core-js/internals/number-parse-int.js","webpack://LMV/./node_modules/core-js/internals/object-assign.js","webpack://LMV/./node_modules/core-js/internals/object-create.js","webpack://LMV/./node_modules/core-js/internals/object-define-properties.js","webpack://LMV/./node_modules/core-js/internals/object-define-property.js","webpack://LMV/./node_modules/core-js/internals/object-get-own-property-descriptor.js","webpack://LMV/./node_modules/core-js/internals/object-get-own-property-names-external.js","webpack://LMV/./node_modules/core-js/internals/object-get-own-property-names.js","webpack://LMV/./node_modules/core-js/internals/object-get-own-property-symbols.js","webpack://LMV/./node_modules/core-js/internals/object-get-prototype-of.js","webpack://LMV/./node_modules/core-js/internals/object-keys-internal.js","webpack://LMV/./node_modules/core-js/internals/object-keys.js","webpack://LMV/./node_modules/core-js/internals/object-property-is-enumerable.js","webpack://LMV/./node_modules/core-js/internals/object-prototype-accessors-forced.js","webpack://LMV/./node_modules/core-js/internals/object-set-prototype-of.js","webpack://LMV/./node_modules/core-js/internals/object-to-array.js","webpack://LMV/./node_modules/core-js/internals/object-to-string.js","webpack://LMV/./node_modules/core-js/internals/own-keys.js","webpack://LMV/./node_modules/core-js/internals/path.js","webpack://LMV/./node_modules/core-js/internals/perform.js","webpack://LMV/./node_modules/core-js/internals/promise-resolve.js","webpack://LMV/./node_modules/core-js/internals/redefine-all.js","webpack://LMV/./node_modules/core-js/internals/redefine.js","webpack://LMV/./node_modules/core-js/internals/reflect-metadata.js","webpack://LMV/./node_modules/core-js/internals/regexp-exec-abstract.js","webpack://LMV/./node_modules/core-js/internals/regexp-exec.js","webpack://LMV/./node_modules/core-js/internals/regexp-flags.js","webpack://LMV/./node_modules/core-js/internals/regexp-sticky-helpers.js","webpack://LMV/./node_modules/core-js/internals/require-object-coercible.js","webpack://LMV/./node_modules/core-js/internals/same-value-zero.js","webpack://LMV/./node_modules/core-js/internals/same-value.js","webpack://LMV/./node_modules/core-js/internals/set-global.js","webpack://LMV/./node_modules/core-js/internals/set-species.js","webpack://LMV/./node_modules/core-js/internals/set-to-string-tag.js","webpack://LMV/./node_modules/core-js/internals/shared-key.js","webpack://LMV/./node_modules/core-js/internals/shared-store.js","webpack://LMV/./node_modules/core-js/internals/shared.js","webpack://LMV/./node_modules/core-js/internals/species-constructor.js","webpack://LMV/./node_modules/core-js/internals/string-html-forced.js","webpack://LMV/./node_modules/core-js/internals/string-multibyte.js","webpack://LMV/./node_modules/core-js/internals/string-pad-webkit-bug.js","webpack://LMV/./node_modules/core-js/internals/string-pad.js","webpack://LMV/./node_modules/core-js/internals/string-punycode-to-ascii.js","webpack://LMV/./node_modules/core-js/internals/string-repeat.js","webpack://LMV/./node_modules/core-js/internals/string-trim-forced.js","webpack://LMV/./node_modules/core-js/internals/string-trim.js","webpack://LMV/./node_modules/core-js/internals/task.js","webpack://LMV/./node_modules/core-js/internals/this-number-value.js","webpack://LMV/./node_modules/core-js/internals/to-absolute-index.js","webpack://LMV/./node_modules/core-js/internals/to-index.js","webpack://LMV/./node_modules/core-js/internals/to-indexed-object.js","webpack://LMV/./node_modules/core-js/internals/to-integer.js","webpack://LMV/./node_modules/core-js/internals/to-length.js","webpack://LMV/./node_modules/core-js/internals/to-object.js","webpack://LMV/./node_modules/core-js/internals/to-offset.js","webpack://LMV/./node_modules/core-js/internals/to-positive-integer.js","webpack://LMV/./node_modules/core-js/internals/to-primitive.js","webpack://LMV/./node_modules/core-js/internals/to-string-tag-support.js","webpack://LMV/./node_modules/core-js/internals/typed-array-constructor.js","webpack://LMV/./node_modules/core-js/internals/typed-array-constructors-require-wrappers.js","webpack://LMV/./node_modules/core-js/internals/typed-array-from.js","webpack://LMV/./node_modules/core-js/internals/uid.js","webpack://LMV/./node_modules/core-js/internals/use-symbol-as-uid.js","webpack://LMV/./node_modules/core-js/internals/well-known-symbol-wrapped.js","webpack://LMV/./node_modules/core-js/internals/well-known-symbol.js","webpack://LMV/./node_modules/core-js/internals/whitespaces.js","webpack://LMV/./node_modules/core-js/modules/es.array-buffer.constructor.js","webpack://LMV/./node_modules/core-js/modules/es.array.concat.js","webpack://LMV/./node_modules/core-js/modules/es.array.copy-within.js","webpack://LMV/./node_modules/core-js/modules/es.array.every.js","webpack://LMV/./node_modules/core-js/modules/es.array.fill.js","webpack://LMV/./node_modules/core-js/modules/es.array.filter.js","webpack://LMV/./node_modules/core-js/modules/es.array.find-index.js","webpack://LMV/./node_modules/core-js/modules/es.array.find.js","webpack://LMV/./node_modules/core-js/modules/es.array.flat-map.js","webpack://LMV/./node_modules/core-js/modules/es.array.flat.js","webpack://LMV/./node_modules/core-js/modules/es.array.for-each.js","webpack://LMV/./node_modules/core-js/modules/es.array.from.js","webpack://LMV/./node_modules/core-js/modules/es.array.includes.js","webpack://LMV/./node_modules/core-js/modules/es.array.index-of.js","webpack://LMV/./node_modules/core-js/modules/es.array.iterator.js","webpack://LMV/./node_modules/core-js/modules/es.array.join.js","webpack://LMV/./node_modules/core-js/modules/es.array.last-index-of.js","webpack://LMV/./node_modules/core-js/modules/es.array.map.js","webpack://LMV/./node_modules/core-js/modules/es.array.of.js","webpack://LMV/./node_modules/core-js/modules/es.array.reduce-right.js","webpack://LMV/./node_modules/core-js/modules/es.array.reduce.js","webpack://LMV/./node_modules/core-js/modules/es.array.slice.js","webpack://LMV/./node_modules/core-js/modules/es.array.some.js","webpack://LMV/./node_modules/core-js/modules/es.array.sort.js","webpack://LMV/./node_modules/core-js/modules/es.array.species.js","webpack://LMV/./node_modules/core-js/modules/es.array.splice.js","webpack://LMV/./node_modules/core-js/modules/es.array.unscopables.flat-map.js","webpack://LMV/./node_modules/core-js/modules/es.array.unscopables.flat.js","webpack://LMV/./node_modules/core-js/modules/es.date.to-primitive.js","webpack://LMV/./node_modules/core-js/modules/es.function.has-instance.js","webpack://LMV/./node_modules/core-js/modules/es.function.name.js","webpack://LMV/./node_modules/core-js/modules/es.global-this.js","webpack://LMV/./node_modules/core-js/modules/es.json.to-string-tag.js","webpack://LMV/./node_modules/core-js/modules/es.map.js","webpack://LMV/./node_modules/core-js/modules/es.math.acosh.js","webpack://LMV/./node_modules/core-js/modules/es.math.asinh.js","webpack://LMV/./node_modules/core-js/modules/es.math.atanh.js","webpack://LMV/./node_modules/core-js/modules/es.math.cbrt.js","webpack://LMV/./node_modules/core-js/modules/es.math.clz32.js","webpack://LMV/./node_modules/core-js/modules/es.math.cosh.js","webpack://LMV/./node_modules/core-js/modules/es.math.expm1.js","webpack://LMV/./node_modules/core-js/modules/es.math.fround.js","webpack://LMV/./node_modules/core-js/modules/es.math.hypot.js","webpack://LMV/./node_modules/core-js/modules/es.math.imul.js","webpack://LMV/./node_modules/core-js/modules/es.math.log10.js","webpack://LMV/./node_modules/core-js/modules/es.math.log1p.js","webpack://LMV/./node_modules/core-js/modules/es.math.log2.js","webpack://LMV/./node_modules/core-js/modules/es.math.sign.js","webpack://LMV/./node_modules/core-js/modules/es.math.sinh.js","webpack://LMV/./node_modules/core-js/modules/es.math.tanh.js","webpack://LMV/./node_modules/core-js/modules/es.math.to-string-tag.js","webpack://LMV/./node_modules/core-js/modules/es.math.trunc.js","webpack://LMV/./node_modules/core-js/modules/es.number.constructor.js","webpack://LMV/./node_modules/core-js/modules/es.number.epsilon.js","webpack://LMV/./node_modules/core-js/modules/es.number.is-finite.js","webpack://LMV/./node_modules/core-js/modules/es.number.is-integer.js","webpack://LMV/./node_modules/core-js/modules/es.number.is-nan.js","webpack://LMV/./node_modules/core-js/modules/es.number.is-safe-integer.js","webpack://LMV/./node_modules/core-js/modules/es.number.max-safe-integer.js","webpack://LMV/./node_modules/core-js/modules/es.number.min-safe-integer.js","webpack://LMV/./node_modules/core-js/modules/es.number.parse-float.js","webpack://LMV/./node_modules/core-js/modules/es.number.parse-int.js","webpack://LMV/./node_modules/core-js/modules/es.number.to-fixed.js","webpack://LMV/./node_modules/core-js/modules/es.object.assign.js","webpack://LMV/./node_modules/core-js/modules/es.object.define-getter.js","webpack://LMV/./node_modules/core-js/modules/es.object.define-setter.js","webpack://LMV/./node_modules/core-js/modules/es.object.entries.js","webpack://LMV/./node_modules/core-js/modules/es.object.freeze.js","webpack://LMV/./node_modules/core-js/modules/es.object.from-entries.js","webpack://LMV/./node_modules/core-js/modules/es.object.get-own-property-descriptor.js","webpack://LMV/./node_modules/core-js/modules/es.object.get-own-property-descriptors.js","webpack://LMV/./node_modules/core-js/modules/es.object.get-own-property-names.js","webpack://LMV/./node_modules/core-js/modules/es.object.get-prototype-of.js","webpack://LMV/./node_modules/core-js/modules/es.object.is-extensible.js","webpack://LMV/./node_modules/core-js/modules/es.object.is-frozen.js","webpack://LMV/./node_modules/core-js/modules/es.object.is-sealed.js","webpack://LMV/./node_modules/core-js/modules/es.object.is.js","webpack://LMV/./node_modules/core-js/modules/es.object.keys.js","webpack://LMV/./node_modules/core-js/modules/es.object.lookup-getter.js","webpack://LMV/./node_modules/core-js/modules/es.object.lookup-setter.js","webpack://LMV/./node_modules/core-js/modules/es.object.prevent-extensions.js","webpack://LMV/./node_modules/core-js/modules/es.object.seal.js","webpack://LMV/./node_modules/core-js/modules/es.object.to-string.js","webpack://LMV/./node_modules/core-js/modules/es.object.values.js","webpack://LMV/./node_modules/core-js/modules/es.promise.all-settled.js","webpack://LMV/./node_modules/core-js/modules/es.promise.finally.js","webpack://LMV/./node_modules/core-js/modules/es.promise.js","webpack://LMV/./node_modules/core-js/modules/es.reflect.apply.js","webpack://LMV/./node_modules/core-js/modules/es.reflect.construct.js","webpack://LMV/./node_modules/core-js/modules/es.reflect.define-property.js","webpack://LMV/./node_modules/core-js/modules/es.reflect.delete-property.js","webpack://LMV/./node_modules/core-js/modules/es.reflect.get-own-property-descriptor.js","webpack://LMV/./node_modules/core-js/modules/es.reflect.get-prototype-of.js","webpack://LMV/./node_modules/core-js/modules/es.reflect.get.js","webpack://LMV/./node_modules/core-js/modules/es.reflect.has.js","webpack://LMV/./node_modules/core-js/modules/es.reflect.is-extensible.js","webpack://LMV/./node_modules/core-js/modules/es.reflect.own-keys.js","webpack://LMV/./node_modules/core-js/modules/es.reflect.prevent-extensions.js","webpack://LMV/./node_modules/core-js/modules/es.reflect.set-prototype-of.js","webpack://LMV/./node_modules/core-js/modules/es.reflect.set.js","webpack://LMV/./node_modules/core-js/modules/es.regexp.constructor.js","webpack://LMV/./node_modules/core-js/modules/es.regexp.exec.js","webpack://LMV/./node_modules/core-js/modules/es.regexp.flags.js","webpack://LMV/./node_modules/core-js/modules/es.regexp.to-string.js","webpack://LMV/./node_modules/core-js/modules/es.set.js","webpack://LMV/./node_modules/core-js/modules/es.string.anchor.js","webpack://LMV/./node_modules/core-js/modules/es.string.big.js","webpack://LMV/./node_modules/core-js/modules/es.string.blink.js","webpack://LMV/./node_modules/core-js/modules/es.string.bold.js","webpack://LMV/./node_modules/core-js/modules/es.string.code-point-at.js","webpack://LMV/./node_modules/core-js/modules/es.string.ends-with.js","webpack://LMV/./node_modules/core-js/modules/es.string.fixed.js","webpack://LMV/./node_modules/core-js/modules/es.string.fontcolor.js","webpack://LMV/./node_modules/core-js/modules/es.string.fontsize.js","webpack://LMV/./node_modules/core-js/modules/es.string.from-code-point.js","webpack://LMV/./node_modules/core-js/modules/es.string.includes.js","webpack://LMV/./node_modules/core-js/modules/es.string.italics.js","webpack://LMV/./node_modules/core-js/modules/es.string.iterator.js","webpack://LMV/./node_modules/core-js/modules/es.string.link.js","webpack://LMV/./node_modules/core-js/modules/es.string.match-all.js","webpack://LMV/./node_modules/core-js/modules/es.string.match.js","webpack://LMV/./node_modules/core-js/modules/es.string.pad-end.js","webpack://LMV/./node_modules/core-js/modules/es.string.pad-start.js","webpack://LMV/./node_modules/core-js/modules/es.string.raw.js","webpack://LMV/./node_modules/core-js/modules/es.string.repeat.js","webpack://LMV/./node_modules/core-js/modules/es.string.replace.js","webpack://LMV/./node_modules/core-js/modules/es.string.search.js","webpack://LMV/./node_modules/core-js/modules/es.string.small.js","webpack://LMV/./node_modules/core-js/modules/es.string.split.js","webpack://LMV/./node_modules/core-js/modules/es.string.starts-with.js","webpack://LMV/./node_modules/core-js/modules/es.string.strike.js","webpack://LMV/./node_modules/core-js/modules/es.string.sub.js","webpack://LMV/./node_modules/core-js/modules/es.string.sup.js","webpack://LMV/./node_modules/core-js/modules/es.string.trim-end.js","webpack://LMV/./node_modules/core-js/modules/es.string.trim-start.js","webpack://LMV/./node_modules/core-js/modules/es.string.trim.js","webpack://LMV/./node_modules/core-js/modules/es.symbol.async-iterator.js","webpack://LMV/./node_modules/core-js/modules/es.symbol.description.js","webpack://LMV/./node_modules/core-js/modules/es.symbol.has-instance.js","webpack://LMV/./node_modules/core-js/modules/es.symbol.is-concat-spreadable.js","webpack://LMV/./node_modules/core-js/modules/es.symbol.iterator.js","webpack://LMV/./node_modules/core-js/modules/es.symbol.js","webpack://LMV/./node_modules/core-js/modules/es.symbol.match.js","webpack://LMV/./node_modules/core-js/modules/es.symbol.replace.js","webpack://LMV/./node_modules/core-js/modules/es.symbol.search.js","webpack://LMV/./node_modules/core-js/modules/es.symbol.species.js","webpack://LMV/./node_modules/core-js/modules/es.symbol.split.js","webpack://LMV/./node_modules/core-js/modules/es.symbol.to-primitive.js","webpack://LMV/./node_modules/core-js/modules/es.symbol.to-string-tag.js","webpack://LMV/./node_modules/core-js/modules/es.symbol.unscopables.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.copy-within.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.every.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.fill.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.filter.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.find-index.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.find.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.float32-array.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.float64-array.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.for-each.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.from.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.includes.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.index-of.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.int16-array.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.int32-array.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.int8-array.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.iterator.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.join.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.last-index-of.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.map.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.of.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.reduce-right.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.reduce.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.reverse.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.set.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.slice.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.some.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.sort.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.subarray.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.to-locale-string.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.to-string.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.uint16-array.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.uint32-array.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.uint8-array.js","webpack://LMV/./node_modules/core-js/modules/es.typed-array.uint8-clamped-array.js","webpack://LMV/./node_modules/core-js/modules/es.weak-map.js","webpack://LMV/./node_modules/core-js/modules/es.weak-set.js","webpack://LMV/./node_modules/core-js/modules/esnext.aggregate-error.js","webpack://LMV/./node_modules/core-js/modules/esnext.array.last-index.js","webpack://LMV/./node_modules/core-js/modules/esnext.array.last-item.js","webpack://LMV/./node_modules/core-js/modules/esnext.composite-key.js","webpack://LMV/./node_modules/core-js/modules/esnext.composite-symbol.js","webpack://LMV/./node_modules/core-js/modules/esnext.global-this.js","webpack://LMV/./node_modules/core-js/modules/esnext.map.delete-all.js","webpack://LMV/./node_modules/core-js/modules/esnext.map.every.js","webpack://LMV/./node_modules/core-js/modules/esnext.map.filter.js","webpack://LMV/./node_modules/core-js/modules/esnext.map.find-key.js","webpack://LMV/./node_modules/core-js/modules/esnext.map.find.js","webpack://LMV/./node_modules/core-js/modules/esnext.map.from.js","webpack://LMV/./node_modules/core-js/modules/esnext.map.group-by.js","webpack://LMV/./node_modules/core-js/modules/esnext.map.includes.js","webpack://LMV/./node_modules/core-js/modules/esnext.map.key-by.js","webpack://LMV/./node_modules/core-js/modules/esnext.map.key-of.js","webpack://LMV/./node_modules/core-js/modules/esnext.map.map-keys.js","webpack://LMV/./node_modules/core-js/modules/esnext.map.map-values.js","webpack://LMV/./node_modules/core-js/modules/esnext.map.merge.js","webpack://LMV/./node_modules/core-js/modules/esnext.map.of.js","webpack://LMV/./node_modules/core-js/modules/esnext.map.reduce.js","webpack://LMV/./node_modules/core-js/modules/esnext.map.some.js","webpack://LMV/./node_modules/core-js/modules/esnext.map.update.js","webpack://LMV/./node_modules/core-js/modules/esnext.math.clamp.js","webpack://LMV/./node_modules/core-js/modules/esnext.math.deg-per-rad.js","webpack://LMV/./node_modules/core-js/modules/esnext.math.degrees.js","webpack://LMV/./node_modules/core-js/modules/esnext.math.fscale.js","webpack://LMV/./node_modules/core-js/modules/esnext.math.iaddh.js","webpack://LMV/./node_modules/core-js/modules/esnext.math.imulh.js","webpack://LMV/./node_modules/core-js/modules/esnext.math.isubh.js","webpack://LMV/./node_modules/core-js/modules/esnext.math.rad-per-deg.js","webpack://LMV/./node_modules/core-js/modules/esnext.math.radians.js","webpack://LMV/./node_modules/core-js/modules/esnext.math.scale.js","webpack://LMV/./node_modules/core-js/modules/esnext.math.seeded-prng.js","webpack://LMV/./node_modules/core-js/modules/esnext.math.signbit.js","webpack://LMV/./node_modules/core-js/modules/esnext.math.umulh.js","webpack://LMV/./node_modules/core-js/modules/esnext.number.from-string.js","webpack://LMV/./node_modules/core-js/modules/esnext.observable.js","webpack://LMV/./node_modules/core-js/modules/esnext.promise.all-settled.js","webpack://LMV/./node_modules/core-js/modules/esnext.promise.any.js","webpack://LMV/./node_modules/core-js/modules/esnext.promise.try.js","webpack://LMV/./node_modules/core-js/modules/esnext.reflect.define-metadata.js","webpack://LMV/./node_modules/core-js/modules/esnext.reflect.delete-metadata.js","webpack://LMV/./node_modules/core-js/modules/esnext.reflect.get-metadata-keys.js","webpack://LMV/./node_modules/core-js/modules/esnext.reflect.get-metadata.js","webpack://LMV/./node_modules/core-js/modules/esnext.reflect.get-own-metadata-keys.js","webpack://LMV/./node_modules/core-js/modules/esnext.reflect.get-own-metadata.js","webpack://LMV/./node_modules/core-js/modules/esnext.reflect.has-metadata.js","webpack://LMV/./node_modules/core-js/modules/esnext.reflect.has-own-metadata.js","webpack://LMV/./node_modules/core-js/modules/esnext.reflect.metadata.js","webpack://LMV/./node_modules/core-js/modules/esnext.set.add-all.js","webpack://LMV/./node_modules/core-js/modules/esnext.set.delete-all.js","webpack://LMV/./node_modules/core-js/modules/esnext.set.difference.js","webpack://LMV/./node_modules/core-js/modules/esnext.set.every.js","webpack://LMV/./node_modules/core-js/modules/esnext.set.filter.js","webpack://LMV/./node_modules/core-js/modules/esnext.set.find.js","webpack://LMV/./node_modules/core-js/modules/esnext.set.from.js","webpack://LMV/./node_modules/core-js/modules/esnext.set.intersection.js","webpack://LMV/./node_modules/core-js/modules/esnext.set.is-disjoint-from.js","webpack://LMV/./node_modules/core-js/modules/esnext.set.is-subset-of.js","webpack://LMV/./node_modules/core-js/modules/esnext.set.is-superset-of.js","webpack://LMV/./node_modules/core-js/modules/esnext.set.join.js","webpack://LMV/./node_modules/core-js/modules/esnext.set.map.js","webpack://LMV/./node_modules/core-js/modules/esnext.set.of.js","webpack://LMV/./node_modules/core-js/modules/esnext.set.reduce.js","webpack://LMV/./node_modules/core-js/modules/esnext.set.some.js","webpack://LMV/./node_modules/core-js/modules/esnext.set.symmetric-difference.js","webpack://LMV/./node_modules/core-js/modules/esnext.set.union.js","webpack://LMV/./node_modules/core-js/modules/esnext.string.at.js","webpack://LMV/./node_modules/core-js/modules/esnext.string.code-points.js","webpack://LMV/./node_modules/core-js/modules/esnext.string.match-all.js","webpack://LMV/./node_modules/core-js/modules/esnext.string.replace-all.js","webpack://LMV/./node_modules/core-js/modules/esnext.symbol.dispose.js","webpack://LMV/./node_modules/core-js/modules/esnext.symbol.observable.js","webpack://LMV/./node_modules/core-js/modules/esnext.symbol.pattern-match.js","webpack://LMV/./node_modules/core-js/modules/esnext.weak-map.delete-all.js","webpack://LMV/./node_modules/core-js/modules/esnext.weak-map.from.js","webpack://LMV/./node_modules/core-js/modules/esnext.weak-map.of.js","webpack://LMV/./node_modules/core-js/modules/esnext.weak-set.add-all.js","webpack://LMV/./node_modules/core-js/modules/esnext.weak-set.delete-all.js","webpack://LMV/./node_modules/core-js/modules/esnext.weak-set.from.js","webpack://LMV/./node_modules/core-js/modules/esnext.weak-set.of.js","webpack://LMV/./node_modules/core-js/modules/web.dom-collections.for-each.js","webpack://LMV/./node_modules/core-js/modules/web.dom-collections.iterator.js","webpack://LMV/./node_modules/core-js/modules/web.immediate.js","webpack://LMV/./node_modules/core-js/modules/web.queue-microtask.js","webpack://LMV/./node_modules/core-js/modules/web.url-search-params.js","webpack://LMV/./node_modules/core-js/modules/web.url.js","webpack://LMV/./node_modules/core-js/modules/web.url.to-json.js","webpack://LMV/./node_modules/pako/index.js","webpack://LMV/./node_modules/pako/lib/deflate.js","webpack://LMV/./node_modules/pako/lib/inflate.js","webpack://LMV/./node_modules/pako/lib/utils/common.js","webpack://LMV/./node_modules/pako/lib/utils/strings.js","webpack://LMV/./node_modules/pako/lib/zlib/adler32.js","webpack://LMV/./node_modules/pako/lib/zlib/constants.js","webpack://LMV/./node_modules/pako/lib/zlib/crc32.js","webpack://LMV/./node_modules/pako/lib/zlib/deflate.js","webpack://LMV/./node_modules/pako/lib/zlib/gzheader.js","webpack://LMV/./node_modules/pako/lib/zlib/inffast.js","webpack://LMV/./node_modules/pako/lib/zlib/inflate.js","webpack://LMV/./node_modules/pako/lib/zlib/inftrees.js","webpack://LMV/./node_modules/pako/lib/zlib/messages.js","webpack://LMV/./node_modules/pako/lib/zlib/trees.js","webpack://LMV/./node_modules/pako/lib/zlib/zstream.js","webpack://LMV/./node_modules/pend/index.js","webpack://LMV/./node_modules/process/browser.js","webpack://LMV/./node_modules/regenerator-runtime/runtime.js","webpack://LMV/./node_modules/setimmediate/setImmediate.js","webpack://LMV/./node_modules/timers-browserify/main.js","webpack://LMV/(webpack)/buildin/amd-options.js","webpack://LMV/(webpack)/buildin/global.js","webpack://LMV/(webpack)/buildin/module.js","webpack://LMV/./src/analytics/analyticsData.js","webpack://LMV/./src/analytics/index.js","webpack://LMV/./src/analytics/providers/interface.js","webpack://LMV/./src/analytics/providers/providersExtensions.js","webpack://LMV/./src/animation/Animation.js","webpack://LMV/./src/animation/AnimationHandler.js","webpack://LMV/./src/animation/InterpolationType.js","webpack://LMV/./src/animation/KeyFrameAnimator.js","webpack://LMV/./src/animation/type/AnnotationAnimation.js","webpack://LMV/./src/animation/type/CameraAnimation.js","webpack://LMV/./src/animation/type/MeshAnimation.js","webpack://LMV/./src/animation/type/PolylineAnimation.js","webpack://LMV/./src/animation/type/VisibilityAnimation.js","webpack://LMV/./src/application/AggregatedView.js","webpack://LMV/./src/application/CameraLS.js","webpack://LMV/./src/application/Document.js","webpack://LMV/./src/application/DynamicGlobalOffset.js","webpack://LMV/./src/application/EventDispatcher.js","webpack://LMV/./src/application/EventTypes.js","webpack://LMV/./src/application/EventUtils.js","webpack://LMV/./src/application/Extension.js","webpack://LMV/./src/application/ExtensionManager.js","webpack://LMV/./src/application/FileLoader.js","webpack://LMV/./src/application/FileLoaderManager.js","webpack://LMV/./src/application/ForgeLogoSpinner.js","webpack://LMV/./src/application/GlobalManager.js","webpack://LMV/./src/application/GlobalManagerMixin.js","webpack://LMV/./src/application/LightPresets.js","webpack://LMV/./src/application/LoadingSpinner.js","webpack://LMV/./src/application/LocalStorage.js","webpack://LMV/./src/application/Model.js","webpack://LMV/./src/application/ModelLayers.js","webpack://LMV/./src/application/ModelMemoryTracker.js","webpack://LMV/./src/application/OverlayManager.js","webpack://LMV/./src/application/PreferenceNames.js","webpack://LMV/./src/application/Preferences.js","webpack://LMV/./src/application/Profile.js","webpack://LMV/./src/application/ProfileManager.js","webpack://LMV/./src/application/ProfileSettings.js","webpack://LMV/./src/application/ProgressState.js","webpack://LMV/./src/application/ScreenModeDelegate.js","webpack://LMV/./src/application/ScreenShot.js","webpack://LMV/./src/application/Thumbnails.js","webpack://LMV/./src/application/Viewer3D.css?11ef","webpack://LMV/./src/application/Viewer3D.js","webpack://LMV/./src/application/Viewer3DImpl.js","webpack://LMV/./src/application/ViewerState.js","webpack://LMV/./src/application/bubble.js","webpack://LMV/./src/compat.js","webpack://LMV/./src/envinit.js","webpack://LMV/./src/file-loaders/lmvtk/common/InputStream.js","webpack://LMV/./src/file-loaders/lmvtk/common/StringUtils.js","webpack://LMV/./src/file-loaders/lmvtk/common/SvfPlacementUtils.js","webpack://LMV/./src/file-loaders/lmvtk/common/VertexBufferBuilder.js","webpack://LMV/./src/file-loaders/lmvtk/otg/HashStrings.js","webpack://LMV/./src/file-loaders/lmvtk/otg/Otg.js","webpack://LMV/./src/file-loaders/lmvtk/otg/OtgGeomCodec.js","webpack://LMV/./src/file-loaders/lmvtk/otg/OtgPriorityQueue.js","webpack://LMV/./src/file-loaders/lmvtk/otg/ProgressiveReadContext.js","webpack://LMV/./src/file-loaders/loader-extensions.js","webpack://LMV/./src/file-loaders/main/Empty2DModelLoader.js","webpack://LMV/./src/file-loaders/main/F2DLoader.js","webpack://LMV/./src/file-loaders/main/LeafletLoader.js","webpack://LMV/./src/file-loaders/main/OtgLoader.js","webpack://LMV/./src/file-loaders/main/OtgResourceCache.js","webpack://LMV/./src/file-loaders/main/PropDbLoader.js","webpack://LMV/./src/file-loaders/main/SvfLoader.js","webpack://LMV/./src/file-loaders/main/TextureLoader.js","webpack://LMV/./src/file-loaders/main/WorkerCreator.js","webpack://LMV/./src/file-loaders/main/WorkerCreatorWasm.js","webpack://LMV/./src/file-loaders/net/ErrorCodes.js","webpack://LMV/./src/file-loaders/net/Xhr.js","webpack://LMV/./src/file-loaders/net/endpoints.js","webpack://LMV/./src/globalization/i18init.js","webpack://LMV/./src/globalization/i18next.js","webpack://LMV/./src/globalization/langs.js","webpack://LMV/./src/globals.js","webpack://LMV/./src/gui/AlertBox.css?c6e8","webpack://LMV/./src/gui/AlertBox.js","webpack://LMV/./src/gui/CommonWidgets.css?6cd2","webpack://LMV/./src/gui/CommonWidgets.js","webpack://LMV/./src/gui/ContextMenu.css?2497","webpack://LMV/./src/gui/ContextMenu.js","webpack://LMV/./src/gui/DataTable.css?ac98","webpack://LMV/./src/gui/DataTable.js","webpack://LMV/./src/gui/DockingPanel.css?42f9","webpack://LMV/./src/gui/DockingPanel.js","webpack://LMV/./src/gui/ErrorHandler.js","webpack://LMV/./src/gui/GuiViewer3D.css?10b0","webpack://LMV/./src/gui/GuiViewer3D.js","webpack://LMV/./src/gui/GuiViewerToolbarConst.js","webpack://LMV/./src/gui/HudMessage.css?4131","webpack://LMV/./src/gui/HudMessage.js","webpack://LMV/./src/gui/LightPresetThumbnails.js","webpack://LMV/./src/gui/LoadingSpinner.css?94ff","webpack://LMV/./src/gui/LoadingSpinner.js","webpack://LMV/./src/gui/ModelStructurePanel.css?ccfc","webpack://LMV/./src/gui/ModelStructurePanel.js","webpack://LMV/./src/gui/ModelStructureTreeDelegate.css?7f42","webpack://LMV/./src/gui/ModelStructureTreeDelegate.js","webpack://LMV/./src/gui/ObjectContextMenu.js","webpack://LMV/./src/gui/Panel.css?8cf4","webpack://LMV/./src/gui/ProgressBar.css?2d92","webpack://LMV/./src/gui/ProgressBar.js","webpack://LMV/./src/gui/PropertyPanel.css?7367","webpack://LMV/./src/gui/PropertyPanel.js","webpack://LMV/./src/gui/RenderOptionsPanel.js","webpack://LMV/./src/gui/SettingsPanel.css?eb43","webpack://LMV/./src/gui/SettingsPanel.js","webpack://LMV/./src/gui/Tree.css?079e","webpack://LMV/./src/gui/Tree.js","webpack://LMV/./src/gui/TreeDelegate.js","webpack://LMV/./src/gui/TreeOnDemand.css?d983","webpack://LMV/./src/gui/TreeOnDemand.js","webpack://LMV/./src/gui/ViewerModelStructurePanel.css?62f0","webpack://LMV/./src/gui/ViewerModelStructurePanel.js","webpack://LMV/./src/gui/ViewerObjectContextMenu.js","webpack://LMV/./src/gui/ViewerPanelMixin.js","webpack://LMV/./src/gui/ViewerPropertyPanel.js","webpack://LMV/./src/gui/ViewerSettingsPanel.css?878e","webpack://LMV/./src/gui/ViewerSettingsPanel.js","webpack://LMV/./src/gui/browser/browser.css?c73c","webpack://LMV/./src/gui/browser/browser.js","webpack://LMV/./src/gui/controls/Button.css?5f69","webpack://LMV/./src/gui/controls/Button.js","webpack://LMV/./src/gui/controls/ComboButton.css?d95a","webpack://LMV/./src/gui/controls/ComboButton.js","webpack://LMV/./src/gui/controls/Control.css?ff5b","webpack://LMV/./src/gui/controls/Control.js","webpack://LMV/./src/gui/controls/ControlGroup.css?d802","webpack://LMV/./src/gui/controls/ControlGroup.js","webpack://LMV/./src/gui/controls/Filterbox.css?8938","webpack://LMV/./src/gui/controls/Filterbox.js","webpack://LMV/./src/gui/controls/RadioButtonGroup.js","webpack://LMV/./src/gui/controls/SearchEvents.js","webpack://LMV/./src/gui/controls/SearchResults.css?41e9","webpack://LMV/./src/gui/controls/SearchResults.js","webpack://LMV/./src/gui/controls/Searchbox.css?a17b","webpack://LMV/./src/gui/controls/Searchbox.js","webpack://LMV/./src/gui/icon-fonts/codes.css?7ff9","webpack://LMV/./src/gui/icon-fonts/header.css?2c0a","webpack://LMV/./src/gui/splitview-layout/SplitViewHorizontalHandler.js","webpack://LMV/./src/gui/splitview-layout/SplitViewLayout.js","webpack://LMV/./src/gui/splitview-layout/SplitViewLayout.scss?f4fe","webpack://LMV/./src/gui/splitview-layout/SplitViewResizeHandler.js","webpack://LMV/./src/gui/splitview-layout/SplitViewVerticalHandler.js","webpack://LMV/./src/gui/themes/AcsTheme.css?652e","webpack://LMV/./src/gui/themes/BimTheme.css?2f01","webpack://LMV/./src/gui/themes/DarkTheme.css?4e3f","webpack://LMV/./src/gui/themes/DarkThemeHyperlink.css?f7a2","webpack://LMV/./src/gui/themes/Fonts.css?a364","webpack://LMV/./src/gui/themes/LightTheme.css?7650","webpack://LMV/./src/gui/themes/LightThemeHyperlink.css?8498","webpack://LMV/./src/gui/toolbar/ToolBar.css?105b","webpack://LMV/./src/gui/toolbar/ToolBar.js","webpack://LMV/./src/index-css.js","webpack://LMV/./src/index.js","webpack://LMV/./src/leech-viewer/CrossViewerInteractionCommon.js","webpack://LMV/./src/leech-viewer/LeechViewer.js","webpack://LMV/./src/leech-viewer/LeechViewerRenderContext.js","webpack://LMV/./src/leech-viewer/MultiViewerFactory.js","webpack://LMV/./src/logger/Logger.js","webpack://LMV/./src/measurement/DisplayUnits.js","webpack://LMV/./src/measurement/MeasureCommon.js","webpack://LMV/./src/measurement/MeasureEvents.js","webpack://LMV/./src/measurement/Measurement.js","webpack://LMV/./src/measurement/MeasurementTypes.js","webpack://LMV/./src/measurement/PDFUtils.js","webpack://LMV/./src/measurement/SnapResult.js","webpack://LMV/./src/measurement/SnapTypes.js","webpack://LMV/./src/measurement/UnitFormatter.js","webpack://LMV/./src/measurement/UnitParser.js","webpack://LMV/./src/mobile/MobileCallbacks.js","webpack://LMV/./src/module-prefix.js","webpack://LMV/./src/module-suffix.js","webpack://LMV/./src/net/LiveReviewClient.js","webpack://LMV/./src/net/MessageClient.js","webpack://LMV/./src/resource-loader.js","webpack://LMV/./src/search/SearchManager.js","webpack://LMV/./src/search/providers/ModelPartsSearchProvider.js","webpack://LMV/./src/search/providers/PropertiesSearchProvider.js","webpack://LMV/./src/search/providers/SearchProviderInterface.js","webpack://LMV/./src/search/providers/TextSearchProvider.js","webpack://LMV/./src/tools/DefaultHandler.js","webpack://LMV/./src/tools/FovTool.js","webpack://LMV/./src/tools/GestureHandler.js","webpack://LMV/./src/tools/HotGestureTool.js","webpack://LMV/./src/tools/HotkeyManager.js","webpack://LMV/./src/tools/KeyCode.js","webpack://LMV/./src/tools/Navigation.js","webpack://LMV/./src/tools/OrbitDollyPanTool.js","webpack://LMV/./src/tools/SelectionType.js","webpack://LMV/./src/tools/Selector.js","webpack://LMV/./src/tools/ToolController.js","webpack://LMV/./src/tools/ToolInterface.js","webpack://LMV/./src/tools/UnifiedCamera.js","webpack://LMV/./src/tools/ViewingUtilities.js","webpack://LMV/./src/tools/VisibilityManager.js","webpack://LMV/./src/tools/WorldUpTool.js","webpack://LMV/./src/tools/autocam/Autocam.js","webpack://LMV/./src/tools/viewtransitions/ViewTransition.js","webpack://LMV/./src/wasm/Wasm.js","webpack://LMV/./src/wgs/globals.js","webpack://LMV/./src/wgs/render/BackgroundShader.js","webpack://LMV/./src/wgs/render/BasicShader.js","webpack://LMV/./src/wgs/render/BlendShader.js","webpack://LMV/./src/wgs/render/CelShader.js","webpack://LMV/./src/wgs/render/CopyShader.js","webpack://LMV/./src/wgs/render/DecodeEnvMap.js","webpack://LMV/./src/wgs/render/EdgeShader.js","webpack://LMV/./src/wgs/render/FXAAShader.js","webpack://LMV/./src/wgs/render/GaussianPass.js","webpack://LMV/./src/wgs/render/GroundFlags.js","webpack://LMV/./src/wgs/render/GroundReflection.js","webpack://LMV/./src/wgs/render/GroundShadow.js","webpack://LMV/./src/wgs/render/HalfFloat.js","webpack://LMV/./src/wgs/render/LineShader.js","webpack://LMV/./src/wgs/render/LineShaderSS.js","webpack://LMV/./src/wgs/render/LineStyleDef.js","webpack://LMV/./src/wgs/render/MaterialConverter.js","webpack://LMV/./src/wgs/render/MaterialConverterCommon.js","webpack://LMV/./src/wgs/render/MaterialManager.js","webpack://LMV/./src/wgs/render/NormalsShader.js","webpack://LMV/./src/wgs/render/PhongShader.js","webpack://LMV/./src/wgs/render/PrismUtil.js","webpack://LMV/./src/wgs/render/RenderContext.js","webpack://LMV/./src/wgs/render/RenderContextPostProcess.js","webpack://LMV/./src/wgs/render/SAOBlurShader.js","webpack://LMV/./src/wgs/render/SAOMinifyShader.js","webpack://LMV/./src/wgs/render/SAOShader.js","webpack://LMV/./src/wgs/render/ShaderChunks.js","webpack://LMV/./src/wgs/render/ShaderPass.js","webpack://LMV/./src/wgs/render/ShaderUtils.js","webpack://LMV/./src/wgs/render/ShadowMap.js","webpack://LMV/./src/wgs/render/SheetRenderContext.js","webpack://LMV/./src/wgs/render/WebGLProgram.js","webpack://LMV/./src/wgs/render/WebGLRenderer.js","webpack://LMV/./src/wgs/render/WebGLShader.js","webpack://LMV/./src/wgs/render/chunks/cutplanes.glsl","webpack://LMV/./src/wgs/render/chunks/decl_point_size.glsl","webpack://LMV/./src/wgs/render/chunks/depth_texture.glsl","webpack://LMV/./src/wgs/render/chunks/env_sample.glsl","webpack://LMV/./src/wgs/render/chunks/final_frag.glsl","webpack://LMV/./src/wgs/render/chunks/float3_average.glsl","webpack://LMV/./src/wgs/render/chunks/hatch_pattern.glsl","webpack://LMV/./src/wgs/render/chunks/hsv.glsl","webpack://LMV/./src/wgs/render/chunks/id_decl_frag.glsl","webpack://LMV/./src/wgs/render/chunks/id_decl_vert.glsl","webpack://LMV/./src/wgs/render/chunks/id_frag.glsl","webpack://LMV/./src/wgs/render/chunks/id_vert.glsl","webpack://LMV/./src/wgs/render/chunks/instancing_decl_vert.glsl","webpack://LMV/./src/wgs/render/chunks/line_decl_common.glsl","webpack://LMV/./src/wgs/render/chunks/normal_map.glsl","webpack://LMV/./src/wgs/render/chunks/ordered_dither.glsl","webpack://LMV/./src/wgs/render/chunks/pack_depth.glsl","webpack://LMV/./src/wgs/render/chunks/pack_normals.glsl","webpack://LMV/./src/wgs/render/chunks/point_size.glsl","webpack://LMV/./src/wgs/render/chunks/prism_glazing.glsl","webpack://LMV/./src/wgs/render/chunks/prism_transparency.glsl","webpack://LMV/./src/wgs/render/chunks/prism_wood.glsl","webpack://LMV/./src/wgs/render/chunks/shadowmap_decl_common.glsl","webpack://LMV/./src/wgs/render/chunks/shadowmap_decl_frag.glsl","webpack://LMV/./src/wgs/render/chunks/shadowmap_decl_vert.glsl","webpack://LMV/./src/wgs/render/chunks/shadowmap_vert.glsl","webpack://LMV/./src/wgs/render/chunks/theming_decl_frag.glsl","webpack://LMV/./src/wgs/render/chunks/theming_frag.glsl","webpack://LMV/./src/wgs/render/chunks/tonemap.glsl","webpack://LMV/./src/wgs/render/chunks/wide_lines_decl.glsl","webpack://LMV/./src/wgs/render/chunks/wide_lines_vert.glsl","webpack://LMV/./src/wgs/render/shaders/background_frag.glsl","webpack://LMV/./src/wgs/render/shaders/background_vert.glsl","webpack://LMV/./src/wgs/render/shaders/basic_frag.glsl","webpack://LMV/./src/wgs/render/shaders/basic_vert.glsl","webpack://LMV/./src/wgs/render/shaders/blend_frag.glsl","webpack://LMV/./src/wgs/render/shaders/cel_frag.glsl","webpack://LMV/./src/wgs/render/shaders/copy_frag.glsl","webpack://LMV/./src/wgs/render/shaders/edge_frag.glsl","webpack://LMV/./src/wgs/render/shaders/edge_vert.glsl","webpack://LMV/./src/wgs/render/shaders/fxaa_frag.glsl","webpack://LMV/./src/wgs/render/shaders/fxaa_vert.glsl","webpack://LMV/./src/wgs/render/shaders/gaussian_frag.glsl","webpack://LMV/./src/wgs/render/shaders/gaussian_vert.glsl","webpack://LMV/./src/wgs/render/shaders/groundreflection_draw_frag.glsl","webpack://LMV/./src/wgs/render/shaders/groundshadow_ao_frag.glsl","webpack://LMV/./src/wgs/render/shaders/groundshadow_blur_frag.glsl","webpack://LMV/./src/wgs/render/shaders/groundshadow_color_frag.glsl","webpack://LMV/./src/wgs/render/shaders/groundshadow_depth_frag.glsl","webpack://LMV/./src/wgs/render/shaders/groundshadow_depth_vert.glsl","webpack://LMV/./src/wgs/render/shaders/line_frag.glsl","webpack://LMV/./src/wgs/render/shaders/line_vert.glsl","webpack://LMV/./src/wgs/render/shaders/liness_frag.glsl","webpack://LMV/./src/wgs/render/shaders/liness_vert.glsl","webpack://LMV/./src/wgs/render/shaders/normals_frag.glsl","webpack://LMV/./src/wgs/render/shaders/normals_vert.glsl","webpack://LMV/./src/wgs/render/shaders/phong_frag.glsl","webpack://LMV/./src/wgs/render/shaders/phong_vert.glsl","webpack://LMV/./src/wgs/render/shaders/sao_blur_frag.glsl","webpack://LMV/./src/wgs/render/shaders/sao_frag.glsl","webpack://LMV/./src/wgs/render/shaders/sao_min_frag.glsl","webpack://LMV/./src/wgs/render/shaders/sao_minfirst_frag.glsl","webpack://LMV/./src/wgs/render/shaders/screen_quad_uv_vert.glsl","webpack://LMV/./src/wgs/render/shaders/screen_quad_vert.glsl","webpack://LMV/./src/wgs/render/shaders/shadowmap_frag.glsl","webpack://LMV/./src/wgs/render/shaders/shadowmap_ground_frag.glsl","webpack://LMV/./src/wgs/render/shaders/shadowmap_ground_vert.glsl","webpack://LMV/./src/wgs/render/shaders/shadowmap_vert.glsl","webpack://LMV/./src/wgs/render/shaders/sheet_render_frag.glsl","webpack://LMV/./src/wgs/render/shaders/sheet_render_vert.glsl","webpack://LMV/./src/wgs/scene/BVHBuilder.js","webpack://LMV/./src/wgs/scene/BufferGeometry.js","webpack://LMV/./src/wgs/scene/DeriveTopology.js","webpack://LMV/./src/wgs/scene/FragmentList.js","webpack://LMV/./src/wgs/scene/FrustumIntersector.js","webpack://LMV/./src/wgs/scene/GeometryList.js","webpack://LMV/./src/wgs/scene/InstanceTree.js","webpack://LMV/./src/wgs/scene/InstanceTreeStorage.js","webpack://LMV/./src/wgs/scene/IntArray.js","webpack://LMV/./src/wgs/scene/LmvBox3.js","webpack://LMV/./src/wgs/scene/LmvMatrix4.js","webpack://LMV/./src/wgs/scene/LmvVector3.js","webpack://LMV/./src/wgs/scene/MeshFlags.js","webpack://LMV/./src/wgs/scene/ModelExploder.js","webpack://LMV/./src/wgs/scene/ModelIteratorBVH.js","webpack://LMV/./src/wgs/scene/ModelIteratorLinear.js","webpack://LMV/./src/wgs/scene/RenderBatch.js","webpack://LMV/./src/wgs/scene/RenderFlags.js","webpack://LMV/./src/wgs/scene/RenderModel.js","webpack://LMV/./src/wgs/scene/RenderScene.js","webpack://LMV/./src/wgs/scene/ResetFlags.js","webpack://LMV/./src/wgs/scene/SceneMath.js","webpack://LMV/./src/wgs/scene/SelectionMode.js","webpack://LMV/./src/wgs/scene/SortedList.js","webpack://LMV/./src/wgs/scene/VBIntersector.js","webpack://LMV/./src/wgs/scene/VertexBufferReader.js","webpack://LMV/./src/wgs/scene/VertexBufferWriter.js","webpack://LMV/./src/wgs/scene/VertexEnumerator.js","webpack://LMV/./src/wgs/scene/consolidation/Consolidation.js","webpack://LMV/./src/wgs/scene/consolidation/ConsolidationIterator.js","webpack://LMV/./src/wgs/scene/consolidation/FragmentListConsolidation.js","webpack://LMV/./src/wgs/scene/consolidation/GeomMergeTask.js","webpack://LMV/./src/wgs/scene/consolidation/InstanceBufferBuilder.js","webpack://LMV/./src/wgs/scene/consolidation/ParallelGeomMerge.js","webpack://LMV/./src/wgs/scene/leaflet/ModelIteratorTexQuad.js","webpack://LMV/./src/wgs/scene/leaflet/TexQuadUtils.js","webpack://LMV/./src/wgs/scene/leaflet/TileCoords.js","webpack://LMV/./thirdparty/hammer/hammer.js","webpack://LMV/./thirdparty/lodash/lodash.custom.js","webpack://LMV/./thirdparty/resize-observer-polyfill/ResizeObserver.min.js","webpack://LMV/./thirdparty/three.js/DDSLoader.js","webpack://LMV/./thirdparty/three.js/three.js"],"sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/index.js\");\n","\nimport { Extension } from \"../../src/application/Extension\";\nimport { TOOL_CHANGE_EVENT, NAVIGATION_MODE_CHANGED_EVENT, CAMERA_CHANGE_EVENT } from \"../../src/application/EventTypes\";\nimport { TOOLBAR } from \"../../src/gui/GuiViewerToolbarConst\";\nimport { ComboButton } from \"../../src/gui/controls/ComboButton\";\nimport { Button } from \"../../src/gui/controls/Button\";\nimport { FovTool } from \"../../src/tools/FovTool\";\nimport { WorldUpTool } from \"../../src/tools/WorldUpTool\";\nimport { i18n } from \"../../src/globalization/i18next\";\nimport { RadioButtonGroup } from \"../../src/gui/controls/RadioButtonGroup\";\nimport { isTouchDevice } from \"../../src/compat\";\nimport { HudMessage } from \"../../src/gui/HudMessage\";\n\n\nvar MODE_PAN = 'pan';\nvar MODE_DOLLY = 'dolly';\nvar MODE_FREE_ORBIT = 'freeorbit';\nvar MODE_ORBIT = 'orbit';\nvar MODE_FOV = 'fov'; // it's actually just an action.\nvar MODE_WORLD_UP = 'worldup';\nvar MODE_FIT_TO_VIEW = 'fittoview';\n\n/**\n * Adds toolbar buttons to Orbit, Pan and Dolly.\n * It also adds camera interaction buttons for Fit to View, Focal Length and Roll \n * \n * The extension id is: `Autodesk.DefaultTools.NavTools`\n * \n * @example\n * viewer.loadExtension('Autodesk.DefaultTools.NavTools')\n * \n * @memberof Autodesk.Viewing.Extensions\n * @alias Autodesk.Viewing.Extensions.NavToolsExtension\n * @see {@link Autodesk.Viewing.Extension} for common inherited methods.\n * @constructor\n */\nexport function NavToolsExtension(viewer, options) {\n Extension.call(this, viewer, options);\n this.name = 'navtools';\n this.modes = [MODE_PAN, MODE_DOLLY, MODE_FREE_ORBIT, MODE_ORBIT, MODE_FOV, MODE_WORLD_UP, MODE_FIT_TO_VIEW];\n this.onToolChanged = this.onToolChanged.bind(this);\n this.onNavigationModeChanged = this.onNavigationModeChanged.bind(this);\n this.navToolsConfig = options.navToolsConfig || {};\n}\n\nNavToolsExtension.prototype = Object.create(Extension.prototype);\nNavToolsExtension.prototype.constructor = NavToolsExtension;\n\nvar proto = NavToolsExtension.prototype;\n\nfunction createNavToggler(self, button, mode) {\n return function () {\n if (self.isActive(mode)) {\n self.deactivate();\n } else {\n self.activate(mode);\n }\n };\n}\n\nproto.load = function () {\n var viewer = this.viewer;\n\n // Register tools\n var fovtool = new FovTool(viewer);\n viewer.toolController.registerTool(fovtool);\n\n if (!this.navToolsConfig.isAECCameraControls) {\n var rolltool = new WorldUpTool(viewer.impl, viewer);\n viewer.toolController.registerTool(rolltool);\n }\n\n this.initFocalLengthOverlay();\n\n viewer.addEventListener(TOOL_CHANGE_EVENT, this.onToolChanged);\n viewer.addEventListener(NAVIGATION_MODE_CHANGED_EVENT, this.onNavigationModeChanged);\n\n return true;\n};\n\n// Ensure that toolbar is properly configured for 2d/3d\nproto.updateUI = function (is3d) {\n if (is3d !== this.is3d) {\n this._destroyUI();\n this._createUI(is3d);\n }\n};\n\nproto.onToolbarCreated = function (toolbar) {\n var is3d = !this.viewer.impl.is2d;\n this._createUI(is3d);\n};\n\nproto.navActionDisplayMode = function (action) {\n return this.viewer.navigation.isActionEnabled(action) ? 'block' : 'none';\n};\n\nproto._createUI = function (is3d)\n{\n // Adds the UI for the default navigation tools (orbit, pan, dolly, camera controls)\n var viewer = this.viewer;\n var toolbar = viewer.getToolbar();\n var navTools = toolbar.getControl(TOOLBAR.NAVTOOLSID);\n\n if (is3d) {\n var orbitToolsButton = new ComboButton('toolbar-orbitTools');\n orbitToolsButton.setToolTip('Orbit');\n orbitToolsButton.setIcon(\"adsk-icon-orbit-constrained\");\n orbitToolsButton.setDisplay(this.navActionDisplayMode('orbit'));\n\n this.createOrbitSubmenu(orbitToolsButton);\n\n navTools.addControl(orbitToolsButton);\n navTools.orbittoolsbutton = orbitToolsButton;\n orbitToolsButton.setState(Button.State.ACTIVE);\n\n navTools.returnToDefault = function () {\n orbitToolsButton.setState(Button.State.ACTIVE);\n };\n }\n\n var panButton = new Button('toolbar-panTool');\n panButton.setToolTip('Pan');\n panButton.setIcon(\"adsk-icon-pan\");\n panButton.onClick = createNavToggler(this, panButton, MODE_PAN);\n panButton.setDisplay(this.navActionDisplayMode('pan'));\n\n navTools.addControl(panButton);\n navTools.panbutton = panButton;\n\n if (!is3d) {\n navTools.returnToDefault = function () {\n panButton.setState(Button.State.ACTIVE);\n };\n navTools.returnToDefault(); // Assume 'pan' is the default navigation tool.\n }\n\n var dollyButton = new Button('toolbar-zoomTool');\n dollyButton.setToolTip('Zoom');\n dollyButton.setIcon(\"adsk-icon-zoom\");\n dollyButton.onClick = createNavToggler(this, dollyButton, MODE_DOLLY);\n dollyButton.setDisplay(this.navActionDisplayMode('zoom'));\n\n navTools.addControl(dollyButton);\n navTools.dollybutton = dollyButton;\n\n if (this.navToolsConfig.isAECCameraControls) {\n // AEC applications such as Docs and Design Collaboration only have a need for Fit to View\n navTools.addControl(this.createFitViewButton(navTools));\n } else {\n var cameraButton = new ComboButton('toolbar-cameraSubmenuTool');\n cameraButton.setToolTip('Camera interactions');\n cameraButton.setIcon(\"adsk-icon-camera\");\n cameraButton.saveAsDefault();\n this.createCameraSubmenu(cameraButton, is3d);\n navTools.addControl(cameraButton);\n navTools.camerabutton = cameraButton;\n }\n\n // remember if we initialized for 3d or 2d\n this.is3d = is3d;\n};\n\nproto.createOrbitSubmenu = function (parentButton) {\n var viewer = this.viewer;\n var toolbar = viewer.getToolbar();\n var navTools = toolbar.getControl(TOOLBAR.NAVTOOLSID);\n\n var freeOrbitButton = new Button('toolbar-freeOrbitTool');\n freeOrbitButton.setToolTip('Free orbit');\n freeOrbitButton.setIcon(\"adsk-icon-orbit-free\");\n freeOrbitButton.onClick = createNavToggler(this, freeOrbitButton, MODE_FREE_ORBIT);\n\n parentButton.addControl(freeOrbitButton);\n navTools.freeorbitbutton = freeOrbitButton;\n\n var orbitButton = new Button('toolbar-orbitTool');\n orbitButton.setToolTip('Orbit');\n orbitButton.setIcon(\"adsk-icon-orbit-constrained\");\n orbitButton.onClick = createNavToggler(this, orbitButton, MODE_ORBIT);\n\n parentButton.addControl(orbitButton);\n navTools.orbitbutton = orbitButton;\n\n parentButton.onClick = orbitButton.onClick; // default\n\n};\n\nproto.createFitViewButton = function (navTools, parentButton) {\n //options = { defaultTooltipValue : \"Fit to view (F)\" };\n var viewer = this.viewer;\n var fitToViewButton = new Button('toolbar-fitToViewTool');\n fitToViewButton.setToolTip('Fit to view');\n fitToViewButton.setIcon(\"adsk-icon-fit-to-view\");\n fitToViewButton.onClick = function (e) {\n viewer.impl.fitToView(viewer.impl.selector.getAggregateSelection());\n var analytics = Autodesk.Viewing.Private.analytics;\n analytics.track('viewer.fit_to_view', {\n from: 'UI' });\n\n var defaultNavToolName = viewer.getDefaultNavigationToolName();\n viewer.setActiveNavigationTool(defaultNavToolName);\n parentButton && parentButton.restoreDefault();\n };\n fitToViewButton.setDisplay(this.navActionDisplayMode('gotoview'));\n\n navTools.fittoviewbutton = fitToViewButton;\n\n return fitToViewButton;\n};\n\nproto.createCameraSubmenu = function (parentButton, is3d)\n{\n var self = this;\n var viewer = this.viewer;\n var toolbar = viewer.getToolbar();\n var navTools = toolbar.getControl(TOOLBAR.NAVTOOLSID);\n\n if (isTouchDevice()) {\n var homeButton = new Button('toolbar-homeTool');\n homeButton.setToolTip('Home');\n homeButton.setIcon(\"adsk-icon-home\");\n homeButton.onClick = function () {\n viewer.navigation.setRequestHomeView(true);\n var defaultNavToolName = viewer.getDefaultNavigationToolName();\n self.activate(defaultNavToolName);\n parentButton.restoreDefault();\n };\n homeButton.setDisplay(this.navActionDisplayMode('gotoview'));\n\n parentButton.addControl(homeButton);\n navTools.homebutton = homeButton;\n }\n\n parentButton.addControl(this.createFitViewButton(navTools, parentButton));\n\n if (is3d) {\n //options.defaultTooltipValue = \"Focal length (Ctrl+Shift drag)\";\n var fovButton = new Button('toolbar-focalLengthTool');\n fovButton.setToolTip('Focal length');\n fovButton.setIcon(\"adsk-icon-fov\");\n fovButton.onClick = createNavToggler(this, fovButton, MODE_FOV);\n fovButton.setDisplay(this.navActionDisplayMode('fov'));\n\n parentButton.addControl(fovButton);\n navTools.fovbutton = fovButton;\n }\n\n //options.defaultTooltipValue = \"Roll (Alt+Shift drag)\";\n var rollButton = new Button('toolbar-rollTool');\n rollButton.setToolTip('Roll');\n rollButton.setIcon(\"adsk-icon-roll\");\n rollButton.onClick = createNavToggler(this, rollButton, MODE_WORLD_UP);\n rollButton.setDisplay(this.navActionDisplayMode('roll'));\n\n parentButton.addControl(rollButton);\n navTools.rollbutton = rollButton;\n};\n\nproto.onToolChanged = function (event) {\n\n if (event.toolName === \"fov\") {\n this.showFocalLengthOverlay(event.active);\n }\n\n // Special case for ALT-drag-release\n if (event.active) {\n switch (event.toolName) {\n case \"dolly\":\n this.handleAltRelease('dollybutton');\n break;\n case \"pan\":\n this.handleAltRelease('panbutton');\n break;\n case \"worldup\":\n this.handleAltRelease('rollbutton');\n break;\n case \"fov\":\n this.handleAltRelease('fovbutton');\n break;}\n\n }\n};\n\nproto.onNavigationModeChanged = function (event) {\n var defaultNavToolName = this.viewer.getDefaultNavigationToolName();\n if (defaultNavToolName === event.id) {\n var toolbar = this.viewer.getToolbar();\n if (!toolbar)\n return;\n var navTools = toolbar.getControl(TOOLBAR.NAVTOOLSID);\n if (!navTools)\n return;\n navTools.returnToDefault && navTools.returnToDefault();\n }\n};\n\nproto.handleAltRelease = function (buttonName) {\n var toolbar = this.viewer.getToolbar();\n if (!toolbar)\n return;\n var navTools = toolbar.getControl(TOOLBAR.NAVTOOLSID);\n var button = navTools && navTools[buttonName];\n button && button.setState(Button.State.ACTIVE);\n};\n\nproto.initFocalLengthOverlay = function () {\n\n var _document = this.getDocument();\n var container = this.focallength = _document.createElement(\"div\");\n\n container.classList.add(\"message-panel\");\n container.classList.add(\"docking-panel\");\n container.classList.add(\"focal-length\");\n container.classList.add(\"docking-panel-container-solid-color-b\");\n\n var table = _document.createElement(\"table\");\n var tbody = _document.createElement(\"tbody\");\n table.appendChild(tbody);\n\n container.appendChild(table);\n this.viewer.container.appendChild(container);\n\n var row = tbody.insertRow(-1);\n var cell = row.insertCell(0);\n cell.classList.add(\"name\");\n cell.setAttribute(\"data-i18n\", \"Focal Length\");\n cell.textContent = i18n.translate(\"Focal Length\");\n\n cell = row.insertCell(1);\n cell.classList.add(\"value\");\n cell.textContent = '';\n this.fovCell = cell;\n\n container.style.visibility = \"hidden\";\n};\n\nproto.showFocalLengthOverlay = function (state) {\n var self = this;\n var viewer = this.viewer;\n var myFocalLength = 0;\n\n function showFovHudMessage(yes) {\n if (yes) {\n // Display a hud messages.\n var messageSpecs = {\n \"msgTitleKey\": \"Orthographic View Set\",\n \"messageKey\": \"The view is set to Orthographic\",\n \"messageDefaultValue\": \"The view is set to Orthographic. Changing the focal length will switch to Perspective.\" };\n\n HudMessage.displayMessage(viewer.container, messageSpecs);\n } else\n {\n HudMessage.dismiss();\n }\n }\n\n function showFov(yes) {\n if (yes) updateFOV();\n\n if (self.focallength)\n self.focallength.style.visibility = yes ? \"visible\" : \"hidden\";\n }\n\n function updateFOV() {\n var camFocalLength = viewer.getFocalLength();\n if (myFocalLength !== camFocalLength)\n {\n myFocalLength = camFocalLength;\n self.fovCell.textContent = camFocalLength.toString() + \" mm\";\n }\n }\n\n function watchFOV(e) {\n updateFOV();\n // If camera changed to ORTHO and we are still in FOV mode\n // put up the warning message that the system will switch to perspective.\n //\n if (viewer.toolController.getActiveToolName() === \"fov\") {\n var camera = viewer.navigation.getCamera();\n var isOrtho = camera && !camera.isPerspective;\n\n showFov(!isOrtho);\n showFovHudMessage(isOrtho);\n }\n }\n var camera = viewer.navigation.getCamera();\n var isOrtho = camera && !camera.isPerspective;\n\n showFov(state && !isOrtho);\n showFovHudMessage(state && isOrtho);\n\n if (state) {\n viewer.addEventListener(CAMERA_CHANGE_EVENT, watchFOV);\n } else\n {\n viewer.removeEventListener(CAMERA_CHANGE_EVENT, watchFOV);\n }\n};\n\nproto.unload = function () {\n this._destroyUI();\n\n return true;\n};\n\nproto._destroyUI = function () {\n // Removes the UI created in createUI\n var viewer = this.viewer;\n var toolbar = viewer.getToolbar();\n\n if (!toolbar) {\n return true;\n }\n\n var navTools = toolbar.getControl(TOOLBAR.NAVTOOLSID);\n\n if (!navTools) {\n return true;\n }\n\n function destroyComboButton(button) {\n if (button) {\n button.subMenu.removeEventListener(RadioButtonGroup.Event.ACTIVE_BUTTON_CHANGED, button.subMenuActiveButtonChangedHandler(navTools));\n navTools.removeControl(button.getId());\n button.onClick = null;\n }\n }\n\n function destroyButton(button) {\n if (button) {\n navTools.removeControl(button.getId());\n button.onClick = null;\n }\n }\n\n if (this.is3d) {\n destroyComboButton(navTools.orbittoolsbutton);\n navTools.orbittoolsbutton = null;\n\n destroyButton(navTools.orbitbutton);\n navTools.orbitbutton = null;\n\n destroyButton(navTools.freeorbitbutton);\n navTools.freeorbitbutton = null;\n\n destroyButton(navTools.fovbutton);\n navTools.fovbutton = null;\n }\n\n destroyButton(navTools.panbutton);\n navTools.panbutton = null;\n\n destroyButton(navTools.dollybutton);\n navTools.dollybutton = null;\n\n destroyComboButton(navTools.camerabutton);\n navTools.camerabutton = null;\n\n destroyButton(navTools.rollbutton);\n navTools.rollbutton = null;\n\n destroyButton(navTools.fittoviewbutton);\n navTools.fittoviewbutton = null;\n\n if (this.focallength) {\n viewer.container.removeChild(this.focallength);\n this.focallength = null;\n }\n\n // Remove Listeners\n viewer.removeEventListener(TOOL_CHANGE_EVENT, this.toolChangedHandler);\n this.toolChangedHandler = null;\n viewer.removeEventListener(NAVIGATION_MODE_CHANGED_EVENT, this.navChangedHandler);\n this.navChangedHandler = null;\n\n return true;\n};\n\n/**\n * Performs the corresponding button action.\n * @param {string} mode - one of the supported modes, see getModes().\n * \n * @memberof Autodesk.Viewing.Extensions.NavToolsExtension\n * @alias Autodesk.Viewing.Extensions.NavToolsExtension#activate\n */\nproto.activate = function (mode) {\n if (this.isActive(mode)) {\n return false;\n }\n if (mode === MODE_FIT_TO_VIEW) {\n this.viewer.impl.fitToView(this.viewer.impl.selector.getAggregateSelection());\n return true;\n }\n if (this.modes.indexOf(mode) != -1) {\n var defaultTool = this.viewer.getDefaultNavigationToolName();\n // NOTE: Dirty Hack\n // LMV-4998: Set the defaultTool to one of the NavTool if the default navigation tool is set by a different extension.\n if (this.modes.indexOf(defaultTool) === -1) {\n this.viewer.activateDefaultNavigationTools(this.viewer.model.is2d());\n }\n this.viewer.setActiveNavigationTool(mode);\n return true;\n }\n return false;\n};\n\n/**\n * Deactivates the current mode and activates the default viewer's navigation tool.\n * @returns {bool} true when deactivation is successful.\n * \n * @memberof Autodesk.Viewing.Extensions.NavToolsExtension\n * @alias Autodesk.Viewing.Extensions.NavToolsExtension#deactivate\n */\nproto.deactivate = function () {\n this.viewer.setActiveNavigationTool();\n return true;\n};\n\n/**\n * Checks whether a specific supported mode is currently active.\n * \n * @param {string} mode - one of the supported modes.\n * @returns {bool} true is the mode queried is currently active.\n * \n * @memberof Autodesk.Viewing.Extensions.NavToolsExtension\n * @alias Autodesk.Viewing.Extensions.NavToolsExtension#isActive\n */\nproto.isActive = function (mode) {\n var currMode = this.viewer.getActiveNavigationTool();\n return currMode === mode;\n};","\nimport { Extension } from \"../../src/application/Extension\";\nimport { ExplodeTool } from './ExplodeTool';\nimport { isIOSDevice, isIE11, isAndroidDevice } from \"../../src/compat\";\nimport { Button } from \"../../src/gui/controls/Button\";\nimport { stringToDOM } from \"../../src/globals\";\nimport { logger } from \"../../src/logger/Logger\";\nimport { EXPLODE_CHANGE_EVENT } from \"../../src/application/EventTypes\";\n\nvar avp = Autodesk.Viewing.Private;\n\n/**\n * \n * \n * Use its `activate()` method to enable the explode UI.\n * \n * The extension id is: `Autodesk.Explode`\n * \n * @example\n * viewer.loadExtension('Autodesk.Explode')\n * \n * @memberof Autodesk.Viewing.Extensions\n * @alias Autodesk.Viewing.Extensions.ExplodeExtension\n * @see {@link Autodesk.Viewing.Extension} for common inherited methods.\n * @constructor\n */\nexport function ExplodeExtension(viewer, options) {\n Extension.call(this, viewer, options);\n this.viewer = viewer;\n this.options = options;\n this.name = \"explode\";\n\n this.deactivate = this.deactivate.bind(this);\n this._onExplode = this._onExplode.bind(this);\n\n this.tool = null;\n\n // these below are all assinged in _createUI()\n this._slider = null;\n this._explodeButton = null;\n this._explodeSubmenu = null;\n this._tooltip = null;\n}\nExplodeExtension.prototype = Object.create(Extension.prototype);\nExplodeExtension.prototype.constructor = ExplodeExtension;\n\nvar proto = ExplodeExtension.prototype;\n\n/**\n * Adds an explode button to the toolbar. When pressed, a slider\n * will be shown which allows changing the model's explosion value.\n * \n * @memberof Autodesk.Viewing.Extensions.ExplodeExtension\n * @alias Autodesk.Viewing.Extensions.ExplodeExtension#load\n */\nproto.load = function () {\n this.tool = new ExplodeTool(this.viewer);\n this.viewer.toolController.registerTool(this.tool, this.setActive.bind(this));\n // No matter whether the UI initializes, the extension always loads.\n return true;\n};\n\n/**\n * Removes the explode button from the toolbar and deactivates the explode state.\n * \n * @memberof Autodesk.Viewing.Extensions.ExplodeExtension\n * @alias Autodesk.Viewing.Extensions.ExplodeExtension#unload\n */\nproto.unload = function () {\n\n this.deactivate();\n _destroyUI(this);\n\n this.viewer.toolController.deregisterTool(this.tool);\n this.tool = null;\n\n return true;\n};\n\n/**\n * Invoked by the viewer when the toolbar UI is available.\n *\n * @param {Autodesk.Viewing.UI.ToolBar} toolbar - toolbar instance.\n *\n * @alias Autodesk.Viewing.Extensions.ExplodeExtension#onToolbarCreated\n */\nproto.onToolbarCreated = function (toolbar) {\n _createUI(this, toolbar);\n};\n\n/**\n * Displays the explode UI.\n * \n * @memberof Autodesk.Viewing.Extensions.ExplodeExtension\n * @alias Autodesk.Viewing.Extensions.ExplodeExtension#activate\n */\nproto.activate = function () {\n if (this.isActive())\n return true;\n\n if (!this._explodeSubmenu)\n return false;\n\n this._explodeSubmenu.style.display = \"\";\n this._explodeButton.setState(Button.State.ACTIVE);\n this._tooltip.style.display = \"none\";\n\n // Sync slider with viewer's explode value\n var lmvExplodeValue = this.viewer.impl.getExplodeScale();\n this._slider.value = lmvExplodeValue;\n\n this.viewer.toolController.activateTool(\"explode\");\n\n // Update UI only when the event is fired\n this.viewer.addEventListener(EXPLODE_CHANGE_EVENT, this._onExplode);\n\n return true;\n};\n\n/**\n * Hides the explode UI and resets explode slider.\n * \n * @memberof Autodesk.Viewing.Extensions.ExplodeExtension\n * @alias Autodesk.Viewing.Extensions.ExplodeExtension#deactivate\n */\nproto.deactivate = function () {\n if (!this.isActive())\n return true;\n\n if (!this._explodeSubmenu)\n return true;\n\n this._explodeButton.setState(Button.State.INACTIVE);\n _hideSlider(this);\n\n this.viewer.toolController.deactivateTool(\"explode\"); // Resets the UI slider via event handler.\n\n // Update UI only when the event is fired\n this.viewer.removeEventListener(EXPLODE_CHANGE_EVENT, this._onExplode);\n\n return true;\n};\n\n/**\n * @returns {boolean} true is the explode UI is visible.\n *\n * @memberof Autodesk.Viewing.Extensions.ExplodeExtension\n * @alias Autodesk.Viewing.Extensions.ExplodeExtension#isActive\n */\nproto.isActive = function () {\n if (!this._explodeSubmenu)\n return false;\n return this._explodeSubmenu.style.display !== 'none';\n};\n\n/**\n * @returns {number} Between 0 and 1.\n *\n * @memberof Autodesk.Viewing.Extensions.ExplodeExtension\n * @alias Autodesk.Viewing.Extensions.ExplodeExtension#getScale\n */\nproto.getScale = function () {\n return this.viewer.getExplodeScale();\n};\n\n/**\n * Applies an explode operation.\n *\n * @param {number} value - Between 0 and 1.\n *\n * @memberof Autodesk.Viewing.Extensions.ExplodeExtension\n * @alias Autodesk.Viewing.Extensions.ExplodeExtension#setScale\n */\nproto.setScale = function (value) {\n return this.tool.setScale(value);\n};\n\n/**\n * Specifies the algorithm used for exploding models.\n * \n * @param {string} strategy - Either 'hierarchy' or 'radial'.\n *\n * @memberof Autodesk.Viewing.Extensions.ExplodeExtension\n * @alias Autodesk.Viewing.Extensions.ExplodeExtension#setStrategy\n */\nproto.setStrategy = function (strategy) {\n if (strategy !== this.getStrategy()) {\n this.viewer.prefs.set(avp.Prefs3D.EXPLODE_STRATEGY, strategy);\n }\n};\n\n/**\n * Returns an identifier for the algorithm used for exploding models.\n * \n * @returns {string} \n *\n * @memberof Autodesk.Viewing.Extensions.ExplodeExtension\n * @alias Autodesk.Viewing.Extensions.ExplodeExtension#getStrategy\n */\nproto.getStrategy = function () {\n return this.viewer.prefs.get(avp.Prefs3D.EXPLODE_STRATEGY);\n};\n\n/**\n * @private\n */\nproto._onExplode = function (event) {\n this._slider.value = event.scale;\n};\n\n/**\n * Enable / Disable the explode button & slider.\n * Doesn't affect the state of the explode scale itself.\n *\n * @param {boolean} enable - enable / disable the UI.\n * \n * @memberof Autodesk.Viewing.Extensions.ExplodeExtension\n * @alias Autodesk.Viewing.Extensions.ExplodeExtension#setUIEnabled\n */\nproto.setUIEnabled = function (enable) {\n if (this._explodeButton) {\n if (enable) {\n // Re-enable button\n this._explodeButton.setState(Autodesk.Viewing.UI.Button.State.INACTIVE);\n\n if (this._wasActive) {\n this.activate();\n }\n } else {\n this._wasActive = this.isActive();\n\n // We don't just use deactivate() because you want to keep the explode scale.\n _hideSlider(this);\n\n // Disable button\n this._explodeButton.setState(Autodesk.Viewing.UI.Button.State.DISABLED);\n }\n }\n};\n\n/**\n * Create toolbar button, explode slider and all other UI.\n *\n * @private\n */\nfunction _createUI(ext, toolbar) {\n\n var avu = Autodesk.Viewing.UI;\n var viewer = ext.viewer;\n\n var explodeButton = new Button('toolbar-explodeTool');\n explodeButton.setIcon(\"adsk-icon-explode\");\n explodeButton.setToolTip(\"Explode model\");\n viewer.modelTools.addControl(explodeButton);\n\n var htmlString = '
';\n var explodeSubmenu = stringToDOM(htmlString);\n\n var parentDom;\n var _document = ext.getDocument();\n if (isIOSDevice()) {\n // hack fix for iOS bug\n // range input not draggable when nested under button\n parentDom = _document.querySelector(\"#toolbar-explodeTool\").parentNode;\n explodeSubmenu.classList.add(\"ios\");\n } else\n if (isAndroidDevice()) {\n // hack fix for Android bug\n // range input not draggable when nested under button\n parentDom = _document.querySelector(\"#toolbar-explodeTool\").parentNode;\n explodeSubmenu.classList.add(\"android\");\n } else\n {\n parentDom = explodeButton.container;\n }\n parentDom.appendChild(explodeSubmenu);\n\n var slider = explodeSubmenu.querySelector(\".explode-slider\");\n slider.addEventListener(isIE11 ? \"change\" : \"input\", function (event) {\n ext.setScale(slider.value);\n });\n\n if (isIE11) {\n // In IE11, the input type=range has a weird default layout...\n slider.style['padding-top'] = '0';\n slider.style['padding-bottom'] = '0';\n slider.style['margin-top'] = '10px';\n }\n\n explodeSubmenu.onclick = function (event) {\n event.stopPropagation();\n };\n\n // hack to disable tooltip\n var tooltip = explodeButton.container.querySelector(\".adsk-control-tooltip\");\n\n explodeButton.onClick = function (event) {\n\n if (ext.isActive()) {\n ext.deactivate();\n } else {\n ext.activate();\n\n // Track tool change only when interacted by the end user.\n logger.track({ category: 'tool_changed', name: 'explode' });\n }\n };\n\n // Keep references\n ext._slider = slider;\n ext._explodeButton = explodeButton;\n ext._explodeSubmenu = explodeSubmenu;\n ext._tooltip = tooltip;\n\n // backwards compatibility references\n viewer.explodeSlider = slider;\n viewer.explodeSubmenu = explodeSubmenu;\n}\n\n/**\n * @param {Object} ext - The extension\n * @private\n */\nfunction _destroyUI(ext) {\n\n var viewer = ext.viewer;\n\n // early bail out if the UI hasn't actually been initialized.\n if (!ext._slider) {\n return;\n }\n\n if (ext._explodeButton) {\n ext._explodeButton.removeFromParent();\n }\n\n // Reset references\n ext._slider = null;\n ext._explodeButton = null;\n ext._explodeSubmenu = null;\n ext._tooltip = null;\n\n // Reset backwards compatibility references\n viewer.explodeSlider = null;\n viewer.explodeSubmenu = null;\n}\n\n/**\n * @param {Object} ext - The extension\n * @private\n */\nfunction _hideSlider(ext) {\n ext._slider.parentNode.style.display = \"none\";\n ext._tooltip.style.display = \"\";\n}","var av = Autodesk.Viewing;\nvar GlobalManagerMixin = av.GlobalManagerMixin;\n\nexport function ExplodeTool(viewer) {\n av.ToolInterface.call(this);\n\n this.names = ['explode'];\n this.viewer = viewer;\n this.setGlobalManager(this.viewer.globalManager);\n this.active = false;\n\n this.activate = function (name, viewer) {\n this.active = true;\n };\n\n this.deactivate = function () {\n this.setScale(0);\n this.active = false;\n };\n\n this.setScale = function (value) {\n return this.viewer.explode(value);\n };\n\n this.isActive = function () {\n return this.active;\n };\n}\n\nGlobalManagerMixin.call(ExplodeTool.prototype);","\nimport { Extension } from \"../../src/application/Extension\";\n\n\n/**\n * Use its `activate()` method to enter fullscreen mode.\n * It performs the same action as the toolbar's fullscreen button.\n * \n * The extension id is: `Autodesk.FullScreen`\n * \n * @example\n * viewer.loadExtension('Autodesk.FullScreen')\n * \n * @memberof Autodesk.Viewing.Extensions\n * @alias Autodesk.Viewing.Extensions.FullScreenExtension\n * @see {@link Autodesk.Viewing.Extension} for common inherited methods.\n * @constructor\n */\nexport function FullScreenExtension(viewer, options) {\n Extension.call(this, viewer, options);\n this.viewer = viewer;\n this.options = options;\n this.name = \"fullscreen\";\n}\nFullScreenExtension.prototype = Object.create(Extension.prototype);\nFullScreenExtension.prototype.constructor = FullScreenExtension;\n\nvar proto = FullScreenExtension.prototype;\n\n/**\n * Enters fullscreen mode.\n * \n * @memberof Autodesk.Viewing.Extensions.FullScreenExtension\n * @alias Autodesk.Viewing.Extensions.FullScreenExtension#activate\n */\nproto.activate = function () {\n if (!this.activeStatus) {\n this.viewer.nextScreenMode();\n this.activeStatus = true;\n }\n return true;\n};\n\n/**\n * Exits fullscreen mode.\n * \n * @memberof Autodesk.Viewing.Extensions.FullScreenExtension\n * @alias Autodesk.Viewing.Extensions.FullScreenExtension#deactivate\n */\nproto.deactivate = function () {\n if (this.activeStatus) {\n this.viewer.escapeScreenMode();\n this.activeStatus = false;\n }\n return true;\n};","// extracted by mini-css-extract-plugin","\nimport { Extension } from \"../../src/application/Extension\";\nimport { TOOLBAR } from \"../../src/gui/GuiViewerToolbarConst\";\nimport { Button } from \"../../src/gui/controls/Button\";\nimport { FusionOrbitTool } from \"./FusionOrbitTool\";\n\nimport \"./FusionOrbit.css\"; // IMPORTANT!!\n\n/**\n * Provides a customization to the orbit tool. \n * \n * The extension id is: `Autodesk.Viewing.FusionOrbit`\n * \n * @example\n * viewer.loadExtension('Autodesk.Viewing.FusionOrbit')\n * \n * @memberof Autodesk.Viewing.Extensions\n * @alias Autodesk.Viewing.Extensions.FusionOrbitExtension\n * @see {@link Autodesk.Viewing.Extension} for common inherited methods.\n * @constructor\n */\nexport function FusionOrbitExtension(viewer, options) {\n Extension.call(this, viewer, options);\n this.name = 'fusionorbit';\n this.modes = ['fusionorbit', 'fusionfreeorbit'];\n}\n\nFusionOrbitExtension.prototype = Object.create(Extension.prototype);\nFusionOrbitExtension.prototype.constructor = FusionOrbitExtension;\n\nvar proto = FusionOrbitExtension.prototype;\n\nproto.load = function () {\n var self = this;\n var viewer = this.viewer;\n\n this.tool = new FusionOrbitTool();\n this.tool.setViewer(viewer);\n viewer.toolController.registerTool(this.tool);\n\n return true;\n};\n\nproto.onToolbarCreated = function (toolbar)\n{\n var self = this;\n var viewer = this.viewer;\n var navTools = toolbar.getControl(TOOLBAR.NAVTOOLSID);\n\n if (!navTools || !navTools.orbitbutton) {\n return;\n }\n\n // save button behaviors, before modifying them\n this.classicBehavior = {};\n this.classicBehavior.orbitOnClick = navTools.orbitbutton.onClick;\n this.classicBehavior.freeorbitOnClick = navTools.freeorbitbutton.onClick;\n this.classicBehavior.returnToDefault = navTools.returnToDefault;\n\n navTools.freeorbitbutton.onClick = function (e) {\n var state = navTools.freeorbitbutton.getState();\n if (state === Button.State.INACTIVE) {\n self.activate('fusionfreeorbit');\n navTools.freeorbitbutton.setState(Button.State.ACTIVE);\n } else if (state === Button.State.ACTIVE) {\n self.deactivate();\n navTools.freeorbitbutton.setState(Button.State.INACTIVE);\n }\n };\n\n navTools.orbitbutton.onClick = function (e) {\n var state = navTools.orbitbutton.getState();\n if (state === Button.State.INACTIVE) {\n self.activate('fusionorbit');\n navTools.orbitbutton.setState(Button.State.ACTIVE);\n } else if (state === Button.State.ACTIVE) {\n self.deactivate();\n }\n };\n\n navTools.returnToDefault = function () {\n if (navTools.orbittoolsbutton) {// can be null when switching sheets\n // clear active button\n navTools.orbittoolsbutton.setState(Button.State.ACTIVE);\n }\n };\n\n // set combo button\n navTools.orbittoolsbutton.setState(Button.State.INACTIVE);\n if (viewer.prefs.fusionOrbitConstrained) {\n navTools.orbittoolsbutton.onClick = navTools.orbitbutton.onClick;\n navTools.orbittoolsbutton.setIcon(navTools.orbitbutton.iconClass);\n viewer.setDefaultNavigationTool(\"orbit\");\n } else {\n navTools.orbittoolsbutton.onClick = navTools.freeorbitbutton.onClick;\n navTools.orbittoolsbutton.setIcon(navTools.freeorbitbutton.iconClass);\n viewer.setDefaultNavigationTool(\"freeorbit\");\n }\n\n // reset\n viewer.setActiveNavigationTool();\n navTools.returnToDefault && navTools.returnToDefault();\n};\n\nproto.unload = function () {\n\n var viewer = this.viewer;\n\n // restore LMV Classic button behaviors\n if (this.classicBehavior) {\n var toolbar = viewer.getToolbar();\n var navTools = toolbar.getControl(TOOLBAR.NAVTOOLSID);\n\n if (navTools) {\n if (navTools.orbitbutton)\n navTools.orbitbutton.onClick = this.classicBehavior.orbitOnClick;\n\n if (navTools.freeorbitbutton)\n navTools.freeorbitbutton.onClick = this.classicBehavior.freeorbitOnClick;\n\n navTools.returnToDefault = this.classicBehavior.returnToDefault;\n\n if (navTools.orbittoolsbutton) {// can be null when switching sheets\n if (navTools.orbitbutton)\n navTools.orbittoolsbutton.onClick = navTools.orbitbutton.onClick;else\n\n navTools.orbittoolsbutton.onClick = null;\n navTools.orbittoolsbutton.setIcon(\"adsk-icon-orbit-constrained\");\n navTools.orbittoolsbutton.setState(Button.State.ACTIVE);\n }\n }\n this.classicBehavior = null;\n }\n\n viewer.setActiveNavigationTool(\"orbit\");\n viewer.setDefaultNavigationTool(\"orbit\");\n\n // Deregister tool\n viewer.toolController.deregisterTool(this.tool);\n this.tool.setViewer(null);\n this.tool = null;\n\n return true;\n};\n\n/**\n * Activates the extension's tool.\n * \n * @param {string} [mode] - Either 'fusionorbit' (default) or 'fusionfreeorbit'. \n * \n * @memberof Autodesk.Viewing.Extensions.FusionOrbitExtension\n * @alias Autodesk.Viewing.Extensions.FusionOrbitExtension#activate\n */\nproto.activate = function (mode) {\n if (this.activeStatus && this.mode === mode) {\n return;\n }\n switch (mode) {\n default:\n case 'fusionorbit':\n this.viewer.setActiveNavigationTool(\"fusion orbit constrained\");\n this.mode = 'fusionorbit';\n break;\n case 'fusionfreeorbit':\n this.viewer.setActiveNavigationTool(\"fusion orbit\");\n this.mode = 'fusionfreeorbit';\n break;}\n\n this.activeStatus = true;\n return true;\n};\n\n/**\n * Deactivates the extension's tool.\n * \n * @memberof Autodesk.Viewing.Extensions.FusionOrbitExtension\n * @alias Autodesk.Viewing.Extensions.FusionOrbitExtension#deactivate\n */\nproto.deactivate = function () {\n if (this.activeStatus) {\n this.viewer.setActiveNavigationTool();\n this.activeStatus = false;\n }\n return true;\n};","\nimport { stringToDOM } from \"../../src/globals\";\nimport { isTouchDevice } from \"../../src/compat\";\nimport { Navigation } from \"../../src/tools/Navigation\";\n\nvar av = Autodesk.Viewing;\n\nvar html = [\n'
',\n'
',\n'
',\n'
',\n'
',\n'
',\n'
',\n'
',\n'
',\n'
',\n'
',\n'
',\n'
',\n'
',\n'
',\n'
',\n'
',\n'
',\n'
',\n'
',\n'
',\n'
',\n'
',\n'
'].\njoin(\"\\n\");\n\nexport function FusionOrbitTool() {\n\n var _names = [\"fusion orbit\", \"fusion orbit constrained\"];\n\n var _PERCENT_SIZE = 0.8;\n var _EXIT_PERCENT_SIZE = 1.2;\n var _CIRCLE_CURSOR_STYLE = \"url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAAt1BMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8AAAAzMzP6+vri4uISEhKKioqtra2dnZ2EhIR9fX10dHRkZGQdHR3t7e3Hx8e5ubm1tbWoqKhWVlZKSko4ODgICAjv7+/o6OjMzMyxsbFOTk4pKSkXFxcEBAT29vbW1tZ6enpISEgLCwvhzeX+AAAAGXRSTlMANRO0nHRJHfnskIxQRKh89syDVwTWZjEJxPFEswAAAOFJREFUKM+1j+lygkAQhIflEAJe0Rw9u4CCeKKoSTTX+z9XoMJWWeX+ssrvZ3f19DQ5zOw/0DUMQPlmQ72bE2adBp8/Rp3CQUi3ILx+bxj4fjDs9T1Bmo6bbPPN8aDU4bjJt4nb+de789kSFyxn826jW3ICLNZZKU8nWWbrBTCRVm04U8TpjquRFf1Go0d7l8aYOrUR7FGEFr1S9LGymwthgX2gE/Kl0cHPOtF2xOWZ5QpIC93RflW4InkDoPRXesd5LJIMQPzV7tCMa7f6BvhJL79AVDmYTNQ1NhnxbI/uwB8H5Bjd4zQPBAAAAABJRU5ErkJggg==), auto\";\n\n var _orbitModes = {\n HORIZONTAL: 0,\n VERTICAL: 1,\n ROLL: 2 };\n\n\n var _orbitSpeeds = {\n HORIZONTAL: 0.005,\n VERTICAL: 0.005,\n ROLL: 1.0 };\n\n\n var _gizmoElem,_gizmoRect = {},_ringElem,_outsideElem;\n var _isConstrained;\n var _camera;\n var _isTouch = isTouchDevice();\n var _isClickToExit = false;\n\n var _mouse = {\n buttons: [],\n src: undefined,\n x: 0,\n y: 0,\n dx: 0,\n dy: 0,\n firstMove: true, // for dx/dy calc\n mode: undefined };\n\n\n var _this = this;\n\n this.setViewer = function (viewer) {\n this.viewer = viewer;\n this.navapi = viewer ? viewer.navigation : null;\n viewer && this.setGlobalManager(viewer.globalManager);\n };\n\n // PRIVATE FUNCTIONS\n\n var _onMouseDown = function _onMouseDown(e) {\n _mouse.buttons[e.touches ? 0 : e.button] = true;\n _mouse.src = e.target.className;\n _mouse.x = 0;\n _mouse.y = 0;\n _mouse.dx = 0;\n _mouse.dy = 0;\n _mouse.firstMove = true;\n _mouse.mode = undefined;\n\n if (_mouse.src === \"ring\") {\n _mouse.mode = _orbitModes.ROLL;\n } else\n if (_mouse.src === \"edgemark-area\") {\n if (e.target.parentNode.className === \"layout-ver\")\n _mouse.mode = _orbitModes.HORIZONTAL;else\n if (e.target.parentNode.className === \"layout-hor\")\n _mouse.mode = _orbitModes.VERTICAL;\n }\n\n _centerPivot();\n\n e.stopPropagation();\n };\n\n var _onMouseUp = function _onMouseUp(e) {\n _mouse.buttons[e.touches ? 0 : e.button] = false;\n _mouse.src = undefined;\n };\n\n var _onMouseMove = function _onMouseMove(e) {\n if (!_mouse.buttons[0]) return;\n\n _updateMousePos(e);\n _updateCamera();\n\n _mouse.firstMove = false;\n };\n\n var _updateMousePos = function _updateMousePos(e) {\n var pageX = e.touches ? e.touches[0].pageX : e.pageX;\n var pageY = e.touches ? e.touches[0].pageY : e.pageY;\n\n if (!_mouse.firstMove) {\n _mouse.dx = pageX - _mouse.x;\n _mouse.dy = pageY - _mouse.y;\n }\n _mouse.x = pageX;\n _mouse.y = pageY;\n };\n\n var _updateCamera = function _updateCamera() {\n\n // if (_mouse.dx === 0 && _mouse.dy === 0) return;\n switch (_mouse.mode) {\n case _orbitModes.ROLL:\n if (!_this.navapi.isActionEnabled('roll')) {\n return;\n }\n break;\n case _orbitModes.HORIZONTAL:\n case _orbitModes.VERTICAL:\n if (!_this.navapi.isActionEnabled('orbit')) {\n return;\n }\n break;}\n\n\n var eyeVec = _camera.target.clone().sub(_camera.position).normalize();\n var rightVec = eyeVec.clone().cross(_camera.up).normalize();\n var upVec = rightVec.clone().cross(eyeVec).normalize();\n _camera.up.copy(upVec); // update camera.up\n\n if (_mouse.mode === _orbitModes.ROLL) {\n var start = new THREE.Vector3(_mouse.x - _gizmoRect.center.x, _mouse.y - _gizmoRect.center.y, 0);\n var end = new THREE.Vector3(_mouse.dx, _mouse.dy, 0).add(start);\n start.normalize();\n end.normalize();\n var cross = start.clone().cross(end);\n var angle = Math.asin(cross.z);\n _camera.up.applyAxisAngle(eyeVec, -angle * _orbitSpeeds.ROLL);\n } else\n {\n var rotAxis, rotAmount;\n\n if (_mouse.mode === _orbitModes.HORIZONTAL) {\n rotAmount = -_mouse.dx * _orbitSpeeds.HORIZONTAL;\n if (_isConstrained)\n _camera.up = Navigation.snapToAxis(_camera.up.clone()); // snap up vec\n rotAxis = _camera.up;\n } else\n if (_mouse.mode === _orbitModes.VERTICAL) {\n rotAmount = -_mouse.dy * _orbitSpeeds.VERTICAL;\n if (_isConstrained) {\n if (_mouse.firstMove) // first time move, snap\n _camera.up = Navigation.snapToAxis(_camera.up.clone());\n rotAxis = eyeVec.clone().cross(_camera.up).normalize(); // new right vec\n } else\n {\n rotAxis = rightVec;\n }\n _camera.up.applyAxisAngle(rotAxis, rotAmount);\n }\n\n var pivot = _this.navapi.getPivotPoint();\n var newPivotToCam = _camera.position.clone().sub(pivot);\n newPivotToCam.applyAxisAngle(rotAxis, rotAmount);\n _camera.position.addVectors(pivot, newPivotToCam); // orbit position\n\n var newPivotToTarget = _camera.target.clone().sub(pivot);\n newPivotToTarget.applyAxisAngle(rotAxis, rotAmount);\n _camera.target.addVectors(pivot, newPivotToTarget); // orbit target\n }\n\n _camera.dirty = true;\n\n };\n\n // may return camera.target, do not modify\n var _findTarget = function _findTarget() {\n var eyeVec = _camera.target.clone().sub(_camera.position).normalize();\n var hit = _this.viewer.impl.rayIntersect(new THREE.Ray(_camera.position, eyeVec));\n return hit && hit.intersectPoint ?\n hit.intersectPoint :\n _camera.target;\n };\n\n var _getCameraPlane = function _getCameraPlane(pos, nor) {\n var planeNor = nor || pos.clone().sub(_camera.position).normalize();\n return new THREE.Plane(\n planeNor, -planeNor.x * pos.x - planeNor.y * pos.y - planeNor.z * pos.z);\n\n };\n\n var _centerPivot = function _centerPivot() {\n // find distance pivot to camera plane\n // set new pivot to be that distance along eye vector\n var eyeVec = _camera.target.clone().sub(_camera.position).normalize();\n var plane = _getCameraPlane(_camera.position, eyeVec);\n var dist = plane.distanceToPoint(_camera.pivot);\n _camera.pivot.copy(eyeVec).multiplyScalar(dist).add(_camera.position);\n };\n\n var _onMouseDownCircle = function _onMouseDownCircle(e) {\n if (!e.touches && e.button === 0)\n _centerPivot(); // center pivot before passing thru to orbit tool\n };\n\n var _clickToExit = function _clickToExit(e) {\n if (_isClickToExit)\n _this.viewer.setActiveNavigationTool();\n };\n\n var _clickToFocus = function _clickToFocus(x, y) {\n var hit = _this.viewer.impl.hitTest(x, y);\n var newTarget;\n\n if (hit && hit.intersectPoint) {\n newTarget = hit.intersectPoint;\n } else\n {\n // intersect camera plane\n var ray = _this.viewer.impl.viewportToRay(_this.viewer.impl.clientToViewport(x, y));\n newTarget = ray.intersectPlane(_getCameraPlane(_camera.target));\n }\n\n var newCamPos = _camera.position.clone().sub(_findTarget()).add(newTarget);\n _this.navapi.setRequestTransition(true, newCamPos, newTarget, _camera.fov);\n };\n\n\n // TOOL INTERFACE\n\n this.register = function () {\n _gizmoElem = stringToDOM(html);\n _gizmoElem.style.display = \"none\";\n this.viewer.canvasWrap.insertBefore(_gizmoElem, this.viewer.canvasWrap.firstChild);\n\n _ringElem = _gizmoElem.querySelector(\".ring\");\n _ringElem.addEventListener(\"mousedown\", _onMouseDown);\n\n Array.prototype.forEach.call(_gizmoElem.querySelectorAll(\".edgemark-area\"), function (elem, i) {\n elem.addEventListener(\"mousedown\", _onMouseDown);\n if (_isTouch) elem.addEventListener(\"touchstart\", _onMouseDown);\n });\n\n this.addWindowEventListener(\"mouseup\", _onMouseUp);\n this.addWindowEventListener(\"mousemove\", _onMouseMove);\n\n // click to exit\n _outsideElem = _gizmoElem.querySelector(\".outside\");\n _outsideElem.addEventListener(\"mousedown\", _clickToExit);\n\n // before passing thru to orbit (default) tool\n var circleElem = _gizmoElem.querySelector(\".circle\");\n circleElem.addEventListener(\"mousedown\", _onMouseDownCircle);\n\n if (_isTouch) {\n _ringElem.addEventListener(\"touchstart\", _onMouseDown);\n this.addWindowEventListener(\"touchend\", _onMouseUp);\n this.addWindowEventListener(\"touchmove\", _onMouseMove);\n _outsideElem.addEventListener(\"touchstart\", _clickToExit);\n circleElem.addEventListener(\"touchstart\", _onMouseDownCircle);\n }\n\n _camera = this.viewer.impl.camera;\n };\n\n this.deregister = function () {\n this.removeWindowEventListener(\"mouseup\", _onMouseUp);\n this.removeWindowEventListener(\"mousemove\", _onMouseMove);\n _outsideElem.removeEventListener(\"mousedown\", _clickToExit);\n\n if (_isTouch) {\n this.removeWindowEventListener(\"touchend\", _onMouseUp);\n this.removeWindowEventListener(\"touchmove\", _onMouseMove);\n _outsideElem.removeEventListener(\"touchstart\", _clickToExit);\n }\n\n this.viewer.canvasWrap.removeChild(_gizmoElem);\n\n _gizmoElem = undefined;\n _ringElem = undefined;\n _outsideElem = undefined;\n };\n\n this.activate = function (name) {\n _gizmoElem.style.display = \"\";\n\n this.handleResize();\n\n _isConstrained = name === \"fusion orbit constrained\";\n\n var hyperlink = this.viewer.toolController.isToolActivated(\"hyperlink\");\n\n // Need to make Hyperlink sit on top of default navigation tool\n if (hyperlink)\n this.viewer.toolController.deactivateTool(\"hyperlink\");\n\n if (_isConstrained) {\n this.viewer.setDefaultNavigationTool(\"orbit\");\n this.viewer.prefs.set(\"fusionOrbitConstrained\", true);\n } else\n {\n this.viewer.setDefaultNavigationTool(\"freeorbit\");\n this.viewer.prefs.set(\"fusionOrbitConstrained\", false);\n }\n\n if (hyperlink)\n this.viewer.toolController.activateTool(\"hyperlink\");\n\n this.viewer.navigation.setZoomTowardsPivot(true);\n };\n\n this.deactivate = function (name) {\n _gizmoElem.style.display = \"none\";\n this.viewer.navigation.setZoomTowardsPivot(this.viewer.prefs.zoomTowardsPivot);\n };\n\n this.getNames = function () {\n return _names;\n };\n\n this.getName = function () {\n return _names[0];\n };\n\n this.update = function () {\n return false;\n };\n\n this.handleSingleClick = function (event, button) {\n _clickToFocus(event.canvasX, event.canvasY);\n return true;\n };\n\n this.handleDoubleClick = function (event, button) {\n return true; // disabled, does not play nice with SingleClick\n };\n\n this.handleSingleTap = function (event) {\n _clickToFocus(event.canvasX, event.canvasY);\n return true;\n };\n\n this.handleDoubleTap = function (event) {\n return false; // enabled, DoubleTap doesn't register the first SingleTap\n };\n\n this.handleKeyDown = function (event, keyCode) {\n return false;\n };\n\n this.handleKeyUp = function (event, keyCode) {\n return false;\n };\n\n this.handleWheelInput = function (delta) {\n return false;\n };\n\n this.handleButtonDown = function (event, button) {\n return false;\n };\n\n this.handleButtonUp = function (event, button) {\n return false;\n };\n\n this.handleMouseMove = function (event) {\n var rect = this.viewer.impl.getCanvasBoundingClientRect();\n var vp;\n if (rect.width > rect.height) {\n vp = new THREE.Vector2(\n ((event.canvasX + 0.5) / rect.width * 2 - 1) * rect.width / rect.height,\n -((event.canvasY + 0.5) / rect.height) * 2 + 1);\n\n } else {\n vp = new THREE.Vector2(\n (event.canvasX + 0.5) / rect.width * 2 - 1,\n (-((event.canvasY + 0.5) / rect.height) * 2 + 1) * rect.height / rect.width);\n\n }\n\n var radius = vp.length();\n\n var isOutside = radius > _EXIT_PERCENT_SIZE;\n if (_isClickToExit !== isOutside) {\n if (isOutside)\n _outsideElem.style.cursor = \"\";else\n\n _outsideElem.style.cursor = _CIRCLE_CURSOR_STYLE;\n _isClickToExit = isOutside;\n // console.log(\"click exit: \" + _isClickToExit);\n }\n\n return false;\n };\n\n this.handleGesture = function (event) {\n _centerPivot();\n return false;\n };\n\n this.handleBlur = function (event) {\n return false;\n };\n\n this.handleResize = function () {\n // for mouse roll\n var rect = _gizmoElem.getBoundingClientRect();\n var _window = this.getWindow();\n _gizmoRect.left = rect.left + _window.pageXOffset;\n _gizmoRect.top = rect.top + _window.pageYOffset;\n _gizmoRect.width = rect.width;\n _gizmoRect.height = rect.height;\n _gizmoRect.center = {};\n _gizmoRect.center.x = _gizmoRect.left + _gizmoRect.width / 2;\n _gizmoRect.center.y = _gizmoRect.top + _gizmoRect.height / 2;\n\n // resize gizmo\n var dim = (_window.innerWidth > _window.innerHeight ? _window.innerHeight : _window.innerWidth) * _PERCENT_SIZE;\n _gizmoElem.style.width = _gizmoElem.style.height = \"\" + dim + \"px\";\n _gizmoElem.style.top = _gizmoElem.style.left = \"calc(50% - \" + dim / 2 + \"px)\";\n _ringElem.style.borderWidth = \"\" + dim * 0.1 + \"px\";\n };\n}\n\nav.GlobalManagerMixin.call(FusionOrbitTool.prototype);","\nimport { Extension } from \"../../src/application/Extension\";\n\n\n/**\n * Use its `activate()` method to animate the camera back to its\n * default, home view. The extension doesn't provide any UI.\n * \n * The extension id is: `Autodesk.GoHome`\n * \n * @example\n * viewer.loadExtension('Autodesk.GoHome')\n * \n * @memberof Autodesk.Viewing.Extensions\n * @alias Autodesk.Viewing.Extensions.GoHomeExtension\n * @see {@link Autodesk.Viewing.Extension} for common inherited methods.\n * @constructor\n */\nexport function GoHomeExtension(viewer, options) {\n Extension.call(this, viewer, options);\n this.viewer = viewer;\n this.options = options;\n this.name = \"gohome\";\n}\nGoHomeExtension.prototype = Object.create(Extension.prototype);\nGoHomeExtension.prototype.constructor = GoHomeExtension;\n\nvar proto = GoHomeExtension.prototype;\n\n/**\n * Animates the camera back to its home location.\n * \n * @memberof Autodesk.Viewing.Extensions.GoHomeExtension\n * @alias Autodesk.Viewing.Extensions.GoHomeExtension#activate\n */\nproto.activate = function () {\n this.viewer.navigation.setRequestHomeView(true);\n return true;\n};\n\n/**\n * It doesn't do anything.\n * \n * @memberof Autodesk.Viewing.Extensions.GoHomeExtension\n * @alias Autodesk.Viewing.Extensions.GoHomeExtension#activate\n */\nproto.deactivate = function () {\n return false;\n};","\nimport { Extension } from \"../../src/application/Extension\";\nimport { ViewerModelStructurePanel } from \"../../src/gui/ViewerModelStructurePanel\";\nimport { isMobileDevice } from \"../../src/compat\";\nimport { Button } from \"../../src/gui/controls/Button\";\nimport * as et from \"../../src/application/EventTypes\";\n\nvar avp = Autodesk.Viewing.Private;\n\n\n/**\n * Adds a toolbar button for accessing the Model Browser panel.\n *\n * Use its `activate()` method to open the Model Browser panel.\n * The Model Browser is only available to 3D models.\n * \n * The extension id is: `Autodesk.ModelStructure`\n *\n * {@link Autodesk.Viewing.GuiViewer3D} loads this extension by default.\n * \n * @example\n * viewer.loadExtension('Autodesk.ModelStructure')\n * \n * @memberof Autodesk.Viewing.Extensions\n * @alias Autodesk.Viewing.Extensions.ModelStructureExtension\n * @see {@link Autodesk.Viewing.Extension} for common inherited methods.\n * @constructor\n */\nexport function ModelStructureExtension(viewer, options) {\n Extension.call(this, viewer, options);\n this.viewer = viewer;\n this.options = options;\n this.name = \"modelstructure\";\n this._modelstructure = null;\n\n this._onLoadModel = this._onLoadModel.bind(this);\n this._onUnloadModel = this._onUnloadModel.bind(this);\n}\nModelStructureExtension.prototype = Object.create(Extension.prototype);\nModelStructureExtension.prototype.constructor = ModelStructureExtension;\n\nvar proto = ModelStructureExtension.prototype;\n\n/**\n * Invoked automatically when the extension is loaded.\n * \n * @memberof Autodesk.Viewing.Extensions.ModelStructureExtension\n * @alias Autodesk.Viewing.Extensions.ModelStructureExtension#load\n */\nproto.load = function () {\n this.viewer.addEventListener(et.MODEL_ADDED_EVENT, this._onLoadModel);\n this.viewer.addEventListener(et.MODEL_ROOT_LOADED_EVENT, this._onLoadModel);\n this.viewer.addEventListener(et.MODEL_UNLOADED_EVENT, this._onUnloadModel);\n this.viewer.addEventListener(et.MODEL_REMOVED_EVENT, this._onUnloadModel);\n return true;\n};\n\n/**\n * Invoked automatically when the extension is unloaded.\n * \n * @memberof Autodesk.Viewing.Extensions.ModelStructureExtension\n * @alias Autodesk.Viewing.Extensions.ModelStructureExtension#unload\n */\nproto.unload = function () {\n this.deactivate();\n this.setModelStructurePanel(null);\n if (this._structureButton) {\n this.viewer.settingsTools.removeControl(this._structureButton);\n this.viewer.settingsTools.structurebutton = null;\n this._structureButton = null;\n }\n this.viewer.removeEventListener(et.MODEL_ADDED_EVENT, this._onLoadModel);\n this.viewer.removeEventListener(et.MODEL_ROOT_LOADED_EVENT, this._onLoadModel);\n this.viewer.removeEventListener(et.MODEL_UNLOADED_EVENT, this._onUnloadModel);\n this.viewer.removeEventListener(et.MODEL_REMOVED_EVENT, this._onUnloadModel);\n return true;\n};\n\n\n/**\n * Invoked after the Toolbar UI gets created. Adds toolbar button.\n *\n * @param {Autodesk.Viewing.UI.ToolBar} toolbar - toolbar instance.\n *\n * @alias Autodesk.Viewing.Extensions.ModelStructureExtension#onToolbarCreated\n */\nproto.onToolbarCreated = function (toolbar) {var _this = this;\n\n // Toolbar button\n var structureButton = new Button('toolbar-modelStructureTool');\n structureButton.setToolTip('Model browser');\n structureButton.setIcon(\"adsk-icon-structure\");\n structureButton.onClick = function (e) {\n var newVisible = !_this._modelstructure.isVisible();\n if (newVisible) {\n _this.activate();\n } else {\n _this.deactivate();\n }\n };\n\n var settingTools = this.viewer.settingsTools;\n settingTools.addControl(structureButton, { index: 0 });\n settingTools.structurebutton = structureButton; // legacy... remove in v8.0\n this._structureButton = structureButton;\n\n // Panel instance \n this.restoreDefaultPanel();\n};\n\n\n/**\n * Opens the Model Browser UI.\n * \n * @memberof Autodesk.Viewing.Extensions.ModelStructureExtension\n * @alias Autodesk.Viewing.Extensions.ModelStructureExtension#activate\n */\nproto.activate = function () {\n if (this._modelstructure) {\n this._modelstructure.setVisible(true);\n avp.analytics.track('viewer.model_browser', {\n action: 'View List' });\n\n return true;\n }\n return false;\n};\n\n/**\n * Closes the Model Browser UI.\n * \n * @memberof Autodesk.Viewing.Extensions.ModelStructureExtension\n * @alias Autodesk.Viewing.Extensions.ModelStructureExtension#deactivate\n */\nproto.deactivate = function () {\n if (this._modelstructure) {\n this._modelstructure.setVisible(false);\n }\n return true; // always\n};\n\n/**\n * @returns {boolean} true when the panel is visible.\n *\n * @alias Autodesk.Viewing.Extensions.ModelStructureExtension#isActive\n */\nproto.isActive = function () {\n if (this._modelstructure) {\n return this._modelstructure.isVisible();\n }\n return false;\n};\n\n/**\n * Sets the panel instance to open when clicking the toolbar button.\n * Use the API to override the default panel with a custom one.\n *\n * @param {Autodesk.Viewing.UI.ModelStructurePanel} modelStructurePanel - The model structure panel to use, or null.\n * @returns {boolean} True if the panel, or null, was set successfully; false otherwise.\n *\n * @alias Autodesk.Viewing.Extensions.ModelStructureExtension#setModelStructurePanel\n */\nproto.setModelStructurePanel = function (modelStructurePanel) {var _this2 = this;\n\n if (modelStructurePanel === this._modelstructure)\n return false;\n\n if (this._modelstructure) {\n this._modelstructure.setVisible(false); // This ensures the button is in the correct state.\n this.viewer.removePanel(this._modelstructure);\n this._modelstructure.uninitialize();\n }\n\n this._modelstructure = modelStructurePanel;\n this.viewer.modelstructure = modelStructurePanel; // legacy compatibility; removed after v8.0.0\n if (!modelStructurePanel) {\n return true;\n }\n\n this.viewer.addPanel(this._modelstructure);\n\n // Notify of all models already loaded\n var models = this.viewer.impl.modelQueue().getModels();\n for (var i = 0; i < models.length; ++i) {\n this._modelstructure.addModel(models[i]);\n }\n\n this._modelstructure.addVisibilityListener(function (visible) {\n if (visible) {\n _this2.viewer.onPanelVisible(_this2._modelstructure);\n }\n _this2._structureButton.setState(visible ? Button.State.ACTIVE : Button.State.INACTIVE);\n });\n\n return true;\n};\n\n/**\n * Removes custom panel and restores the default one.\n *\n * @alias Autodesk.Viewing.Extensions.ModelStructureExtension#restoreDefaultPanel \n */\nproto.restoreDefaultPanel = function () {\n\n var config = this.viewer.config;\n var options = {\n docStructureConfig: config.docStructureConfig,\n hideSearch: isMobileDevice(),\n excludeRoot: config.modelBrowserExcludeRoot,\n startCollapsed: config.modelBrowserStartCollapsed };\n\n var modelTitle = config.defaultModelStructureTitle || 'Browser';\n var panelInstance = new ViewerModelStructurePanel(this.viewer, modelTitle, options);\n this.setModelStructurePanel(panelInstance);\n};\n\n/**\n * @private\n */\nproto._onLoadModel = function (event) {\n if (this._modelstructure) {\n this._modelstructure.addModel(event.model);\n }\n};\n\n/**\n * @private\n */\nproto._onUnloadModel = function (event) {\n if (this._modelstructure) {\n this._modelstructure.unloadModel(event.model);\n }\n};","\nimport { Extension } from \"../../src/application/Extension\";\nimport { PropertyPanel } from \"../../src/gui/PropertyPanel\";\nimport { ViewerPropertyPanel } from \"../../src/gui/ViewerPropertyPanel\";\nimport { Button } from \"../../src/gui/controls/Button\";\nimport * as et from \"../../src/application/EventTypes\";\nimport { Prefs } from '../../src/application/PreferenceNames';\n\n/**\n * Use its `activate()` method to open the Properties UI.\n * \n * The extension id is: `Autodesk.PropertiesManager`\n * \n * @example\n * viewer.loadExtension('Autodesk.PropertiesManager')\n * \n * @memberof Autodesk.Viewing.Extensions\n * @alias Autodesk.Viewing.Extensions.PropertiesManagerExtension\n * @see {@link Autodesk.Viewing.Extension} for common inherited methods.\n * @constructor\n */\nexport function PropertiesManagerExtension(viewer, options) {\n Extension.call(this, viewer, options);\n this.name = \"propertiesmanager\";\n this._panel = null;\n this._onIsolateEvent = this._onIsolateEvent.bind(this);\n this._onSelectionChangeEvent = this._onSelectionChangeEvent.bind(this);\n this._onPrefChange = this._onPrefChange.bind(this);\n}\n\nPropertiesManagerExtension.prototype = Object.create(Extension.prototype);\nPropertiesManagerExtension.prototype.constructor = PropertiesManagerExtension;\nvar proto = PropertiesManagerExtension.prototype;\n\n\n/**\n * Invoked when the extension gets loaded.\n * @returns {boolean} true when the extension loaded successfully.\n * @alias Autodesk.Viewing.Extensions.PropertiesManagerExtension#load\n */\nproto.load = function () {\n this.viewer.addEventListener(et.ISOLATE_EVENT, this._onIsolateEvent);\n this.viewer.addEventListener(et.AGGREGATE_SELECTION_CHANGED_EVENT, this._onSelectionChangeEvent);\n\n this.viewer.prefs.addListeners(Prefs.OPEN_PROPERTIES_ON_SELECT, this._onPrefChange);\n\n return true;\n};\n\n/**\n * Invoked when the extension gets unloaded.\n *\n * @alias Autodesk.Viewing.Extensions.PropertiesManagerExtension#unload\n */\nproto.unload = function () {\n this.viewer.removeEventListener(et.ISOLATE_EVENT, this._onIsolateEvent);\n this.viewer.removeEventListener(et.AGGREGATE_SELECTION_CHANGED_EVENT, this._onSelectionChangeEvent);\n\n this.viewer.prefs.removeListeners(Prefs.OPEN_PROPERTIES_ON_SELECT, this._onPrefChange);\n\n this.deactivate();\n this.setPanel(null);\n\n if (this._toolbarButton) {\n this.viewer.settingsTools.removeControl(this._toolbarButton);\n this.viewer.settingsTools.propertiesbutton = null; // for backwards compatibility, remove in v8.0.0\n this._toolbarButton = null;\n }\n};\n\n/**\n * Invoked by the Viewer as soon as the toolbar is available.\n */\nproto.onToolbarCreated = function (toolbar) {\n this.setDefaultPanel();\n this._addToolbarButton();\n};\n\n/**\n * Opens the Properties UI.\n * \n * @alias Autodesk.Viewing.Extensions.PropertiesManagerExtension#activate\n */\nproto.activate = function () {\n if (this._panel) {\n this._panel.setVisible(true);\n return true;\n }\n return false;\n};\n\n/**\n * Closes the Properties UI.\n * \n * @alias Autodesk.Viewing.Extensions.PropertiesManagerExtension#deactivate\n */\nproto.deactivate = function () {\n if (this._panel) {\n this._panel.setVisible(false);\n }\n return true;\n};\n\n/**\n * @returns {boolean} true is the properties panel is open.\n * \n * @alias Autodesk.Viewing.Extensions.PropertiesManagerExtension#isActive\n */\nproto.isActive = function () {\n if (this._panel) {\n return this._panel.isVisible();\n }\n return false;\n};\n\n\n/**\n * Overrides the property panel instance.\n *\n * @returns {boolean} True if the panel or null was set successfully, and false otherwise.\n *\n * @alias Autodesk.Viewing.Extensions.PropertiesManagerExtension#setPanel\n */\nproto.setPanel = function (propertyPanel) {var _this = this;\n if (propertyPanel instanceof PropertyPanel || !propertyPanel) {\n if (this._panel) {\n this._panel.setVisible(false);\n this.viewer.removePanel(this._panel);\n this._panel.uninitialize();\n }\n\n this._panel = propertyPanel;\n\n if (propertyPanel) {\n this.viewer.addPanel(propertyPanel);\n propertyPanel.addVisibilityListener(function (visible) {\n if (visible) {\n _this.viewer.onPanelVisible(_this._panel);\n }\n _this._toolbarButton.setState(visible ? Button.State.ACTIVE : Button.State.INACTIVE);\n });\n\n }\n return true;\n }\n return false;\n};\n\n/**\n * Resets the panel to its default instance.\n *\n * @alias Autodesk.Viewing.Extensions.PropertiesManagerExtension#setDefaultPanel\n */\nproto.setDefaultPanel = function () {\n this.setPanel(new ViewerPropertyPanel(this.viewer));\n};\n\n/**\n * Sets the property panel instance.\n *\n * @returns {Object} The panel instance.\n *\n * @alias Autodesk.Viewing.Extensions.PropertiesManagerExtension#getPanel\n */\nproto.getPanel = function () {\n return this._panel;\n};\n\n/**\n * @returns {Autodesk.Viewing.UI.Button|null} the instance of the button.\n */\nproto.getToolbarButton = function () {\n return this._toolbarButton;\n};\n\n\n\n/**\n * Adds a button to the toolbar.\n * Invoked automatically as soon as the toolbar is available.\n *\n * @private\n */\nproto._addToolbarButton = function () {var _this2 = this;\n\n if (this._toolbarButton)\n return;\n\n var propertiesButton = this._toolbarButton = new Button('toolbar-propertiesTool');\n propertiesButton.setToolTip('Properties');\n propertiesButton.setIcon(\"adsk-icon-properties\");\n propertiesButton.onClick = function (event) {\n _this2._panel.setVisible(!_this2._panel.isVisible());\n };\n propertiesButton.setVisible(!this.viewer.prefs.openPropertiesOnSelect);\n this.viewer.settingsTools.addControl(propertiesButton, { index: 1 });\n this.viewer.settingsTools.propertiesbutton = propertiesButton; // for backwards compatibility, remove in v8.0.0\n};\n\n/**\n * @private\n */\nproto._onIsolateEvent = function (event) {\n if (!this._panel)\n return;\n if (this.viewer.prefs.openPropertiesOnSelect || event.nodeIdArray[0] === event.model.getRootId()) {\n this._panel.setVisible(event.nodeIdArray.length > 0 || this.viewer.impl.selector.hasSelection());\n }\n};\n\n/**\n * Opens the panel when a selection is made AND the corresponding preference is true.\n *\n * @private\n */\nproto._onSelectionChangeEvent = function (event) {\n\n if (!this.viewer.prefs.openPropertiesOnSelect)\n return;\n\n var hasSelection = false;\n for (var i = 0; i < event.selections.length; ++i) {\n if (event.selections[i].dbIdArray.length > 0) {\n hasSelection = true;\n break;\n }\n }\n\n if (hasSelection) {\n this.activate();\n } else {\n this.deactivate();\n }\n};\n\n/**\n * Invoked when the preference for whether the Panel gets automatically\n * opened on selection is true or not.\n *\n * @param {boolean} displayOnSelection - true to automatically open the panel when a part is selcted.\n *\n * @private\n */\nproto._onPrefChange = function (displayOnSelection) {\n\n // When Properties are displayed on selection, \n // hide the toolbar button (because UX).\n if (this._toolbarButton) {\n this._toolbarButton.setVisible(!displayOnSelection);\n }\n};","\nimport { Extension } from \"../../src/application/Extension\";\nimport { ViewerSettingTab } from \"../../src/gui/ViewerSettingsPanel\";\n\n\n/**\n * Use its `activate()` method to open the Settings UI.\n * \n * The extension id is: `Autodesk.ViewerSettings`\n * \n * @example\n * viewer.loadExtension('Autodesk.ViewerSettings')\n * \n * @memberof Autodesk.Viewing.Extensions\n * @alias Autodesk.Viewing.Extensions.ViewerSettingsExtension\n * @see {@link Autodesk.Viewing.Extension} for common inherited methods.\n * @constructor\n */\nexport function ViewerSettingsExtension(\n\n\nviewer, options) {\n Extension.call(this, viewer, options);\n this.viewer = viewer;\n this.options = options;\n this.name = \"viewersettings\";\n}\nViewerSettingsExtension.prototype = Object.create(Extension.prototype);\nViewerSettingsExtension.prototype.constructor = ViewerSettingsExtension;\n\nvar proto = ViewerSettingsExtension.prototype;\n\n/**\n * Opens the Settings UI.\n * \n * @memberof Autodesk.Viewing.Extensions.ViewerSettingsExtension\n * @alias Autodesk.Viewing.Extensions.ViewerSettingsExtension#activate\n */\nproto.activate = function () {\n if (!this.activeStatus) {\n this.viewer.showViewer3dOptions(true);\n var panel = this.viewer.getSettingsPanel(true);\n panel.selectTab(ViewerSettingTab.Performance);\n this.activeStatus = true;\n }\n return true;\n};\n\n/**\n * Closes the Settings UI.\n * \n * @memberof Autodesk.Viewing.Extensions.ViewerSettingsExtension\n * @alias Autodesk.Viewing.Extensions.ViewerSettingsExtension#deactivate\n */\nproto.deactivate = function () {\n if (this.activeStatus) {\n this.viewer.showViewer3dOptions(false);\n this.activeStatus = false;\n }\n return true;\n};","\nimport { theExtensionManager } from \"../src/application/ExtensionManager\";\n\nimport { PropertiesManagerExtension } from \"./PropertiesManager/PropertiesManager\";\nimport { ViewerSettingsExtension } from \"./ViewerSettings/ViewerSettings\";\nimport { ModelStructureExtension } from \"./ModelStructure/ModelStructure\";\nimport { NavToolsExtension } from \"./DefaultTools/NavTools\";\nimport { ExplodeExtension } from \"./Explode/Explode\";\nimport { FullScreenExtension } from \"./FullScreen/FullScreen\";\nimport { GoHomeExtension } from \"./GoHome/GoHome\";\nimport { FusionOrbitExtension } from \"./FusionOrbit/FusionOrbit\";\n\n\ntheExtensionManager.registerExtension('Autodesk.PropertiesManager', PropertiesManagerExtension);\ntheExtensionManager.registerExtension('Autodesk.ViewerSettings', ViewerSettingsExtension);\ntheExtensionManager.registerExtension('Autodesk.ModelStructure', ModelStructureExtension);\ntheExtensionManager.registerExtension('Autodesk.DefaultTools.NavTools', NavToolsExtension);\ntheExtensionManager.registerExtension('Autodesk.Explode', ExplodeExtension);\ntheExtensionManager.registerExtension('Autodesk.FullScreen', FullScreenExtension);\ntheExtensionManager.registerExtension('Autodesk.GoHome', GoHomeExtension);\ntheExtensionManager.registerExtension('Autodesk.Viewing.FusionOrbit', FusionOrbitExtension);","\nvar externalExtensions = [\n\n// First is the path to extension's entry point,\n// Second (and all others) are the extension IDs.\n{\n src: './extensions/Wireframes/Wireframes.js',\n ids: ['Autodesk.Viewing.Wireframes'] },\n\n{\n src: './extensions/ZoomWindow/ZoomWindow.js',\n ids: ['Autodesk.Viewing.ZoomWindow'] },\n\n{\n src: './extensions/AEC/LibraryExports.js',\n ids: [\n 'Autodesk.AEC.LevelsExtension',\n 'Autodesk.AEC.HyperlinkExtension',\n 'Autodesk.AEC.DropMeExtension',\n 'Autodesk.AEC.CanvasBookmarkExtension',\n 'Autodesk.AEC.Minimap3DExtension',\n 'Autodesk.AEC.LocationsExtension',\n 'Autodesk.AEC.Hypermodeling'] },\n\n\n{\n src: './extensions/Pushpins/PushPinExtension.js',\n ids: ['Autodesk.BIM360.Extension.PushPin'] },\n\n{\n src: './extensions/Hyperlink/Hyperlink.js',\n ids: ['Autodesk.Hyperlink'] },\n\n{\n src: './extensions/Debug/Debug.js',\n ids: ['Autodesk.Debug'] },\n\n{\n src: './extensions/BimWalk/BimWalk.js',\n ids: ['Autodesk.BimWalk'] },\n\n{\n src: './extensions/Section/Section.js',\n ids: ['Autodesk.Section'] },\n\n{\n src: './extensions/CompGeom/index.js',\n ids: ['Autodesk.CompGeom'] },\n\n{\n src: './extensions/Snapping/index.js',\n ids: ['Autodesk.Snapping'] },\n\n{\n src: './extensions/Beeline/Beeline.js',\n ids: ['Autodesk.Beeline'] },\n\n{\n src: './extensions/FirstPerson/FirstPerson.js',\n ids: ['Autodesk.FirstPerson'] },\n\n{\n src: './extensions/webVR/webVR.js',\n ids: ['Autodesk.Viewing.WebVR'] },\n\n{\n src: './extensions/CAM360/CAM360.js',\n ids: ['Autodesk.CAM360'] },\n\n{\n src: './extensions/Collaboration/Collaboration.js',\n ids: ['Autodesk.Viewing.Collaboration'] },\n\n{\n src: './extensions/FusionSim/FusionSim.js',\n ids: ['Autodesk.Fusion360.Simulation'] },\n\n{\n src: './extensions/OMV/OMV.js',\n ids: ['Autodesk.OMV'] },\n\n{\n src: './extensions/SplitScreen/SplitScreen.js',\n ids: ['Autodesk.SplitScreen'] },\n\n{\n src: './extensions/CrossFadeEffects/CrossFadeEffects.js',\n ids: ['Autodesk.CrossFadeEffects'] },\n\n{\n src: './extensions/Edit2D/Edit2D.js',\n ids: ['Autodesk.Edit2D'] },\n\n{\n src: './extensions/Edit3D/Edit3D.js',\n ids: ['Autodesk.Edit3D'] },\n\n{\n src: './extensions/VisualClusters/VisualClusters.js',\n ids: ['Autodesk.VisualClusters'] },\n\n{\n src: './extensions/Moldflow/Moldflow.js',\n ids: ['Autodesk.Moldflow'] },\n\n{\n src: './extensions/PixelCompare/PixelCompare.js',\n ids: ['Autodesk.Viewing.PixelCompare'] },\n\n{\n src: './extensions/ScalarisSimulation/ScalarisSimulation.js',\n ids: ['Autodesk.Viewing.ScalarisSimulation'] },\n\n{\n src: './extensions/Measure/Measure.js',\n ids: ['Autodesk.Measure'] },\n\n{\n src: './extensions/Markup/Markup.js',\n ids: [\n 'Autodesk.Viewing.MarkupsCore',\n 'Autodesk.Viewing.MarkupsGui'] },\n\n\n{\n src: './extensions/PDF/index.js',\n ids: ['Autodesk.PDF'] },\n\n{\n src: './extensions/ReCap/index.js',\n ids: ['Autodesk.ReCap'] },\n\n{\n src: './extensions/Scalaris/index.js',\n ids: ['Autodesk.Scalaris'] },\n\n{\n src: './extensions/DocumentBrowser/index.js',\n ids: ['Autodesk.DocumentBrowser'] },\n\n{\n src: './extensions/Geolocation/index.js',\n ids: ['Autodesk.Geolocation'] },\n\n{\n src: './extensions/Fusion360/AnimationExtension.js',\n ids: ['Autodesk.Fusion360.Animation'] },\n\n{\n src: './extensions/NPR/index.js',\n ids: ['Autodesk.NPR'] },\n\n{\n src: './extensions/DOF/DOFExtension.js',\n ids: ['Autodesk.DOF'] },\n\n{\n src: './extensions/MSDF/index.js',\n ids: ['Autodesk.MSDF'] },\n\n{\n src: './extensions/MemoryLimited/MemoryLimited.js',\n ids: ['Autodesk.MemoryLimited'] },\n\n{\n src: './extensions/ViewCubeUi/ViewCubeUi.js',\n ids: ['Autodesk.ViewCubeUi'] },\n\n{\n src: './extensions/MemoryLimitedDebug/MemoryManager.js',\n ids: ['Autodesk.Viewing.MemoryLimitedDebug'] },\n\n{\n src: './extensions/BimMarkups/BimMarkups.js',\n ids: ['Autodesk.BIM360.Markups'] },\n\n{\n src: './extensions/Minimap2D/Minimap2D.js',\n ids: ['Autodesk.BIM360.Minimap'] },\n\n{\n src: './extensions/GestureDocumentNavigation/GestureDocumentNavigation.js',\n ids: ['Autodesk.BIM360.GestureDocumentNavigation'] },\n\n{\n src: './extensions/RollCamera/RollCamera.js',\n ids: ['Autodesk.BIM360.RollCamera'] },\n\n{\n src: './extensions/LayerManager/LayerManager.js',\n ids: ['Autodesk.LayerManager'] },\n\n{\n src: './extensions/SceneBuilder/sceneBuilder.js',\n ids: ['Autodesk.Viewing.SceneBuilder'] },\n\n{\n src: './extensions/Popout/index.js',\n ids: ['Autodesk.Viewing.Popout'] },\n\n{\n src: './extensions/ProfileUi/index.js',\n ids: ['Autodesk.ProfileUi'] },\n\n{\n src: './extensions/PropertySearch/PropertySearch.js',\n ids: ['Autodesk.PropertySearch'] },\n\n{\n src: './extensions/StandardSurface/index.js',\n ids: ['Autodesk.StandardSurface'] },\n\n{\n src: './extensions/MaterialConverterPrism/index.js',\n ids: ['Autodesk.Viewing.MaterialConverterPrism'] },\n\n{\n src: './extensions/DWF/index.js',\n ids: ['Autodesk.DWF'] },\n\n{\n src: './extensions/ModelsPanel/index.js',\n ids: ['Autodesk.ModelsPanel'] },\n\n{\n src: './extensions/ModelAlignment/index.js',\n ids: ['Autodesk.ModelAlignment', 'Autodesk.SheetAlignment'],\n dependencies: ['Autodesk.Edit3D'] },\n\n{\n src: './extensions/ModelAlignmentService/ModelAlignmentService.js',\n ids: ['Autodesk.ModelAlignmentService'] },\n\n{\n src: './extensions/MixpanelProvider/index.js',\n ids: ['Autodesk.Viewing.MixpanelExtension'] },\n\n{\n src: './extensions/Crop/Crop.js',\n ids: ['Autodesk.Crop'] },\n\n{\n src: './extensions/DataVisualization/index.js',\n ids: ['Autodesk.DataVisualization'] },\n\n{\n src: './extensions/StringExtractor/StringExtractor.js',\n ids: ['Autodesk.StringExtractor'] },\n\n{\n src: './extensions/ModelSheetTransition/ModelSheetTransition.js',\n ids: ['Autodesk.ModelSheetTransition'] },\n\n{\n src: './extensions/BoxSelection/BoxSelectionExtension.js',\n ids: ['Autodesk.BoxSelection'] }];\n\n\n\nfunction getExtensionEntryKey(ee) {\n // Given ee.src == './extensions/Something/file.js'\n // then key == 'Something'\n var key = ee.src.split('/')[2];\n return key;\n}\n\nmodule.exports = {\n externalExtensions: externalExtensions,\n getExtensionEntryKey: getExtensionEntryKey };","\nimport { theExtensionManager } from \"../src/application/ExtensionManager\";\nimport { externalExtensions, getExtensionEntryKey } from './externalExtensions';\n\n\nvar ext = BUILD_FLAG__MINIFIED_BUILD ? 'min.js' : 'js';\n\n// Register them all\nexternalExtensions.forEach(function (ee) {\n\n var key = getExtensionEntryKey(ee);\n var filePath = \"extensions/\".concat(key, \"/\").concat(key, \".\").concat(ext);\n var dependencies = ee.dependencies;\n ee.ids.forEach(function (id) {\n theExtensionManager.registerExternalExtension(id, filePath, dependencies);\n });\n});\n\n\nif (BUILD_FLAG__DIFF_TOOL) {\n // Not available in externalExtensions.js\n theExtensionManager.registerExternalExtension('Autodesk.DiffTool', \"extensions/DiffTool/DiffTool.\".concat(ext));\n}","/* Clusterize.js - v0.18.1 - 2018-01-02\n http://NeXTs.github.com/Clusterize.js/\n Copyright (c) 2015 Denis Lukov; Licensed GPLv3 */\n\n;(function(name, definition) {\n if (typeof module != 'undefined') module.exports = definition();\n else if (typeof define == 'function' && typeof define.amd == 'object') define(definition);\n else this[name] = definition();\n}('Clusterize', function() {\n \"use strict\"\n\n // detect ie9 and lower\n // https://gist.github.com/padolsey/527683#comment-786682\n var ie = (function(){\n for( var v = 3,\n el = document.createElement('b'),\n all = el.all || [];\n el.innerHTML = '',\n all[0];\n ){}\n return v > 4 ? v : document.documentMode;\n }()),\n is_mac = navigator.platform.toLowerCase().indexOf('mac') + 1;\n var Clusterize = function(data) {\n if( ! (this instanceof Clusterize))\n return new Clusterize(data);\n var self = this;\n\n var defaults = {\n rows_in_block: 50,\n blocks_in_cluster: 4,\n tag: null,\n show_no_data_row: true,\n no_data_class: 'clusterize-no-data',\n no_data_text: 'No data',\n keep_parity: true,\n callbacks: {}\n }\n\n // public parameters\n self.options = {};\n var options = ['rows_in_block', 'blocks_in_cluster', 'show_no_data_row', 'no_data_class', 'no_data_text', 'keep_parity', 'tag', 'callbacks'];\n for(var i = 0, option; option = options[i]; i++) {\n self.options[option] = typeof data[option] != 'undefined' && data[option] != null\n ? data[option]\n : defaults[option];\n }\n\n var elems = ['scroll', 'content'];\n for(var i = 0, elem; elem = elems[i]; i++) {\n self[elem + '_elem'] = data[elem + 'Id']\n ? document.getElementById(data[elem + 'Id'])\n : data[elem + 'Elem'];\n if( ! self[elem + '_elem'])\n throw new Error(\"Error! Could not find \" + elem + \" element\");\n }\n\n // tabindex forces the browser to keep focus on the scrolling list, fixes #11\n if( ! self.content_elem.hasAttribute('tabindex'))\n self.content_elem.setAttribute('tabindex', 0);\n\n // private parameters\n var rows = isArray(data.rows)\n ? data.rows\n : self.fetchMarkup(),\n cache = {},\n scroll_top = self.scroll_elem.scrollTop;\n\n // append initial data\n self.insertToDOM(rows, cache);\n\n // restore the scroll position\n self.scroll_elem.scrollTop = scroll_top;\n\n // adding scroll handler\n var last_cluster = false,\n scroll_debounce = 0,\n pointer_events_set = false,\n scrollEv = function() {\n // fixes scrolling issue on Mac #3\n if (is_mac) {\n if( ! pointer_events_set) self.content_elem.style.pointerEvents = 'none';\n pointer_events_set = true;\n clearTimeout(scroll_debounce);\n scroll_debounce = setTimeout(function () {\n self.content_elem.style.pointerEvents = 'auto';\n pointer_events_set = false;\n }, 50);\n }\n if (last_cluster != (last_cluster = self.getClusterNum()))\n self.insertToDOM(rows, cache);\n if (self.options.callbacks.scrollingProgress)\n self.options.callbacks.scrollingProgress(self.getScrollProgress());\n },\n resize_debounce = 0,\n resizeEv = function() {\n clearTimeout(resize_debounce);\n resize_debounce = setTimeout(self.refresh, 100);\n }\n on('scroll', self.scroll_elem, scrollEv);\n on('resize', window, resizeEv);\n\n // public methods\n self.destroy = function(clean) {\n off('scroll', self.scroll_elem, scrollEv);\n off('resize', window, resizeEv);\n self.html((clean ? self.generateEmptyRow() : rows).join(''));\n }\n self.refresh = function(force) {\n if(self.getRowsHeight(rows) || force) self.update(rows);\n }\n self.update = function(new_rows) {\n rows = isArray(new_rows)\n ? new_rows\n : [];\n var scroll_top = self.scroll_elem.scrollTop;\n // fixes #39\n if(rows.length * self.options.item_height < scroll_top) {\n self.scroll_elem.scrollTop = 0;\n last_cluster = 0;\n }\n self.insertToDOM(rows, cache);\n self.scroll_elem.scrollTop = scroll_top;\n }\n self.clear = function() {\n self.update([]);\n }\n self.getRowsAmount = function() {\n return rows.length;\n }\n self.getScrollProgress = function() {\n return this.options.scroll_top / (rows.length * this.options.item_height) * 100 || 0;\n }\n\n var add = function(where, _new_rows) {\n var new_rows = isArray(_new_rows)\n ? _new_rows\n : [];\n if( ! new_rows.length) return;\n rows = where == 'append'\n ? rows.concat(new_rows)\n : new_rows.concat(rows);\n self.insertToDOM(rows, cache);\n }\n self.append = function(rows) {\n add('append', rows);\n }\n self.prepend = function(rows) {\n add('prepend', rows);\n }\n }\n\n Clusterize.prototype = {\n constructor: Clusterize,\n // fetch existing markup\n fetchMarkup: function() {\n var rows = [], rows_nodes = this.getChildNodes(this.content_elem);\n while (rows_nodes.length) {\n rows.push(rows_nodes.shift().outerHTML);\n }\n return rows;\n },\n // get tag name, content tag name, tag height, calc cluster height\n exploreEnvironment: function(rows, cache) {\n var opts = this.options;\n opts.content_tag = this.content_elem.tagName.toLowerCase();\n if( ! rows.length) return;\n if(ie && ie <= 9 && ! opts.tag) opts.tag = rows[0].match(/<([^>\\s/]*)/)[1].toLowerCase();\n if(this.content_elem.children.length <= 1) cache.data = this.html(rows[0] + rows[0] + rows[0]);\n if( ! opts.tag) opts.tag = this.content_elem.children[0].tagName.toLowerCase();\n this.getRowsHeight(rows);\n },\n getRowsHeight: function(rows) {\n var opts = this.options,\n prev_item_height = opts.item_height;\n opts.cluster_height = 0;\n if( ! rows.length) return;\n var nodes = this.content_elem.children;\n if( ! nodes.length) return;\n var node = nodes[Math.floor(nodes.length / 2)];\n opts.item_height = node.offsetHeight;\n // consider table's border-spacing\n if(opts.tag == 'tr' && getStyle('borderCollapse', this.content_elem) != 'collapse')\n opts.item_height += parseInt(getStyle('borderSpacing', this.content_elem), 10) || 0;\n // consider margins (and margins collapsing)\n if(opts.tag != 'tr') {\n var marginTop = parseInt(getStyle('marginTop', node), 10) || 0;\n var marginBottom = parseInt(getStyle('marginBottom', node), 10) || 0;\n opts.item_height += Math.max(marginTop, marginBottom);\n }\n opts.block_height = opts.item_height * opts.rows_in_block;\n opts.rows_in_cluster = opts.blocks_in_cluster * opts.rows_in_block;\n opts.cluster_height = opts.blocks_in_cluster * opts.block_height;\n return prev_item_height != opts.item_height;\n },\n // get current cluster number\n getClusterNum: function () {\n this.options.scroll_top = this.scroll_elem.scrollTop;\n return Math.floor(this.options.scroll_top / (this.options.cluster_height - this.options.block_height)) || 0;\n },\n // generate empty row if no data provided\n generateEmptyRow: function() {\n var opts = this.options;\n if( ! opts.tag || ! opts.show_no_data_row) return [];\n var empty_row = document.createElement(opts.tag),\n no_data_content = document.createTextNode(opts.no_data_text), td;\n empty_row.className = opts.no_data_class;\n if(opts.tag == 'tr') {\n td = document.createElement('td');\n // fixes #53\n td.colSpan = 100;\n td.appendChild(no_data_content);\n }\n empty_row.appendChild(td || no_data_content);\n return [empty_row.outerHTML];\n },\n // generate cluster for current scroll position\n generate: function (rows, cluster_num) {\n var opts = this.options,\n rows_len = rows.length;\n if (rows_len < opts.rows_in_block) {\n return {\n top_offset: 0,\n bottom_offset: 0,\n rows_above: 0,\n rows: rows_len ? rows : this.generateEmptyRow()\n }\n }\n var items_start = Math.max((opts.rows_in_cluster - opts.rows_in_block) * cluster_num, 0),\n items_end = items_start + opts.rows_in_cluster,\n top_offset = Math.max(items_start * opts.item_height, 0),\n bottom_offset = Math.max((rows_len - items_end) * opts.item_height, 0),\n this_cluster_rows = [],\n rows_above = items_start;\n if(top_offset < 1) {\n rows_above++;\n }\n for (var i = items_start; i < items_end; i++) {\n rows[i] && this_cluster_rows.push(rows[i]);\n }\n return {\n top_offset: top_offset,\n bottom_offset: bottom_offset,\n rows_above: rows_above,\n rows: this_cluster_rows\n }\n },\n renderExtraTag: function(class_name, height) {\n var tag = document.createElement(this.options.tag),\n clusterize_prefix = 'clusterize-';\n tag.className = [clusterize_prefix + 'extra-row', clusterize_prefix + class_name].join(' ');\n height && (tag.style.height = height + 'px');\n return tag.outerHTML;\n },\n // if necessary verify data changed and insert to DOM\n insertToDOM: function(rows, cache) {\n // explore row's height\n if( ! this.options.cluster_height) {\n this.exploreEnvironment(rows, cache);\n }\n var data = this.generate(rows, this.getClusterNum()),\n this_cluster_rows = data.rows.join(''),\n this_cluster_content_changed = this.checkChanges('data', this_cluster_rows, cache),\n top_offset_changed = this.checkChanges('top', data.top_offset, cache),\n only_bottom_offset_changed = this.checkChanges('bottom', data.bottom_offset, cache),\n callbacks = this.options.callbacks,\n layout = [];\n\n if(this_cluster_content_changed || top_offset_changed) {\n if(data.top_offset) {\n this.options.keep_parity && layout.push(this.renderExtraTag('keep-parity'));\n layout.push(this.renderExtraTag('top-space', data.top_offset));\n }\n layout.push(this_cluster_rows);\n data.bottom_offset && layout.push(this.renderExtraTag('bottom-space', data.bottom_offset));\n callbacks.clusterWillChange && callbacks.clusterWillChange();\n this.html(layout.join(''));\n this.options.content_tag == 'ol' && this.content_elem.setAttribute('start', data.rows_above);\n this.content_elem.style['counter-increment'] = 'clusterize-counter ' + (data.rows_above-1);\n callbacks.clusterChanged && callbacks.clusterChanged();\n } else if(only_bottom_offset_changed) {\n this.content_elem.lastChild.style.height = data.bottom_offset + 'px';\n }\n },\n // unfortunately ie <= 9 does not allow to use innerHTML for table elements, so make a workaround\n html: function(data) {\n var content_elem = this.content_elem;\n if(ie && ie <= 9 && this.options.tag == 'tr') {\n var div = document.createElement('div'), last;\n div.innerHTML = '' + data + '
';\n while((last = content_elem.lastChild)) {\n content_elem.removeChild(last);\n }\n var rows_nodes = this.getChildNodes(div.firstChild.firstChild);\n while (rows_nodes.length) {\n content_elem.appendChild(rows_nodes.shift());\n }\n } else {\n content_elem.innerHTML = data;\n }\n },\n getChildNodes: function(tag) {\n var child_nodes = tag.children, nodes = [];\n for (var i = 0, ii = child_nodes.length; i < ii; i++) {\n nodes.push(child_nodes[i]);\n }\n return nodes;\n },\n checkChanges: function(type, value, cache) {\n var changed = value != cache[type];\n cache[type] = value;\n return changed;\n }\n }\n\n // support functions\n function on(evt, element, fnc) {\n return element.addEventListener ? element.addEventListener(evt, fnc, false) : element.attachEvent(\"on\" + evt, fnc);\n }\n function off(evt, element, fnc) {\n return element.removeEventListener ? element.removeEventListener(evt, fnc, false) : element.detachEvent(\"on\" + evt, fnc);\n }\n function isArray(arr) {\n return Object.prototype.toString.call(arr) === '[object Array]';\n }\n function getStyle(prop, elem) {\n return window.getComputedStyle ? window.getComputedStyle(elem)[prop] : elem.currentStyle[prop];\n }\n\n return Clusterize;\n}));","module.exports = function (it) {\n if (typeof it != 'function') {\n throw TypeError(String(it) + ' is not a function');\n } return it;\n};\n","var isObject = require('../internals/is-object');\n\nmodule.exports = function (it) {\n if (!isObject(it) && it !== null) {\n throw TypeError(\"Can't set \" + String(it) + ' as a prototype');\n } return it;\n};\n","var wellKnownSymbol = require('../internals/well-known-symbol');\nvar create = require('../internals/object-create');\nvar definePropertyModule = require('../internals/object-define-property');\n\nvar UNSCOPABLES = wellKnownSymbol('unscopables');\nvar ArrayPrototype = Array.prototype;\n\n// Array.prototype[@@unscopables]\n// https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables\nif (ArrayPrototype[UNSCOPABLES] == undefined) {\n definePropertyModule.f(ArrayPrototype, UNSCOPABLES, {\n configurable: true,\n value: create(null)\n });\n}\n\n// add a key to Array.prototype[@@unscopables]\nmodule.exports = function (key) {\n ArrayPrototype[UNSCOPABLES][key] = true;\n};\n","'use strict';\nvar charAt = require('../internals/string-multibyte').charAt;\n\n// `AdvanceStringIndex` abstract operation\n// https://tc39.github.io/ecma262/#sec-advancestringindex\nmodule.exports = function (S, index, unicode) {\n return index + (unicode ? charAt(S, index).length : 1);\n};\n","module.exports = function (it, Constructor, name) {\n if (!(it instanceof Constructor)) {\n throw TypeError('Incorrect ' + (name ? name + ' ' : '') + 'invocation');\n } return it;\n};\n","var isObject = require('../internals/is-object');\n\nmodule.exports = function (it) {\n if (!isObject(it)) {\n throw TypeError(String(it) + ' is not an object');\n } return it;\n};\n","module.exports = typeof ArrayBuffer !== 'undefined' && typeof DataView !== 'undefined';\n","'use strict';\nvar NATIVE_ARRAY_BUFFER = require('../internals/array-buffer-native');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar global = require('../internals/global');\nvar isObject = require('../internals/is-object');\nvar has = require('../internals/has');\nvar classof = require('../internals/classof');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar redefine = require('../internals/redefine');\nvar defineProperty = require('../internals/object-define-property').f;\nvar getPrototypeOf = require('../internals/object-get-prototype-of');\nvar setPrototypeOf = require('../internals/object-set-prototype-of');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar uid = require('../internals/uid');\n\nvar Int8Array = global.Int8Array;\nvar Int8ArrayPrototype = Int8Array && Int8Array.prototype;\nvar Uint8ClampedArray = global.Uint8ClampedArray;\nvar Uint8ClampedArrayPrototype = Uint8ClampedArray && Uint8ClampedArray.prototype;\nvar TypedArray = Int8Array && getPrototypeOf(Int8Array);\nvar TypedArrayPrototype = Int8ArrayPrototype && getPrototypeOf(Int8ArrayPrototype);\nvar ObjectPrototype = Object.prototype;\nvar isPrototypeOf = ObjectPrototype.isPrototypeOf;\n\nvar TO_STRING_TAG = wellKnownSymbol('toStringTag');\nvar TYPED_ARRAY_TAG = uid('TYPED_ARRAY_TAG');\n// Fixing native typed arrays in Opera Presto crashes the browser, see #595\nvar NATIVE_ARRAY_BUFFER_VIEWS = NATIVE_ARRAY_BUFFER && !!setPrototypeOf && classof(global.opera) !== 'Opera';\nvar TYPED_ARRAY_TAG_REQIRED = false;\nvar NAME;\n\nvar TypedArrayConstructorsList = {\n Int8Array: 1,\n Uint8Array: 1,\n Uint8ClampedArray: 1,\n Int16Array: 2,\n Uint16Array: 2,\n Int32Array: 4,\n Uint32Array: 4,\n Float32Array: 4,\n Float64Array: 8\n};\n\nvar isView = function isView(it) {\n var klass = classof(it);\n return klass === 'DataView' || has(TypedArrayConstructorsList, klass);\n};\n\nvar isTypedArray = function (it) {\n return isObject(it) && has(TypedArrayConstructorsList, classof(it));\n};\n\nvar aTypedArray = function (it) {\n if (isTypedArray(it)) return it;\n throw TypeError('Target is not a typed array');\n};\n\nvar aTypedArrayConstructor = function (C) {\n if (setPrototypeOf) {\n if (isPrototypeOf.call(TypedArray, C)) return C;\n } else for (var ARRAY in TypedArrayConstructorsList) if (has(TypedArrayConstructorsList, NAME)) {\n var TypedArrayConstructor = global[ARRAY];\n if (TypedArrayConstructor && (C === TypedArrayConstructor || isPrototypeOf.call(TypedArrayConstructor, C))) {\n return C;\n }\n } throw TypeError('Target is not a typed array constructor');\n};\n\nvar exportTypedArrayMethod = function (KEY, property, forced) {\n if (!DESCRIPTORS) return;\n if (forced) for (var ARRAY in TypedArrayConstructorsList) {\n var TypedArrayConstructor = global[ARRAY];\n if (TypedArrayConstructor && has(TypedArrayConstructor.prototype, KEY)) {\n delete TypedArrayConstructor.prototype[KEY];\n }\n }\n if (!TypedArrayPrototype[KEY] || forced) {\n redefine(TypedArrayPrototype, KEY, forced ? property\n : NATIVE_ARRAY_BUFFER_VIEWS && Int8ArrayPrototype[KEY] || property);\n }\n};\n\nvar exportTypedArrayStaticMethod = function (KEY, property, forced) {\n var ARRAY, TypedArrayConstructor;\n if (!DESCRIPTORS) return;\n if (setPrototypeOf) {\n if (forced) for (ARRAY in TypedArrayConstructorsList) {\n TypedArrayConstructor = global[ARRAY];\n if (TypedArrayConstructor && has(TypedArrayConstructor, KEY)) {\n delete TypedArrayConstructor[KEY];\n }\n }\n if (!TypedArray[KEY] || forced) {\n // V8 ~ Chrome 49-50 `%TypedArray%` methods are non-writable non-configurable\n try {\n return redefine(TypedArray, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && Int8Array[KEY] || property);\n } catch (error) { /* empty */ }\n } else return;\n }\n for (ARRAY in TypedArrayConstructorsList) {\n TypedArrayConstructor = global[ARRAY];\n if (TypedArrayConstructor && (!TypedArrayConstructor[KEY] || forced)) {\n redefine(TypedArrayConstructor, KEY, property);\n }\n }\n};\n\nfor (NAME in TypedArrayConstructorsList) {\n if (!global[NAME]) NATIVE_ARRAY_BUFFER_VIEWS = false;\n}\n\n// WebKit bug - typed arrays constructors prototype is Object.prototype\nif (!NATIVE_ARRAY_BUFFER_VIEWS || typeof TypedArray != 'function' || TypedArray === Function.prototype) {\n // eslint-disable-next-line no-shadow\n TypedArray = function TypedArray() {\n throw TypeError('Incorrect invocation');\n };\n if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) {\n if (global[NAME]) setPrototypeOf(global[NAME], TypedArray);\n }\n}\n\nif (!NATIVE_ARRAY_BUFFER_VIEWS || !TypedArrayPrototype || TypedArrayPrototype === ObjectPrototype) {\n TypedArrayPrototype = TypedArray.prototype;\n if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) {\n if (global[NAME]) setPrototypeOf(global[NAME].prototype, TypedArrayPrototype);\n }\n}\n\n// WebKit bug - one more object in Uint8ClampedArray prototype chain\nif (NATIVE_ARRAY_BUFFER_VIEWS && getPrototypeOf(Uint8ClampedArrayPrototype) !== TypedArrayPrototype) {\n setPrototypeOf(Uint8ClampedArrayPrototype, TypedArrayPrototype);\n}\n\nif (DESCRIPTORS && !has(TypedArrayPrototype, TO_STRING_TAG)) {\n TYPED_ARRAY_TAG_REQIRED = true;\n defineProperty(TypedArrayPrototype, TO_STRING_TAG, { get: function () {\n return isObject(this) ? this[TYPED_ARRAY_TAG] : undefined;\n } });\n for (NAME in TypedArrayConstructorsList) if (global[NAME]) {\n createNonEnumerableProperty(global[NAME], TYPED_ARRAY_TAG, NAME);\n }\n}\n\nmodule.exports = {\n NATIVE_ARRAY_BUFFER_VIEWS: NATIVE_ARRAY_BUFFER_VIEWS,\n TYPED_ARRAY_TAG: TYPED_ARRAY_TAG_REQIRED && TYPED_ARRAY_TAG,\n aTypedArray: aTypedArray,\n aTypedArrayConstructor: aTypedArrayConstructor,\n exportTypedArrayMethod: exportTypedArrayMethod,\n exportTypedArrayStaticMethod: exportTypedArrayStaticMethod,\n isView: isView,\n isTypedArray: isTypedArray,\n TypedArray: TypedArray,\n TypedArrayPrototype: TypedArrayPrototype\n};\n","'use strict';\nvar global = require('../internals/global');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar NATIVE_ARRAY_BUFFER = require('../internals/array-buffer-native');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar redefineAll = require('../internals/redefine-all');\nvar fails = require('../internals/fails');\nvar anInstance = require('../internals/an-instance');\nvar toInteger = require('../internals/to-integer');\nvar toLength = require('../internals/to-length');\nvar toIndex = require('../internals/to-index');\nvar IEEE754 = require('../internals/ieee754');\nvar getPrototypeOf = require('../internals/object-get-prototype-of');\nvar setPrototypeOf = require('../internals/object-set-prototype-of');\nvar getOwnPropertyNames = require('../internals/object-get-own-property-names').f;\nvar defineProperty = require('../internals/object-define-property').f;\nvar arrayFill = require('../internals/array-fill');\nvar setToStringTag = require('../internals/set-to-string-tag');\nvar InternalStateModule = require('../internals/internal-state');\n\nvar getInternalState = InternalStateModule.get;\nvar setInternalState = InternalStateModule.set;\nvar ARRAY_BUFFER = 'ArrayBuffer';\nvar DATA_VIEW = 'DataView';\nvar PROTOTYPE = 'prototype';\nvar WRONG_LENGTH = 'Wrong length';\nvar WRONG_INDEX = 'Wrong index';\nvar NativeArrayBuffer = global[ARRAY_BUFFER];\nvar $ArrayBuffer = NativeArrayBuffer;\nvar $DataView = global[DATA_VIEW];\nvar $DataViewPrototype = $DataView && $DataView[PROTOTYPE];\nvar ObjectPrototype = Object.prototype;\nvar RangeError = global.RangeError;\n\nvar packIEEE754 = IEEE754.pack;\nvar unpackIEEE754 = IEEE754.unpack;\n\nvar packInt8 = function (number) {\n return [number & 0xFF];\n};\n\nvar packInt16 = function (number) {\n return [number & 0xFF, number >> 8 & 0xFF];\n};\n\nvar packInt32 = function (number) {\n return [number & 0xFF, number >> 8 & 0xFF, number >> 16 & 0xFF, number >> 24 & 0xFF];\n};\n\nvar unpackInt32 = function (buffer) {\n return buffer[3] << 24 | buffer[2] << 16 | buffer[1] << 8 | buffer[0];\n};\n\nvar packFloat32 = function (number) {\n return packIEEE754(number, 23, 4);\n};\n\nvar packFloat64 = function (number) {\n return packIEEE754(number, 52, 8);\n};\n\nvar addGetter = function (Constructor, key) {\n defineProperty(Constructor[PROTOTYPE], key, { get: function () { return getInternalState(this)[key]; } });\n};\n\nvar get = function (view, count, index, isLittleEndian) {\n var intIndex = toIndex(index);\n var store = getInternalState(view);\n if (intIndex + count > store.byteLength) throw RangeError(WRONG_INDEX);\n var bytes = getInternalState(store.buffer).bytes;\n var start = intIndex + store.byteOffset;\n var pack = bytes.slice(start, start + count);\n return isLittleEndian ? pack : pack.reverse();\n};\n\nvar set = function (view, count, index, conversion, value, isLittleEndian) {\n var intIndex = toIndex(index);\n var store = getInternalState(view);\n if (intIndex + count > store.byteLength) throw RangeError(WRONG_INDEX);\n var bytes = getInternalState(store.buffer).bytes;\n var start = intIndex + store.byteOffset;\n var pack = conversion(+value);\n for (var i = 0; i < count; i++) bytes[start + i] = pack[isLittleEndian ? i : count - i - 1];\n};\n\nif (!NATIVE_ARRAY_BUFFER) {\n $ArrayBuffer = function ArrayBuffer(length) {\n anInstance(this, $ArrayBuffer, ARRAY_BUFFER);\n var byteLength = toIndex(length);\n setInternalState(this, {\n bytes: arrayFill.call(new Array(byteLength), 0),\n byteLength: byteLength\n });\n if (!DESCRIPTORS) this.byteLength = byteLength;\n };\n\n $DataView = function DataView(buffer, byteOffset, byteLength) {\n anInstance(this, $DataView, DATA_VIEW);\n anInstance(buffer, $ArrayBuffer, DATA_VIEW);\n var bufferLength = getInternalState(buffer).byteLength;\n var offset = toInteger(byteOffset);\n if (offset < 0 || offset > bufferLength) throw RangeError('Wrong offset');\n byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength);\n if (offset + byteLength > bufferLength) throw RangeError(WRONG_LENGTH);\n setInternalState(this, {\n buffer: buffer,\n byteLength: byteLength,\n byteOffset: offset\n });\n if (!DESCRIPTORS) {\n this.buffer = buffer;\n this.byteLength = byteLength;\n this.byteOffset = offset;\n }\n };\n\n if (DESCRIPTORS) {\n addGetter($ArrayBuffer, 'byteLength');\n addGetter($DataView, 'buffer');\n addGetter($DataView, 'byteLength');\n addGetter($DataView, 'byteOffset');\n }\n\n redefineAll($DataView[PROTOTYPE], {\n getInt8: function getInt8(byteOffset) {\n return get(this, 1, byteOffset)[0] << 24 >> 24;\n },\n getUint8: function getUint8(byteOffset) {\n return get(this, 1, byteOffset)[0];\n },\n getInt16: function getInt16(byteOffset /* , littleEndian */) {\n var bytes = get(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined);\n return (bytes[1] << 8 | bytes[0]) << 16 >> 16;\n },\n getUint16: function getUint16(byteOffset /* , littleEndian */) {\n var bytes = get(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined);\n return bytes[1] << 8 | bytes[0];\n },\n getInt32: function getInt32(byteOffset /* , littleEndian */) {\n return unpackInt32(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined));\n },\n getUint32: function getUint32(byteOffset /* , littleEndian */) {\n return unpackInt32(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined)) >>> 0;\n },\n getFloat32: function getFloat32(byteOffset /* , littleEndian */) {\n return unpackIEEE754(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 23);\n },\n getFloat64: function getFloat64(byteOffset /* , littleEndian */) {\n return unpackIEEE754(get(this, 8, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 52);\n },\n setInt8: function setInt8(byteOffset, value) {\n set(this, 1, byteOffset, packInt8, value);\n },\n setUint8: function setUint8(byteOffset, value) {\n set(this, 1, byteOffset, packInt8, value);\n },\n setInt16: function setInt16(byteOffset, value /* , littleEndian */) {\n set(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined);\n },\n setUint16: function setUint16(byteOffset, value /* , littleEndian */) {\n set(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined);\n },\n setInt32: function setInt32(byteOffset, value /* , littleEndian */) {\n set(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined);\n },\n setUint32: function setUint32(byteOffset, value /* , littleEndian */) {\n set(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined);\n },\n setFloat32: function setFloat32(byteOffset, value /* , littleEndian */) {\n set(this, 4, byteOffset, packFloat32, value, arguments.length > 2 ? arguments[2] : undefined);\n },\n setFloat64: function setFloat64(byteOffset, value /* , littleEndian */) {\n set(this, 8, byteOffset, packFloat64, value, arguments.length > 2 ? arguments[2] : undefined);\n }\n });\n} else {\n if (!fails(function () {\n NativeArrayBuffer(1);\n }) || !fails(function () {\n new NativeArrayBuffer(-1); // eslint-disable-line no-new\n }) || fails(function () {\n new NativeArrayBuffer(); // eslint-disable-line no-new\n new NativeArrayBuffer(1.5); // eslint-disable-line no-new\n new NativeArrayBuffer(NaN); // eslint-disable-line no-new\n return NativeArrayBuffer.name != ARRAY_BUFFER;\n })) {\n $ArrayBuffer = function ArrayBuffer(length) {\n anInstance(this, $ArrayBuffer);\n return new NativeArrayBuffer(toIndex(length));\n };\n var ArrayBufferPrototype = $ArrayBuffer[PROTOTYPE] = NativeArrayBuffer[PROTOTYPE];\n for (var keys = getOwnPropertyNames(NativeArrayBuffer), j = 0, key; keys.length > j;) {\n if (!((key = keys[j++]) in $ArrayBuffer)) {\n createNonEnumerableProperty($ArrayBuffer, key, NativeArrayBuffer[key]);\n }\n }\n ArrayBufferPrototype.constructor = $ArrayBuffer;\n }\n\n // WebKit bug - the same parent prototype for typed arrays and data view\n if (setPrototypeOf && getPrototypeOf($DataViewPrototype) !== ObjectPrototype) {\n setPrototypeOf($DataViewPrototype, ObjectPrototype);\n }\n\n // iOS Safari 7.x bug\n var testView = new $DataView(new $ArrayBuffer(2));\n var nativeSetInt8 = $DataViewPrototype.setInt8;\n testView.setInt8(0, 2147483648);\n testView.setInt8(1, 2147483649);\n if (testView.getInt8(0) || !testView.getInt8(1)) redefineAll($DataViewPrototype, {\n setInt8: function setInt8(byteOffset, value) {\n nativeSetInt8.call(this, byteOffset, value << 24 >> 24);\n },\n setUint8: function setUint8(byteOffset, value) {\n nativeSetInt8.call(this, byteOffset, value << 24 >> 24);\n }\n }, { unsafe: true });\n}\n\nsetToStringTag($ArrayBuffer, ARRAY_BUFFER);\nsetToStringTag($DataView, DATA_VIEW);\n\nmodule.exports = {\n ArrayBuffer: $ArrayBuffer,\n DataView: $DataView\n};\n","'use strict';\nvar toObject = require('../internals/to-object');\nvar toAbsoluteIndex = require('../internals/to-absolute-index');\nvar toLength = require('../internals/to-length');\n\nvar min = Math.min;\n\n// `Array.prototype.copyWithin` method implementation\n// https://tc39.github.io/ecma262/#sec-array.prototype.copywithin\nmodule.exports = [].copyWithin || function copyWithin(target /* = 0 */, start /* = 0, end = @length */) {\n var O = toObject(this);\n var len = toLength(O.length);\n var to = toAbsoluteIndex(target, len);\n var from = toAbsoluteIndex(start, len);\n var end = arguments.length > 2 ? arguments[2] : undefined;\n var count = min((end === undefined ? len : toAbsoluteIndex(end, len)) - from, len - to);\n var inc = 1;\n if (from < to && to < from + count) {\n inc = -1;\n from += count - 1;\n to += count - 1;\n }\n while (count-- > 0) {\n if (from in O) O[to] = O[from];\n else delete O[to];\n to += inc;\n from += inc;\n } return O;\n};\n","'use strict';\nvar toObject = require('../internals/to-object');\nvar toAbsoluteIndex = require('../internals/to-absolute-index');\nvar toLength = require('../internals/to-length');\n\n// `Array.prototype.fill` method implementation\n// https://tc39.github.io/ecma262/#sec-array.prototype.fill\nmodule.exports = function fill(value /* , start = 0, end = @length */) {\n var O = toObject(this);\n var length = toLength(O.length);\n var argumentsLength = arguments.length;\n var index = toAbsoluteIndex(argumentsLength > 1 ? arguments[1] : undefined, length);\n var end = argumentsLength > 2 ? arguments[2] : undefined;\n var endPos = end === undefined ? length : toAbsoluteIndex(end, length);\n while (endPos > index) O[index++] = value;\n return O;\n};\n","'use strict';\nvar $forEach = require('../internals/array-iteration').forEach;\nvar arrayMethodIsStrict = require('../internals/array-method-is-strict');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar STRICT_METHOD = arrayMethodIsStrict('forEach');\nvar USES_TO_LENGTH = arrayMethodUsesToLength('forEach');\n\n// `Array.prototype.forEach` method implementation\n// https://tc39.github.io/ecma262/#sec-array.prototype.foreach\nmodule.exports = (!STRICT_METHOD || !USES_TO_LENGTH) ? function forEach(callbackfn /* , thisArg */) {\n return $forEach(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n} : [].forEach;\n","'use strict';\nvar bind = require('../internals/function-bind-context');\nvar toObject = require('../internals/to-object');\nvar callWithSafeIterationClosing = require('../internals/call-with-safe-iteration-closing');\nvar isArrayIteratorMethod = require('../internals/is-array-iterator-method');\nvar toLength = require('../internals/to-length');\nvar createProperty = require('../internals/create-property');\nvar getIteratorMethod = require('../internals/get-iterator-method');\n\n// `Array.from` method implementation\n// https://tc39.github.io/ecma262/#sec-array.from\nmodule.exports = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {\n var O = toObject(arrayLike);\n var C = typeof this == 'function' ? this : Array;\n var argumentsLength = arguments.length;\n var mapfn = argumentsLength > 1 ? arguments[1] : undefined;\n var mapping = mapfn !== undefined;\n var iteratorMethod = getIteratorMethod(O);\n var index = 0;\n var length, result, step, iterator, next, value;\n if (mapping) mapfn = bind(mapfn, argumentsLength > 2 ? arguments[2] : undefined, 2);\n // if the target is not iterable or it's an array with the default iterator - use a simple case\n if (iteratorMethod != undefined && !(C == Array && isArrayIteratorMethod(iteratorMethod))) {\n iterator = iteratorMethod.call(O);\n next = iterator.next;\n result = new C();\n for (;!(step = next.call(iterator)).done; index++) {\n value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;\n createProperty(result, index, value);\n }\n } else {\n length = toLength(O.length);\n result = new C(length);\n for (;length > index; index++) {\n value = mapping ? mapfn(O[index], index) : O[index];\n createProperty(result, index, value);\n }\n }\n result.length = index;\n return result;\n};\n","var toIndexedObject = require('../internals/to-indexed-object');\nvar toLength = require('../internals/to-length');\nvar toAbsoluteIndex = require('../internals/to-absolute-index');\n\n// `Array.prototype.{ indexOf, includes }` methods implementation\nvar createMethod = function (IS_INCLUDES) {\n return function ($this, el, fromIndex) {\n var O = toIndexedObject($this);\n var length = toLength(O.length);\n var index = toAbsoluteIndex(fromIndex, length);\n var value;\n // Array#includes uses SameValueZero equality algorithm\n // eslint-disable-next-line no-self-compare\n if (IS_INCLUDES && el != el) while (length > index) {\n value = O[index++];\n // eslint-disable-next-line no-self-compare\n if (value != value) return true;\n // Array#indexOf ignores holes, Array#includes - not\n } else for (;length > index; index++) {\n if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;\n } return !IS_INCLUDES && -1;\n };\n};\n\nmodule.exports = {\n // `Array.prototype.includes` method\n // https://tc39.github.io/ecma262/#sec-array.prototype.includes\n includes: createMethod(true),\n // `Array.prototype.indexOf` method\n // https://tc39.github.io/ecma262/#sec-array.prototype.indexof\n indexOf: createMethod(false)\n};\n","var bind = require('../internals/function-bind-context');\nvar IndexedObject = require('../internals/indexed-object');\nvar toObject = require('../internals/to-object');\nvar toLength = require('../internals/to-length');\nvar arraySpeciesCreate = require('../internals/array-species-create');\n\nvar push = [].push;\n\n// `Array.prototype.{ forEach, map, filter, some, every, find, findIndex }` methods implementation\nvar createMethod = function (TYPE) {\n var IS_MAP = TYPE == 1;\n var IS_FILTER = TYPE == 2;\n var IS_SOME = TYPE == 3;\n var IS_EVERY = TYPE == 4;\n var IS_FIND_INDEX = TYPE == 6;\n var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;\n return function ($this, callbackfn, that, specificCreate) {\n var O = toObject($this);\n var self = IndexedObject(O);\n var boundFunction = bind(callbackfn, that, 3);\n var length = toLength(self.length);\n var index = 0;\n var create = specificCreate || arraySpeciesCreate;\n var target = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;\n var value, result;\n for (;length > index; index++) if (NO_HOLES || index in self) {\n value = self[index];\n result = boundFunction(value, index, O);\n if (TYPE) {\n if (IS_MAP) target[index] = result; // map\n else if (result) switch (TYPE) {\n case 3: return true; // some\n case 5: return value; // find\n case 6: return index; // findIndex\n case 2: push.call(target, value); // filter\n } else if (IS_EVERY) return false; // every\n }\n }\n return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;\n };\n};\n\nmodule.exports = {\n // `Array.prototype.forEach` method\n // https://tc39.github.io/ecma262/#sec-array.prototype.foreach\n forEach: createMethod(0),\n // `Array.prototype.map` method\n // https://tc39.github.io/ecma262/#sec-array.prototype.map\n map: createMethod(1),\n // `Array.prototype.filter` method\n // https://tc39.github.io/ecma262/#sec-array.prototype.filter\n filter: createMethod(2),\n // `Array.prototype.some` method\n // https://tc39.github.io/ecma262/#sec-array.prototype.some\n some: createMethod(3),\n // `Array.prototype.every` method\n // https://tc39.github.io/ecma262/#sec-array.prototype.every\n every: createMethod(4),\n // `Array.prototype.find` method\n // https://tc39.github.io/ecma262/#sec-array.prototype.find\n find: createMethod(5),\n // `Array.prototype.findIndex` method\n // https://tc39.github.io/ecma262/#sec-array.prototype.findIndex\n findIndex: createMethod(6)\n};\n","'use strict';\nvar toIndexedObject = require('../internals/to-indexed-object');\nvar toInteger = require('../internals/to-integer');\nvar toLength = require('../internals/to-length');\nvar arrayMethodIsStrict = require('../internals/array-method-is-strict');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar min = Math.min;\nvar nativeLastIndexOf = [].lastIndexOf;\nvar NEGATIVE_ZERO = !!nativeLastIndexOf && 1 / [1].lastIndexOf(1, -0) < 0;\nvar STRICT_METHOD = arrayMethodIsStrict('lastIndexOf');\n// For preventing possible almost infinite loop in non-standard implementations, test the forward version of the method\nvar USES_TO_LENGTH = arrayMethodUsesToLength('indexOf', { ACCESSORS: true, 1: 0 });\nvar FORCED = NEGATIVE_ZERO || !STRICT_METHOD || !USES_TO_LENGTH;\n\n// `Array.prototype.lastIndexOf` method implementation\n// https://tc39.github.io/ecma262/#sec-array.prototype.lastindexof\nmodule.exports = FORCED ? function lastIndexOf(searchElement /* , fromIndex = @[*-1] */) {\n // convert -0 to +0\n if (NEGATIVE_ZERO) return nativeLastIndexOf.apply(this, arguments) || 0;\n var O = toIndexedObject(this);\n var length = toLength(O.length);\n var index = length - 1;\n if (arguments.length > 1) index = min(index, toInteger(arguments[1]));\n if (index < 0) index = length + index;\n for (;index >= 0; index--) if (index in O && O[index] === searchElement) return index || 0;\n return -1;\n} : nativeLastIndexOf;\n","var fails = require('../internals/fails');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar V8_VERSION = require('../internals/engine-v8-version');\n\nvar SPECIES = wellKnownSymbol('species');\n\nmodule.exports = function (METHOD_NAME) {\n // We can't use this feature detection in V8 since it causes\n // deoptimization and serious performance degradation\n // https://github.com/zloirock/core-js/issues/677\n return V8_VERSION >= 51 || !fails(function () {\n var array = [];\n var constructor = array.constructor = {};\n constructor[SPECIES] = function () {\n return { foo: 1 };\n };\n return array[METHOD_NAME](Boolean).foo !== 1;\n });\n};\n","'use strict';\nvar fails = require('../internals/fails');\n\nmodule.exports = function (METHOD_NAME, argument) {\n var method = [][METHOD_NAME];\n return !!method && fails(function () {\n // eslint-disable-next-line no-useless-call,no-throw-literal\n method.call(null, argument || function () { throw 1; }, 1);\n });\n};\n","var DESCRIPTORS = require('../internals/descriptors');\nvar fails = require('../internals/fails');\nvar has = require('../internals/has');\n\nvar defineProperty = Object.defineProperty;\nvar cache = {};\n\nvar thrower = function (it) { throw it; };\n\nmodule.exports = function (METHOD_NAME, options) {\n if (has(cache, METHOD_NAME)) return cache[METHOD_NAME];\n if (!options) options = {};\n var method = [][METHOD_NAME];\n var ACCESSORS = has(options, 'ACCESSORS') ? options.ACCESSORS : false;\n var argument0 = has(options, 0) ? options[0] : thrower;\n var argument1 = has(options, 1) ? options[1] : undefined;\n\n return cache[METHOD_NAME] = !!method && !fails(function () {\n if (ACCESSORS && !DESCRIPTORS) return true;\n var O = { length: -1 };\n\n if (ACCESSORS) defineProperty(O, 1, { enumerable: true, get: thrower });\n else O[1] = 1;\n\n method.call(O, argument0, argument1);\n });\n};\n","var aFunction = require('../internals/a-function');\nvar toObject = require('../internals/to-object');\nvar IndexedObject = require('../internals/indexed-object');\nvar toLength = require('../internals/to-length');\n\n// `Array.prototype.{ reduce, reduceRight }` methods implementation\nvar createMethod = function (IS_RIGHT) {\n return function (that, callbackfn, argumentsLength, memo) {\n aFunction(callbackfn);\n var O = toObject(that);\n var self = IndexedObject(O);\n var length = toLength(O.length);\n var index = IS_RIGHT ? length - 1 : 0;\n var i = IS_RIGHT ? -1 : 1;\n if (argumentsLength < 2) while (true) {\n if (index in self) {\n memo = self[index];\n index += i;\n break;\n }\n index += i;\n if (IS_RIGHT ? index < 0 : length <= index) {\n throw TypeError('Reduce of empty array with no initial value');\n }\n }\n for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {\n memo = callbackfn(memo, self[index], index, O);\n }\n return memo;\n };\n};\n\nmodule.exports = {\n // `Array.prototype.reduce` method\n // https://tc39.github.io/ecma262/#sec-array.prototype.reduce\n left: createMethod(false),\n // `Array.prototype.reduceRight` method\n // https://tc39.github.io/ecma262/#sec-array.prototype.reduceright\n right: createMethod(true)\n};\n","var isObject = require('../internals/is-object');\nvar isArray = require('../internals/is-array');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar SPECIES = wellKnownSymbol('species');\n\n// `ArraySpeciesCreate` abstract operation\n// https://tc39.github.io/ecma262/#sec-arrayspeciescreate\nmodule.exports = function (originalArray, length) {\n var C;\n if (isArray(originalArray)) {\n C = originalArray.constructor;\n // cross-realm fallback\n if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;\n else if (isObject(C)) {\n C = C[SPECIES];\n if (C === null) C = undefined;\n }\n } return new (C === undefined ? Array : C)(length === 0 ? 0 : length);\n};\n","var anObject = require('../internals/an-object');\n\n// call something on iterator step with safe closing on error\nmodule.exports = function (iterator, fn, value, ENTRIES) {\n try {\n return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);\n // 7.4.6 IteratorClose(iterator, completion)\n } catch (error) {\n var returnMethod = iterator['return'];\n if (returnMethod !== undefined) anObject(returnMethod.call(iterator));\n throw error;\n }\n};\n","var wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar ITERATOR = wellKnownSymbol('iterator');\nvar SAFE_CLOSING = false;\n\ntry {\n var called = 0;\n var iteratorWithReturn = {\n next: function () {\n return { done: !!called++ };\n },\n 'return': function () {\n SAFE_CLOSING = true;\n }\n };\n iteratorWithReturn[ITERATOR] = function () {\n return this;\n };\n // eslint-disable-next-line no-throw-literal\n Array.from(iteratorWithReturn, function () { throw 2; });\n} catch (error) { /* empty */ }\n\nmodule.exports = function (exec, SKIP_CLOSING) {\n if (!SKIP_CLOSING && !SAFE_CLOSING) return false;\n var ITERATION_SUPPORT = false;\n try {\n var object = {};\n object[ITERATOR] = function () {\n return {\n next: function () {\n return { done: ITERATION_SUPPORT = true };\n }\n };\n };\n exec(object);\n } catch (error) { /* empty */ }\n return ITERATION_SUPPORT;\n};\n","var toString = {}.toString;\n\nmodule.exports = function (it) {\n return toString.call(it).slice(8, -1);\n};\n","var TO_STRING_TAG_SUPPORT = require('../internals/to-string-tag-support');\nvar classofRaw = require('../internals/classof-raw');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar TO_STRING_TAG = wellKnownSymbol('toStringTag');\n// ES3 wrong here\nvar CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';\n\n// fallback for IE11 Script Access Denied error\nvar tryGet = function (it, key) {\n try {\n return it[key];\n } catch (error) { /* empty */ }\n};\n\n// getting tag from ES6+ `Object.prototype.toString`\nmodule.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {\n var O, tag, result;\n return it === undefined ? 'Undefined' : it === null ? 'Null'\n // @@toStringTag case\n : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG)) == 'string' ? tag\n // builtinTag case\n : CORRECT_ARGUMENTS ? classofRaw(O)\n // ES3 arguments fallback\n : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result;\n};\n","'use strict';\nvar anObject = require('../internals/an-object');\nvar aFunction = require('../internals/a-function');\n\n// https://github.com/tc39/collection-methods\nmodule.exports = function (/* ...elements */) {\n var set = anObject(this);\n var adder = aFunction(set.add);\n for (var k = 0, len = arguments.length; k < len; k++) {\n adder.call(set, arguments[k]);\n }\n return set;\n};\n","'use strict';\nvar anObject = require('../internals/an-object');\nvar aFunction = require('../internals/a-function');\n\n// https://github.com/tc39/collection-methods\nmodule.exports = function (/* ...elements */) {\n var collection = anObject(this);\n var remover = aFunction(collection['delete']);\n var allDeleted = true;\n var wasDeleted;\n for (var k = 0, len = arguments.length; k < len; k++) {\n wasDeleted = remover.call(collection, arguments[k]);\n allDeleted = allDeleted && wasDeleted;\n }\n return !!allDeleted;\n};\n","'use strict';\n// https://tc39.github.io/proposal-setmap-offrom/\nvar aFunction = require('../internals/a-function');\nvar bind = require('../internals/function-bind-context');\nvar iterate = require('../internals/iterate');\n\nmodule.exports = function from(source /* , mapFn, thisArg */) {\n var length = arguments.length;\n var mapFn = length > 1 ? arguments[1] : undefined;\n var mapping, A, n, boundFunction;\n aFunction(this);\n mapping = mapFn !== undefined;\n if (mapping) aFunction(mapFn);\n if (source == undefined) return new this();\n A = [];\n if (mapping) {\n n = 0;\n boundFunction = bind(mapFn, length > 2 ? arguments[2] : undefined, 2);\n iterate(source, function (nextItem) {\n A.push(boundFunction(nextItem, n++));\n });\n } else {\n iterate(source, A.push, A);\n }\n return new this(A);\n};\n","'use strict';\n// https://tc39.github.io/proposal-setmap-offrom/\nmodule.exports = function of() {\n var length = arguments.length;\n var A = new Array(length);\n while (length--) A[length] = arguments[length];\n return new this(A);\n};\n","'use strict';\nvar defineProperty = require('../internals/object-define-property').f;\nvar create = require('../internals/object-create');\nvar redefineAll = require('../internals/redefine-all');\nvar bind = require('../internals/function-bind-context');\nvar anInstance = require('../internals/an-instance');\nvar iterate = require('../internals/iterate');\nvar defineIterator = require('../internals/define-iterator');\nvar setSpecies = require('../internals/set-species');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar fastKey = require('../internals/internal-metadata').fastKey;\nvar InternalStateModule = require('../internals/internal-state');\n\nvar setInternalState = InternalStateModule.set;\nvar internalStateGetterFor = InternalStateModule.getterFor;\n\nmodule.exports = {\n getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {\n var C = wrapper(function (that, iterable) {\n anInstance(that, C, CONSTRUCTOR_NAME);\n setInternalState(that, {\n type: CONSTRUCTOR_NAME,\n index: create(null),\n first: undefined,\n last: undefined,\n size: 0\n });\n if (!DESCRIPTORS) that.size = 0;\n if (iterable != undefined) iterate(iterable, that[ADDER], that, IS_MAP);\n });\n\n var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);\n\n var define = function (that, key, value) {\n var state = getInternalState(that);\n var entry = getEntry(that, key);\n var previous, index;\n // change existing entry\n if (entry) {\n entry.value = value;\n // create new entry\n } else {\n state.last = entry = {\n index: index = fastKey(key, true),\n key: key,\n value: value,\n previous: previous = state.last,\n next: undefined,\n removed: false\n };\n if (!state.first) state.first = entry;\n if (previous) previous.next = entry;\n if (DESCRIPTORS) state.size++;\n else that.size++;\n // add to index\n if (index !== 'F') state.index[index] = entry;\n } return that;\n };\n\n var getEntry = function (that, key) {\n var state = getInternalState(that);\n // fast case\n var index = fastKey(key);\n var entry;\n if (index !== 'F') return state.index[index];\n // frozen object case\n for (entry = state.first; entry; entry = entry.next) {\n if (entry.key == key) return entry;\n }\n };\n\n redefineAll(C.prototype, {\n // 23.1.3.1 Map.prototype.clear()\n // 23.2.3.2 Set.prototype.clear()\n clear: function clear() {\n var that = this;\n var state = getInternalState(that);\n var data = state.index;\n var entry = state.first;\n while (entry) {\n entry.removed = true;\n if (entry.previous) entry.previous = entry.previous.next = undefined;\n delete data[entry.index];\n entry = entry.next;\n }\n state.first = state.last = undefined;\n if (DESCRIPTORS) state.size = 0;\n else that.size = 0;\n },\n // 23.1.3.3 Map.prototype.delete(key)\n // 23.2.3.4 Set.prototype.delete(value)\n 'delete': function (key) {\n var that = this;\n var state = getInternalState(that);\n var entry = getEntry(that, key);\n if (entry) {\n var next = entry.next;\n var prev = entry.previous;\n delete state.index[entry.index];\n entry.removed = true;\n if (prev) prev.next = next;\n if (next) next.previous = prev;\n if (state.first == entry) state.first = next;\n if (state.last == entry) state.last = prev;\n if (DESCRIPTORS) state.size--;\n else that.size--;\n } return !!entry;\n },\n // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)\n // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined)\n forEach: function forEach(callbackfn /* , that = undefined */) {\n var state = getInternalState(this);\n var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);\n var entry;\n while (entry = entry ? entry.next : state.first) {\n boundFunction(entry.value, entry.key, this);\n // revert to the last existing entry\n while (entry && entry.removed) entry = entry.previous;\n }\n },\n // 23.1.3.7 Map.prototype.has(key)\n // 23.2.3.7 Set.prototype.has(value)\n has: function has(key) {\n return !!getEntry(this, key);\n }\n });\n\n redefineAll(C.prototype, IS_MAP ? {\n // 23.1.3.6 Map.prototype.get(key)\n get: function get(key) {\n var entry = getEntry(this, key);\n return entry && entry.value;\n },\n // 23.1.3.9 Map.prototype.set(key, value)\n set: function set(key, value) {\n return define(this, key === 0 ? 0 : key, value);\n }\n } : {\n // 23.2.3.1 Set.prototype.add(value)\n add: function add(value) {\n return define(this, value = value === 0 ? 0 : value, value);\n }\n });\n if (DESCRIPTORS) defineProperty(C.prototype, 'size', {\n get: function () {\n return getInternalState(this).size;\n }\n });\n return C;\n },\n setStrong: function (C, CONSTRUCTOR_NAME, IS_MAP) {\n var ITERATOR_NAME = CONSTRUCTOR_NAME + ' Iterator';\n var getInternalCollectionState = internalStateGetterFor(CONSTRUCTOR_NAME);\n var getInternalIteratorState = internalStateGetterFor(ITERATOR_NAME);\n // add .keys, .values, .entries, [@@iterator]\n // 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11\n defineIterator(C, CONSTRUCTOR_NAME, function (iterated, kind) {\n setInternalState(this, {\n type: ITERATOR_NAME,\n target: iterated,\n state: getInternalCollectionState(iterated),\n kind: kind,\n last: undefined\n });\n }, function () {\n var state = getInternalIteratorState(this);\n var kind = state.kind;\n var entry = state.last;\n // revert to the last existing entry\n while (entry && entry.removed) entry = entry.previous;\n // get next entry\n if (!state.target || !(state.last = entry = entry ? entry.next : state.state.first)) {\n // or finish the iteration\n state.target = undefined;\n return { value: undefined, done: true };\n }\n // return step by kind\n if (kind == 'keys') return { value: entry.key, done: false };\n if (kind == 'values') return { value: entry.value, done: false };\n return { value: [entry.key, entry.value], done: false };\n }, IS_MAP ? 'entries' : 'values', !IS_MAP, true);\n\n // add [@@species], 23.1.2.2, 23.2.2.2\n setSpecies(CONSTRUCTOR_NAME);\n }\n};\n","'use strict';\nvar redefineAll = require('../internals/redefine-all');\nvar getWeakData = require('../internals/internal-metadata').getWeakData;\nvar anObject = require('../internals/an-object');\nvar isObject = require('../internals/is-object');\nvar anInstance = require('../internals/an-instance');\nvar iterate = require('../internals/iterate');\nvar ArrayIterationModule = require('../internals/array-iteration');\nvar $has = require('../internals/has');\nvar InternalStateModule = require('../internals/internal-state');\n\nvar setInternalState = InternalStateModule.set;\nvar internalStateGetterFor = InternalStateModule.getterFor;\nvar find = ArrayIterationModule.find;\nvar findIndex = ArrayIterationModule.findIndex;\nvar id = 0;\n\n// fallback for uncaught frozen keys\nvar uncaughtFrozenStore = function (store) {\n return store.frozen || (store.frozen = new UncaughtFrozenStore());\n};\n\nvar UncaughtFrozenStore = function () {\n this.entries = [];\n};\n\nvar findUncaughtFrozen = function (store, key) {\n return find(store.entries, function (it) {\n return it[0] === key;\n });\n};\n\nUncaughtFrozenStore.prototype = {\n get: function (key) {\n var entry = findUncaughtFrozen(this, key);\n if (entry) return entry[1];\n },\n has: function (key) {\n return !!findUncaughtFrozen(this, key);\n },\n set: function (key, value) {\n var entry = findUncaughtFrozen(this, key);\n if (entry) entry[1] = value;\n else this.entries.push([key, value]);\n },\n 'delete': function (key) {\n var index = findIndex(this.entries, function (it) {\n return it[0] === key;\n });\n if (~index) this.entries.splice(index, 1);\n return !!~index;\n }\n};\n\nmodule.exports = {\n getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {\n var C = wrapper(function (that, iterable) {\n anInstance(that, C, CONSTRUCTOR_NAME);\n setInternalState(that, {\n type: CONSTRUCTOR_NAME,\n id: id++,\n frozen: undefined\n });\n if (iterable != undefined) iterate(iterable, that[ADDER], that, IS_MAP);\n });\n\n var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);\n\n var define = function (that, key, value) {\n var state = getInternalState(that);\n var data = getWeakData(anObject(key), true);\n if (data === true) uncaughtFrozenStore(state).set(key, value);\n else data[state.id] = value;\n return that;\n };\n\n redefineAll(C.prototype, {\n // 23.3.3.2 WeakMap.prototype.delete(key)\n // 23.4.3.3 WeakSet.prototype.delete(value)\n 'delete': function (key) {\n var state = getInternalState(this);\n if (!isObject(key)) return false;\n var data = getWeakData(key);\n if (data === true) return uncaughtFrozenStore(state)['delete'](key);\n return data && $has(data, state.id) && delete data[state.id];\n },\n // 23.3.3.4 WeakMap.prototype.has(key)\n // 23.4.3.4 WeakSet.prototype.has(value)\n has: function has(key) {\n var state = getInternalState(this);\n if (!isObject(key)) return false;\n var data = getWeakData(key);\n if (data === true) return uncaughtFrozenStore(state).has(key);\n return data && $has(data, state.id);\n }\n });\n\n redefineAll(C.prototype, IS_MAP ? {\n // 23.3.3.3 WeakMap.prototype.get(key)\n get: function get(key) {\n var state = getInternalState(this);\n if (isObject(key)) {\n var data = getWeakData(key);\n if (data === true) return uncaughtFrozenStore(state).get(key);\n return data ? data[state.id] : undefined;\n }\n },\n // 23.3.3.5 WeakMap.prototype.set(key, value)\n set: function set(key, value) {\n return define(this, key, value);\n }\n } : {\n // 23.4.3.1 WeakSet.prototype.add(value)\n add: function add(value) {\n return define(this, value, true);\n }\n });\n\n return C;\n }\n};\n","'use strict';\nvar $ = require('../internals/export');\nvar global = require('../internals/global');\nvar isForced = require('../internals/is-forced');\nvar redefine = require('../internals/redefine');\nvar InternalMetadataModule = require('../internals/internal-metadata');\nvar iterate = require('../internals/iterate');\nvar anInstance = require('../internals/an-instance');\nvar isObject = require('../internals/is-object');\nvar fails = require('../internals/fails');\nvar checkCorrectnessOfIteration = require('../internals/check-correctness-of-iteration');\nvar setToStringTag = require('../internals/set-to-string-tag');\nvar inheritIfRequired = require('../internals/inherit-if-required');\n\nmodule.exports = function (CONSTRUCTOR_NAME, wrapper, common) {\n var IS_MAP = CONSTRUCTOR_NAME.indexOf('Map') !== -1;\n var IS_WEAK = CONSTRUCTOR_NAME.indexOf('Weak') !== -1;\n var ADDER = IS_MAP ? 'set' : 'add';\n var NativeConstructor = global[CONSTRUCTOR_NAME];\n var NativePrototype = NativeConstructor && NativeConstructor.prototype;\n var Constructor = NativeConstructor;\n var exported = {};\n\n var fixMethod = function (KEY) {\n var nativeMethod = NativePrototype[KEY];\n redefine(NativePrototype, KEY,\n KEY == 'add' ? function add(value) {\n nativeMethod.call(this, value === 0 ? 0 : value);\n return this;\n } : KEY == 'delete' ? function (key) {\n return IS_WEAK && !isObject(key) ? false : nativeMethod.call(this, key === 0 ? 0 : key);\n } : KEY == 'get' ? function get(key) {\n return IS_WEAK && !isObject(key) ? undefined : nativeMethod.call(this, key === 0 ? 0 : key);\n } : KEY == 'has' ? function has(key) {\n return IS_WEAK && !isObject(key) ? false : nativeMethod.call(this, key === 0 ? 0 : key);\n } : function set(key, value) {\n nativeMethod.call(this, key === 0 ? 0 : key, value);\n return this;\n }\n );\n };\n\n // eslint-disable-next-line max-len\n if (isForced(CONSTRUCTOR_NAME, typeof NativeConstructor != 'function' || !(IS_WEAK || NativePrototype.forEach && !fails(function () {\n new NativeConstructor().entries().next();\n })))) {\n // create collection constructor\n Constructor = common.getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER);\n InternalMetadataModule.REQUIRED = true;\n } else if (isForced(CONSTRUCTOR_NAME, true)) {\n var instance = new Constructor();\n // early implementations not supports chaining\n var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance;\n // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false\n var THROWS_ON_PRIMITIVES = fails(function () { instance.has(1); });\n // most early implementations doesn't supports iterables, most modern - not close it correctly\n // eslint-disable-next-line no-new\n var ACCEPT_ITERABLES = checkCorrectnessOfIteration(function (iterable) { new NativeConstructor(iterable); });\n // for early implementations -0 and +0 not the same\n var BUGGY_ZERO = !IS_WEAK && fails(function () {\n // V8 ~ Chromium 42- fails only with 5+ elements\n var $instance = new NativeConstructor();\n var index = 5;\n while (index--) $instance[ADDER](index, index);\n return !$instance.has(-0);\n });\n\n if (!ACCEPT_ITERABLES) {\n Constructor = wrapper(function (dummy, iterable) {\n anInstance(dummy, Constructor, CONSTRUCTOR_NAME);\n var that = inheritIfRequired(new NativeConstructor(), dummy, Constructor);\n if (iterable != undefined) iterate(iterable, that[ADDER], that, IS_MAP);\n return that;\n });\n Constructor.prototype = NativePrototype;\n NativePrototype.constructor = Constructor;\n }\n\n if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {\n fixMethod('delete');\n fixMethod('has');\n IS_MAP && fixMethod('get');\n }\n\n if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER);\n\n // weak collections should not contains .clear method\n if (IS_WEAK && NativePrototype.clear) delete NativePrototype.clear;\n }\n\n exported[CONSTRUCTOR_NAME] = Constructor;\n $({ global: true, forced: Constructor != NativeConstructor }, exported);\n\n setToStringTag(Constructor, CONSTRUCTOR_NAME);\n\n if (!IS_WEAK) common.setStrong(Constructor, CONSTRUCTOR_NAME, IS_MAP);\n\n return Constructor;\n};\n","// TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`\nvar Map = require('../modules/es.map');\nvar WeakMap = require('../modules/es.weak-map');\nvar create = require('../internals/object-create');\nvar isObject = require('../internals/is-object');\n\nvar Node = function () {\n // keys\n this.object = null;\n this.symbol = null;\n // child nodes\n this.primitives = null;\n this.objectsByIndex = create(null);\n};\n\nNode.prototype.get = function (key, initializer) {\n return this[key] || (this[key] = initializer());\n};\n\nNode.prototype.next = function (i, it, IS_OBJECT) {\n var store = IS_OBJECT\n ? this.objectsByIndex[i] || (this.objectsByIndex[i] = new WeakMap())\n : this.primitives || (this.primitives = new Map());\n var entry = store.get(it);\n if (!entry) store.set(it, entry = new Node());\n return entry;\n};\n\nvar root = new Node();\n\nmodule.exports = function () {\n var active = root;\n var length = arguments.length;\n var i, it;\n // for prevent leaking, start from objects\n for (i = 0; i < length; i++) {\n if (isObject(it = arguments[i])) active = active.next(i, it, true);\n }\n if (this === Object && active === root) throw TypeError('Composite keys must contain a non-primitive component');\n for (i = 0; i < length; i++) {\n if (!isObject(it = arguments[i])) active = active.next(i, it, false);\n } return active;\n};\n","var has = require('../internals/has');\nvar ownKeys = require('../internals/own-keys');\nvar getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');\nvar definePropertyModule = require('../internals/object-define-property');\n\nmodule.exports = function (target, source) {\n var keys = ownKeys(source);\n var defineProperty = definePropertyModule.f;\n var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n if (!has(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));\n }\n};\n","var wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar MATCH = wellKnownSymbol('match');\n\nmodule.exports = function (METHOD_NAME) {\n var regexp = /./;\n try {\n '/./'[METHOD_NAME](regexp);\n } catch (e) {\n try {\n regexp[MATCH] = false;\n return '/./'[METHOD_NAME](regexp);\n } catch (f) { /* empty */ }\n } return false;\n};\n","var fails = require('../internals/fails');\n\nmodule.exports = !fails(function () {\n function F() { /* empty */ }\n F.prototype.constructor = null;\n return Object.getPrototypeOf(new F()) !== F.prototype;\n});\n","var requireObjectCoercible = require('../internals/require-object-coercible');\n\nvar quot = /\"/g;\n\n// B.2.3.2.1 CreateHTML(string, tag, attribute, value)\n// https://tc39.github.io/ecma262/#sec-createhtml\nmodule.exports = function (string, tag, attribute, value) {\n var S = String(requireObjectCoercible(string));\n var p1 = '<' + tag;\n if (attribute !== '') p1 += ' ' + attribute + '=\"' + String(value).replace(quot, '"') + '\"';\n return p1 + '>' + S + '';\n};\n","'use strict';\nvar IteratorPrototype = require('../internals/iterators-core').IteratorPrototype;\nvar create = require('../internals/object-create');\nvar createPropertyDescriptor = require('../internals/create-property-descriptor');\nvar setToStringTag = require('../internals/set-to-string-tag');\nvar Iterators = require('../internals/iterators');\n\nvar returnThis = function () { return this; };\n\nmodule.exports = function (IteratorConstructor, NAME, next) {\n var TO_STRING_TAG = NAME + ' Iterator';\n IteratorConstructor.prototype = create(IteratorPrototype, { next: createPropertyDescriptor(1, next) });\n setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true);\n Iterators[TO_STRING_TAG] = returnThis;\n return IteratorConstructor;\n};\n","var DESCRIPTORS = require('../internals/descriptors');\nvar definePropertyModule = require('../internals/object-define-property');\nvar createPropertyDescriptor = require('../internals/create-property-descriptor');\n\nmodule.exports = DESCRIPTORS ? function (object, key, value) {\n return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));\n} : function (object, key, value) {\n object[key] = value;\n return object;\n};\n","module.exports = function (bitmap, value) {\n return {\n enumerable: !(bitmap & 1),\n configurable: !(bitmap & 2),\n writable: !(bitmap & 4),\n value: value\n };\n};\n","'use strict';\nvar toPrimitive = require('../internals/to-primitive');\nvar definePropertyModule = require('../internals/object-define-property');\nvar createPropertyDescriptor = require('../internals/create-property-descriptor');\n\nmodule.exports = function (object, key, value) {\n var propertyKey = toPrimitive(key);\n if (propertyKey in object) definePropertyModule.f(object, propertyKey, createPropertyDescriptor(0, value));\n else object[propertyKey] = value;\n};\n","'use strict';\nvar anObject = require('../internals/an-object');\nvar toPrimitive = require('../internals/to-primitive');\n\nmodule.exports = function (hint) {\n if (hint !== 'string' && hint !== 'number' && hint !== 'default') {\n throw TypeError('Incorrect hint');\n } return toPrimitive(anObject(this), hint !== 'number');\n};\n","'use strict';\nvar $ = require('../internals/export');\nvar createIteratorConstructor = require('../internals/create-iterator-constructor');\nvar getPrototypeOf = require('../internals/object-get-prototype-of');\nvar setPrototypeOf = require('../internals/object-set-prototype-of');\nvar setToStringTag = require('../internals/set-to-string-tag');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar redefine = require('../internals/redefine');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar IS_PURE = require('../internals/is-pure');\nvar Iterators = require('../internals/iterators');\nvar IteratorsCore = require('../internals/iterators-core');\n\nvar IteratorPrototype = IteratorsCore.IteratorPrototype;\nvar BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;\nvar ITERATOR = wellKnownSymbol('iterator');\nvar KEYS = 'keys';\nvar VALUES = 'values';\nvar ENTRIES = 'entries';\n\nvar returnThis = function () { return this; };\n\nmodule.exports = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {\n createIteratorConstructor(IteratorConstructor, NAME, next);\n\n var getIterationMethod = function (KIND) {\n if (KIND === DEFAULT && defaultIterator) return defaultIterator;\n if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype) return IterablePrototype[KIND];\n switch (KIND) {\n case KEYS: return function keys() { return new IteratorConstructor(this, KIND); };\n case VALUES: return function values() { return new IteratorConstructor(this, KIND); };\n case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); };\n } return function () { return new IteratorConstructor(this); };\n };\n\n var TO_STRING_TAG = NAME + ' Iterator';\n var INCORRECT_VALUES_NAME = false;\n var IterablePrototype = Iterable.prototype;\n var nativeIterator = IterablePrototype[ITERATOR]\n || IterablePrototype['@@iterator']\n || DEFAULT && IterablePrototype[DEFAULT];\n var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);\n var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;\n var CurrentIteratorPrototype, methods, KEY;\n\n // fix native\n if (anyNativeIterator) {\n CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable()));\n if (IteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {\n if (!IS_PURE && getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {\n if (setPrototypeOf) {\n setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);\n } else if (typeof CurrentIteratorPrototype[ITERATOR] != 'function') {\n createNonEnumerableProperty(CurrentIteratorPrototype, ITERATOR, returnThis);\n }\n }\n // Set @@toStringTag to native iterators\n setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true);\n if (IS_PURE) Iterators[TO_STRING_TAG] = returnThis;\n }\n }\n\n // fix Array#{values, @@iterator}.name in V8 / FF\n if (DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {\n INCORRECT_VALUES_NAME = true;\n defaultIterator = function values() { return nativeIterator.call(this); };\n }\n\n // define iterator\n if ((!IS_PURE || FORCED) && IterablePrototype[ITERATOR] !== defaultIterator) {\n createNonEnumerableProperty(IterablePrototype, ITERATOR, defaultIterator);\n }\n Iterators[NAME] = defaultIterator;\n\n // export additional methods\n if (DEFAULT) {\n methods = {\n values: getIterationMethod(VALUES),\n keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),\n entries: getIterationMethod(ENTRIES)\n };\n if (FORCED) for (KEY in methods) {\n if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {\n redefine(IterablePrototype, KEY, methods[KEY]);\n }\n } else $({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);\n }\n\n return methods;\n};\n","var path = require('../internals/path');\nvar has = require('../internals/has');\nvar wrappedWellKnownSymbolModule = require('../internals/well-known-symbol-wrapped');\nvar defineProperty = require('../internals/object-define-property').f;\n\nmodule.exports = function (NAME) {\n var Symbol = path.Symbol || (path.Symbol = {});\n if (!has(Symbol, NAME)) defineProperty(Symbol, NAME, {\n value: wrappedWellKnownSymbolModule.f(NAME)\n });\n};\n","var fails = require('../internals/fails');\n\n// Thank's IE8 for his funny defineProperty\nmodule.exports = !fails(function () {\n return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;\n});\n","var global = require('../internals/global');\nvar isObject = require('../internals/is-object');\n\nvar document = global.document;\n// typeof document.createElement is 'object' in old IE\nvar EXISTS = isObject(document) && isObject(document.createElement);\n\nmodule.exports = function (it) {\n return EXISTS ? document.createElement(it) : {};\n};\n","// iterable DOM collections\n// flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods\nmodule.exports = {\n CSSRuleList: 0,\n CSSStyleDeclaration: 0,\n CSSValueList: 0,\n ClientRectList: 0,\n DOMRectList: 0,\n DOMStringList: 0,\n DOMTokenList: 1,\n DataTransferItemList: 0,\n FileList: 0,\n HTMLAllCollection: 0,\n HTMLCollection: 0,\n HTMLFormElement: 0,\n HTMLSelectElement: 0,\n MediaList: 0,\n MimeTypeArray: 0,\n NamedNodeMap: 0,\n NodeList: 1,\n PaintRequestList: 0,\n Plugin: 0,\n PluginArray: 0,\n SVGLengthList: 0,\n SVGNumberList: 0,\n SVGPathSegList: 0,\n SVGPointList: 0,\n SVGStringList: 0,\n SVGTransformList: 0,\n SourceBufferList: 0,\n StyleSheetList: 0,\n TextTrackCueList: 0,\n TextTrackList: 0,\n TouchList: 0\n};\n","var userAgent = require('../internals/engine-user-agent');\n\nmodule.exports = /(iphone|ipod|ipad).*applewebkit/i.test(userAgent);\n","var getBuiltIn = require('../internals/get-built-in');\n\nmodule.exports = getBuiltIn('navigator', 'userAgent') || '';\n","var global = require('../internals/global');\nvar userAgent = require('../internals/engine-user-agent');\n\nvar process = global.process;\nvar versions = process && process.versions;\nvar v8 = versions && versions.v8;\nvar match, version;\n\nif (v8) {\n match = v8.split('.');\n version = match[0] + match[1];\n} else if (userAgent) {\n match = userAgent.match(/Edge\\/(\\d+)/);\n if (!match || match[1] >= 74) {\n match = userAgent.match(/Chrome\\/(\\d+)/);\n if (match) version = match[1];\n }\n}\n\nmodule.exports = version && +version;\n","// IE8- don't enum bug keys\nmodule.exports = [\n 'constructor',\n 'hasOwnProperty',\n 'isPrototypeOf',\n 'propertyIsEnumerable',\n 'toLocaleString',\n 'toString',\n 'valueOf'\n];\n","var global = require('../internals/global');\nvar getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar redefine = require('../internals/redefine');\nvar setGlobal = require('../internals/set-global');\nvar copyConstructorProperties = require('../internals/copy-constructor-properties');\nvar isForced = require('../internals/is-forced');\n\n/*\n options.target - name of the target object\n options.global - target is the global object\n options.stat - export as static methods of target\n options.proto - export as prototype methods of target\n options.real - real prototype method for the `pure` version\n options.forced - export even if the native feature is available\n options.bind - bind methods to the target, required for the `pure` version\n options.wrap - wrap constructors to preventing global pollution, required for the `pure` version\n options.unsafe - use the simple assignment of property instead of delete + defineProperty\n options.sham - add a flag to not completely full polyfills\n options.enumerable - export as enumerable property\n options.noTargetGet - prevent calling a getter on target\n*/\nmodule.exports = function (options, source) {\n var TARGET = options.target;\n var GLOBAL = options.global;\n var STATIC = options.stat;\n var FORCED, target, key, targetProperty, sourceProperty, descriptor;\n if (GLOBAL) {\n target = global;\n } else if (STATIC) {\n target = global[TARGET] || setGlobal(TARGET, {});\n } else {\n target = (global[TARGET] || {}).prototype;\n }\n if (target) for (key in source) {\n sourceProperty = source[key];\n if (options.noTargetGet) {\n descriptor = getOwnPropertyDescriptor(target, key);\n targetProperty = descriptor && descriptor.value;\n } else targetProperty = target[key];\n FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);\n // contained in target\n if (!FORCED && targetProperty !== undefined) {\n if (typeof sourceProperty === typeof targetProperty) continue;\n copyConstructorProperties(sourceProperty, targetProperty);\n }\n // add a flag to not completely full polyfills\n if (options.sham || (targetProperty && targetProperty.sham)) {\n createNonEnumerableProperty(sourceProperty, 'sham', true);\n }\n // extend global\n redefine(target, key, sourceProperty, options);\n }\n};\n","module.exports = function (exec) {\n try {\n return !!exec();\n } catch (error) {\n return true;\n }\n};\n","'use strict';\n// TODO: Remove from `core-js@4` since it's moved to entry points\nrequire('../modules/es.regexp.exec');\nvar redefine = require('../internals/redefine');\nvar fails = require('../internals/fails');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar regexpExec = require('../internals/regexp-exec');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\n\nvar SPECIES = wellKnownSymbol('species');\n\nvar REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {\n // #replace needs built-in support for named groups.\n // #match works fine because it just return the exec results, even if it has\n // a \"grops\" property.\n var re = /./;\n re.exec = function () {\n var result = [];\n result.groups = { a: '7' };\n return result;\n };\n return ''.replace(re, '$') !== '7';\n});\n\n// IE <= 11 replaces $0 with the whole match, as if it was $&\n// https://stackoverflow.com/questions/6024666/getting-ie-to-replace-a-regex-with-the-literal-string-0\nvar REPLACE_KEEPS_$0 = (function () {\n return 'a'.replace(/./, '$0') === '$0';\n})();\n\nvar REPLACE = wellKnownSymbol('replace');\n// Safari <= 13.0.3(?) substitutes nth capture where n>m with an empty string\nvar REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = (function () {\n if (/./[REPLACE]) {\n return /./[REPLACE]('a', '$0') === '';\n }\n return false;\n})();\n\n// Chrome 51 has a buggy \"split\" implementation when RegExp#exec !== nativeExec\n// Weex JS has frozen built-in prototypes, so use try / catch wrapper\nvar SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () {\n var re = /(?:)/;\n var originalExec = re.exec;\n re.exec = function () { return originalExec.apply(this, arguments); };\n var result = 'ab'.split(re);\n return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';\n});\n\nmodule.exports = function (KEY, length, exec, sham) {\n var SYMBOL = wellKnownSymbol(KEY);\n\n var DELEGATES_TO_SYMBOL = !fails(function () {\n // String methods call symbol-named RegEp methods\n var O = {};\n O[SYMBOL] = function () { return 7; };\n return ''[KEY](O) != 7;\n });\n\n var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails(function () {\n // Symbol-named RegExp methods call .exec\n var execCalled = false;\n var re = /a/;\n\n if (KEY === 'split') {\n // We can't use real regex here since it causes deoptimization\n // and serious performance degradation in V8\n // https://github.com/zloirock/core-js/issues/306\n re = {};\n // RegExp[@@split] doesn't call the regex's exec method, but first creates\n // a new one. We need to return the patched regex when creating the new one.\n re.constructor = {};\n re.constructor[SPECIES] = function () { return re; };\n re.flags = '';\n re[SYMBOL] = /./[SYMBOL];\n }\n\n re.exec = function () { execCalled = true; return null; };\n\n re[SYMBOL]('');\n return !execCalled;\n });\n\n if (\n !DELEGATES_TO_SYMBOL ||\n !DELEGATES_TO_EXEC ||\n (KEY === 'replace' && !(\n REPLACE_SUPPORTS_NAMED_GROUPS &&\n REPLACE_KEEPS_$0 &&\n !REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE\n )) ||\n (KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC)\n ) {\n var nativeRegExpMethod = /./[SYMBOL];\n var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {\n if (regexp.exec === regexpExec) {\n if (DELEGATES_TO_SYMBOL && !forceStringMethod) {\n // The native String method already delegates to @@method (this\n // polyfilled function), leasing to infinite recursion.\n // We avoid it by directly calling the native @@method method.\n return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) };\n }\n return { done: true, value: nativeMethod.call(str, regexp, arg2) };\n }\n return { done: false };\n }, {\n REPLACE_KEEPS_$0: REPLACE_KEEPS_$0,\n REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE: REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE\n });\n var stringMethod = methods[0];\n var regexMethod = methods[1];\n\n redefine(String.prototype, KEY, stringMethod);\n redefine(RegExp.prototype, SYMBOL, length == 2\n // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)\n // 21.2.5.11 RegExp.prototype[@@split](string, limit)\n ? function (string, arg) { return regexMethod.call(string, this, arg); }\n // 21.2.5.6 RegExp.prototype[@@match](string)\n // 21.2.5.9 RegExp.prototype[@@search](string)\n : function (string) { return regexMethod.call(string, this); }\n );\n }\n\n if (sham) createNonEnumerableProperty(RegExp.prototype[SYMBOL], 'sham', true);\n};\n","'use strict';\nvar isArray = require('../internals/is-array');\nvar toLength = require('../internals/to-length');\nvar bind = require('../internals/function-bind-context');\n\n// `FlattenIntoArray` abstract operation\n// https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray\nvar flattenIntoArray = function (target, original, source, sourceLen, start, depth, mapper, thisArg) {\n var targetIndex = start;\n var sourceIndex = 0;\n var mapFn = mapper ? bind(mapper, thisArg, 3) : false;\n var element;\n\n while (sourceIndex < sourceLen) {\n if (sourceIndex in source) {\n element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex];\n\n if (depth > 0 && isArray(element)) {\n targetIndex = flattenIntoArray(target, original, element, toLength(element.length), targetIndex, depth - 1) - 1;\n } else {\n if (targetIndex >= 0x1FFFFFFFFFFFFF) throw TypeError('Exceed the acceptable array length');\n target[targetIndex] = element;\n }\n\n targetIndex++;\n }\n sourceIndex++;\n }\n return targetIndex;\n};\n\nmodule.exports = flattenIntoArray;\n","var fails = require('../internals/fails');\n\nmodule.exports = !fails(function () {\n return Object.isExtensible(Object.preventExtensions({}));\n});\n","var aFunction = require('../internals/a-function');\n\n// optional / simple context binding\nmodule.exports = function (fn, that, length) {\n aFunction(fn);\n if (that === undefined) return fn;\n switch (length) {\n case 0: return function () {\n return fn.call(that);\n };\n case 1: return function (a) {\n return fn.call(that, a);\n };\n case 2: return function (a, b) {\n return fn.call(that, a, b);\n };\n case 3: return function (a, b, c) {\n return fn.call(that, a, b, c);\n };\n }\n return function (/* ...args */) {\n return fn.apply(that, arguments);\n };\n};\n","'use strict';\nvar aFunction = require('../internals/a-function');\nvar isObject = require('../internals/is-object');\n\nvar slice = [].slice;\nvar factories = {};\n\nvar construct = function (C, argsLength, args) {\n if (!(argsLength in factories)) {\n for (var list = [], i = 0; i < argsLength; i++) list[i] = 'a[' + i + ']';\n // eslint-disable-next-line no-new-func\n factories[argsLength] = Function('C,a', 'return new C(' + list.join(',') + ')');\n } return factories[argsLength](C, args);\n};\n\n// `Function.prototype.bind` method implementation\n// https://tc39.github.io/ecma262/#sec-function.prototype.bind\nmodule.exports = Function.bind || function bind(that /* , ...args */) {\n var fn = aFunction(this);\n var partArgs = slice.call(arguments, 1);\n var boundFunction = function bound(/* args... */) {\n var args = partArgs.concat(slice.call(arguments));\n return this instanceof boundFunction ? construct(fn, args.length, args) : fn.apply(that, args);\n };\n if (isObject(fn.prototype)) boundFunction.prototype = fn.prototype;\n return boundFunction;\n};\n","var path = require('../internals/path');\nvar global = require('../internals/global');\n\nvar aFunction = function (variable) {\n return typeof variable == 'function' ? variable : undefined;\n};\n\nmodule.exports = function (namespace, method) {\n return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global[namespace])\n : path[namespace] && path[namespace][method] || global[namespace] && global[namespace][method];\n};\n","var classof = require('../internals/classof');\nvar Iterators = require('../internals/iterators');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar ITERATOR = wellKnownSymbol('iterator');\n\nmodule.exports = function (it) {\n if (it != undefined) return it[ITERATOR]\n || it['@@iterator']\n || Iterators[classof(it)];\n};\n","var anObject = require('../internals/an-object');\nvar getIteratorMethod = require('../internals/get-iterator-method');\n\nmodule.exports = function (it) {\n var iteratorMethod = getIteratorMethod(it);\n if (typeof iteratorMethod != 'function') {\n throw TypeError(String(it) + ' is not iterable');\n } return anObject(iteratorMethod.call(it));\n};\n","var IS_PURE = require('../internals/is-pure');\nvar getIterator = require('../internals/get-iterator');\n\nmodule.exports = IS_PURE ? getIterator : function (it) {\n // eslint-disable-next-line no-undef\n return Map.prototype.entries.call(it);\n};\n","var IS_PURE = require('../internals/is-pure');\nvar getIterator = require('../internals/get-iterator');\n\nmodule.exports = IS_PURE ? getIterator : function (it) {\n // eslint-disable-next-line no-undef\n return Set.prototype.values.call(it);\n};\n","var check = function (it) {\n return it && it.Math == Math && it;\n};\n\n// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028\nmodule.exports =\n // eslint-disable-next-line no-undef\n check(typeof globalThis == 'object' && globalThis) ||\n check(typeof window == 'object' && window) ||\n check(typeof self == 'object' && self) ||\n check(typeof global == 'object' && global) ||\n // eslint-disable-next-line no-new-func\n Function('return this')();\n","var hasOwnProperty = {}.hasOwnProperty;\n\nmodule.exports = function (it, key) {\n return hasOwnProperty.call(it, key);\n};\n","module.exports = {};\n","var global = require('../internals/global');\n\nmodule.exports = function (a, b) {\n var console = global.console;\n if (console && console.error) {\n arguments.length === 1 ? console.error(a) : console.error(a, b);\n }\n};\n","var getBuiltIn = require('../internals/get-built-in');\n\nmodule.exports = getBuiltIn('document', 'documentElement');\n","var DESCRIPTORS = require('../internals/descriptors');\nvar fails = require('../internals/fails');\nvar createElement = require('../internals/document-create-element');\n\n// Thank's IE8 for his funny defineProperty\nmodule.exports = !DESCRIPTORS && !fails(function () {\n return Object.defineProperty(createElement('div'), 'a', {\n get: function () { return 7; }\n }).a != 7;\n});\n","// IEEE754 conversions based on https://github.com/feross/ieee754\n// eslint-disable-next-line no-shadow-restricted-names\nvar Infinity = 1 / 0;\nvar abs = Math.abs;\nvar pow = Math.pow;\nvar floor = Math.floor;\nvar log = Math.log;\nvar LN2 = Math.LN2;\n\nvar pack = function (number, mantissaLength, bytes) {\n var buffer = new Array(bytes);\n var exponentLength = bytes * 8 - mantissaLength - 1;\n var eMax = (1 << exponentLength) - 1;\n var eBias = eMax >> 1;\n var rt = mantissaLength === 23 ? pow(2, -24) - pow(2, -77) : 0;\n var sign = number < 0 || number === 0 && 1 / number < 0 ? 1 : 0;\n var index = 0;\n var exponent, mantissa, c;\n number = abs(number);\n // eslint-disable-next-line no-self-compare\n if (number != number || number === Infinity) {\n // eslint-disable-next-line no-self-compare\n mantissa = number != number ? 1 : 0;\n exponent = eMax;\n } else {\n exponent = floor(log(number) / LN2);\n if (number * (c = pow(2, -exponent)) < 1) {\n exponent--;\n c *= 2;\n }\n if (exponent + eBias >= 1) {\n number += rt / c;\n } else {\n number += rt * pow(2, 1 - eBias);\n }\n if (number * c >= 2) {\n exponent++;\n c /= 2;\n }\n if (exponent + eBias >= eMax) {\n mantissa = 0;\n exponent = eMax;\n } else if (exponent + eBias >= 1) {\n mantissa = (number * c - 1) * pow(2, mantissaLength);\n exponent = exponent + eBias;\n } else {\n mantissa = number * pow(2, eBias - 1) * pow(2, mantissaLength);\n exponent = 0;\n }\n }\n for (; mantissaLength >= 8; buffer[index++] = mantissa & 255, mantissa /= 256, mantissaLength -= 8);\n exponent = exponent << mantissaLength | mantissa;\n exponentLength += mantissaLength;\n for (; exponentLength > 0; buffer[index++] = exponent & 255, exponent /= 256, exponentLength -= 8);\n buffer[--index] |= sign * 128;\n return buffer;\n};\n\nvar unpack = function (buffer, mantissaLength) {\n var bytes = buffer.length;\n var exponentLength = bytes * 8 - mantissaLength - 1;\n var eMax = (1 << exponentLength) - 1;\n var eBias = eMax >> 1;\n var nBits = exponentLength - 7;\n var index = bytes - 1;\n var sign = buffer[index--];\n var exponent = sign & 127;\n var mantissa;\n sign >>= 7;\n for (; nBits > 0; exponent = exponent * 256 + buffer[index], index--, nBits -= 8);\n mantissa = exponent & (1 << -nBits) - 1;\n exponent >>= -nBits;\n nBits += mantissaLength;\n for (; nBits > 0; mantissa = mantissa * 256 + buffer[index], index--, nBits -= 8);\n if (exponent === 0) {\n exponent = 1 - eBias;\n } else if (exponent === eMax) {\n return mantissa ? NaN : sign ? -Infinity : Infinity;\n } else {\n mantissa = mantissa + pow(2, mantissaLength);\n exponent = exponent - eBias;\n } return (sign ? -1 : 1) * mantissa * pow(2, exponent - mantissaLength);\n};\n\nmodule.exports = {\n pack: pack,\n unpack: unpack\n};\n","var fails = require('../internals/fails');\nvar classof = require('../internals/classof-raw');\n\nvar split = ''.split;\n\n// fallback for non-array-like ES3 and non-enumerable old V8 strings\nmodule.exports = fails(function () {\n // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346\n // eslint-disable-next-line no-prototype-builtins\n return !Object('z').propertyIsEnumerable(0);\n}) ? function (it) {\n return classof(it) == 'String' ? split.call(it, '') : Object(it);\n} : Object;\n","var isObject = require('../internals/is-object');\nvar setPrototypeOf = require('../internals/object-set-prototype-of');\n\n// makes subclassing work correct for wrapped built-ins\nmodule.exports = function ($this, dummy, Wrapper) {\n var NewTarget, NewTargetPrototype;\n if (\n // it can work only with native `setPrototypeOf`\n setPrototypeOf &&\n // we haven't completely correct pre-ES6 way for getting `new.target`, so use this\n typeof (NewTarget = dummy.constructor) == 'function' &&\n NewTarget !== Wrapper &&\n isObject(NewTargetPrototype = NewTarget.prototype) &&\n NewTargetPrototype !== Wrapper.prototype\n ) setPrototypeOf($this, NewTargetPrototype);\n return $this;\n};\n","var store = require('../internals/shared-store');\n\nvar functionToString = Function.toString;\n\n// this helper broken in `3.4.1-3.4.4`, so we can't use `shared` helper\nif (typeof store.inspectSource != 'function') {\n store.inspectSource = function (it) {\n return functionToString.call(it);\n };\n}\n\nmodule.exports = store.inspectSource;\n","var hiddenKeys = require('../internals/hidden-keys');\nvar isObject = require('../internals/is-object');\nvar has = require('../internals/has');\nvar defineProperty = require('../internals/object-define-property').f;\nvar uid = require('../internals/uid');\nvar FREEZING = require('../internals/freezing');\n\nvar METADATA = uid('meta');\nvar id = 0;\n\nvar isExtensible = Object.isExtensible || function () {\n return true;\n};\n\nvar setMetadata = function (it) {\n defineProperty(it, METADATA, { value: {\n objectID: 'O' + ++id, // object ID\n weakData: {} // weak collections IDs\n } });\n};\n\nvar fastKey = function (it, create) {\n // return a primitive with prefix\n if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;\n if (!has(it, METADATA)) {\n // can't set metadata to uncaught frozen object\n if (!isExtensible(it)) return 'F';\n // not necessary to add metadata\n if (!create) return 'E';\n // add missing metadata\n setMetadata(it);\n // return object ID\n } return it[METADATA].objectID;\n};\n\nvar getWeakData = function (it, create) {\n if (!has(it, METADATA)) {\n // can't set metadata to uncaught frozen object\n if (!isExtensible(it)) return true;\n // not necessary to add metadata\n if (!create) return false;\n // add missing metadata\n setMetadata(it);\n // return the store of weak collections IDs\n } return it[METADATA].weakData;\n};\n\n// add metadata on freeze-family methods calling\nvar onFreeze = function (it) {\n if (FREEZING && meta.REQUIRED && isExtensible(it) && !has(it, METADATA)) setMetadata(it);\n return it;\n};\n\nvar meta = module.exports = {\n REQUIRED: false,\n fastKey: fastKey,\n getWeakData: getWeakData,\n onFreeze: onFreeze\n};\n\nhiddenKeys[METADATA] = true;\n","var NATIVE_WEAK_MAP = require('../internals/native-weak-map');\nvar global = require('../internals/global');\nvar isObject = require('../internals/is-object');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar objectHas = require('../internals/has');\nvar sharedKey = require('../internals/shared-key');\nvar hiddenKeys = require('../internals/hidden-keys');\n\nvar WeakMap = global.WeakMap;\nvar set, get, has;\n\nvar enforce = function (it) {\n return has(it) ? get(it) : set(it, {});\n};\n\nvar getterFor = function (TYPE) {\n return function (it) {\n var state;\n if (!isObject(it) || (state = get(it)).type !== TYPE) {\n throw TypeError('Incompatible receiver, ' + TYPE + ' required');\n } return state;\n };\n};\n\nif (NATIVE_WEAK_MAP) {\n var store = new WeakMap();\n var wmget = store.get;\n var wmhas = store.has;\n var wmset = store.set;\n set = function (it, metadata) {\n wmset.call(store, it, metadata);\n return metadata;\n };\n get = function (it) {\n return wmget.call(store, it) || {};\n };\n has = function (it) {\n return wmhas.call(store, it);\n };\n} else {\n var STATE = sharedKey('state');\n hiddenKeys[STATE] = true;\n set = function (it, metadata) {\n createNonEnumerableProperty(it, STATE, metadata);\n return metadata;\n };\n get = function (it) {\n return objectHas(it, STATE) ? it[STATE] : {};\n };\n has = function (it) {\n return objectHas(it, STATE);\n };\n}\n\nmodule.exports = {\n set: set,\n get: get,\n has: has,\n enforce: enforce,\n getterFor: getterFor\n};\n","var wellKnownSymbol = require('../internals/well-known-symbol');\nvar Iterators = require('../internals/iterators');\n\nvar ITERATOR = wellKnownSymbol('iterator');\nvar ArrayPrototype = Array.prototype;\n\n// check on default Array iterator\nmodule.exports = function (it) {\n return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it);\n};\n","var classof = require('../internals/classof-raw');\n\n// `IsArray` abstract operation\n// https://tc39.github.io/ecma262/#sec-isarray\nmodule.exports = Array.isArray || function isArray(arg) {\n return classof(arg) == 'Array';\n};\n","var fails = require('../internals/fails');\n\nvar replacement = /#|\\.prototype\\./;\n\nvar isForced = function (feature, detection) {\n var value = data[normalize(feature)];\n return value == POLYFILL ? true\n : value == NATIVE ? false\n : typeof detection == 'function' ? fails(detection)\n : !!detection;\n};\n\nvar normalize = isForced.normalize = function (string) {\n return String(string).replace(replacement, '.').toLowerCase();\n};\n\nvar data = isForced.data = {};\nvar NATIVE = isForced.NATIVE = 'N';\nvar POLYFILL = isForced.POLYFILL = 'P';\n\nmodule.exports = isForced;\n","var isObject = require('../internals/is-object');\n\nvar floor = Math.floor;\n\n// `Number.isInteger` method implementation\n// https://tc39.github.io/ecma262/#sec-number.isinteger\nmodule.exports = function isInteger(it) {\n return !isObject(it) && isFinite(it) && floor(it) === it;\n};\n","module.exports = function (it) {\n return typeof it === 'object' ? it !== null : typeof it === 'function';\n};\n","module.exports = false;\n","var isObject = require('../internals/is-object');\nvar classof = require('../internals/classof-raw');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar MATCH = wellKnownSymbol('match');\n\n// `IsRegExp` abstract operation\n// https://tc39.github.io/ecma262/#sec-isregexp\nmodule.exports = function (it) {\n var isRegExp;\n return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classof(it) == 'RegExp');\n};\n","var anObject = require('../internals/an-object');\nvar isArrayIteratorMethod = require('../internals/is-array-iterator-method');\nvar toLength = require('../internals/to-length');\nvar bind = require('../internals/function-bind-context');\nvar getIteratorMethod = require('../internals/get-iterator-method');\nvar callWithSafeIterationClosing = require('../internals/call-with-safe-iteration-closing');\n\nvar Result = function (stopped, result) {\n this.stopped = stopped;\n this.result = result;\n};\n\nvar iterate = module.exports = function (iterable, fn, that, AS_ENTRIES, IS_ITERATOR) {\n var boundFunction = bind(fn, that, AS_ENTRIES ? 2 : 1);\n var iterator, iterFn, index, length, result, next, step;\n\n if (IS_ITERATOR) {\n iterator = iterable;\n } else {\n iterFn = getIteratorMethod(iterable);\n if (typeof iterFn != 'function') throw TypeError('Target is not iterable');\n // optimisation for array iterators\n if (isArrayIteratorMethod(iterFn)) {\n for (index = 0, length = toLength(iterable.length); length > index; index++) {\n result = AS_ENTRIES\n ? boundFunction(anObject(step = iterable[index])[0], step[1])\n : boundFunction(iterable[index]);\n if (result && result instanceof Result) return result;\n } return new Result(false);\n }\n iterator = iterFn.call(iterable);\n }\n\n next = iterator.next;\n while (!(step = next.call(iterator)).done) {\n result = callWithSafeIterationClosing(iterator, boundFunction, step.value, AS_ENTRIES);\n if (typeof result == 'object' && result && result instanceof Result) return result;\n } return new Result(false);\n};\n\niterate.stop = function (result) {\n return new Result(true, result);\n};\n","'use strict';\nvar getPrototypeOf = require('../internals/object-get-prototype-of');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar has = require('../internals/has');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar IS_PURE = require('../internals/is-pure');\n\nvar ITERATOR = wellKnownSymbol('iterator');\nvar BUGGY_SAFARI_ITERATORS = false;\n\nvar returnThis = function () { return this; };\n\n// `%IteratorPrototype%` object\n// https://tc39.github.io/ecma262/#sec-%iteratorprototype%-object\nvar IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;\n\nif ([].keys) {\n arrayIterator = [].keys();\n // Safari 8 has buggy iterators w/o `next`\n if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;\n else {\n PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator));\n if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype;\n }\n}\n\nif (IteratorPrototype == undefined) IteratorPrototype = {};\n\n// 25.1.2.1.1 %IteratorPrototype%[@@iterator]()\nif (!IS_PURE && !has(IteratorPrototype, ITERATOR)) {\n createNonEnumerableProperty(IteratorPrototype, ITERATOR, returnThis);\n}\n\nmodule.exports = {\n IteratorPrototype: IteratorPrototype,\n BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS\n};\n","module.exports = {};\n","var nativeExpm1 = Math.expm1;\nvar exp = Math.exp;\n\n// `Math.expm1` method implementation\n// https://tc39.github.io/ecma262/#sec-math.expm1\nmodule.exports = (!nativeExpm1\n // Old FF bug\n || nativeExpm1(10) > 22025.465794806719 || nativeExpm1(10) < 22025.4657948067165168\n // Tor Browser bug\n || nativeExpm1(-2e-17) != -2e-17\n) ? function expm1(x) {\n return (x = +x) == 0 ? x : x > -1e-6 && x < 1e-6 ? x + x * x / 2 : exp(x) - 1;\n} : nativeExpm1;\n","var sign = require('../internals/math-sign');\n\nvar abs = Math.abs;\nvar pow = Math.pow;\nvar EPSILON = pow(2, -52);\nvar EPSILON32 = pow(2, -23);\nvar MAX32 = pow(2, 127) * (2 - EPSILON32);\nvar MIN32 = pow(2, -126);\n\nvar roundTiesToEven = function (n) {\n return n + 1 / EPSILON - 1 / EPSILON;\n};\n\n// `Math.fround` method implementation\n// https://tc39.github.io/ecma262/#sec-math.fround\nmodule.exports = Math.fround || function fround(x) {\n var $abs = abs(x);\n var $sign = sign(x);\n var a, result;\n if ($abs < MIN32) return $sign * roundTiesToEven($abs / MIN32 / EPSILON32) * MIN32 * EPSILON32;\n a = (1 + EPSILON32 / EPSILON) * $abs;\n result = a - (a - $abs);\n // eslint-disable-next-line no-self-compare\n if (result > MAX32 || result != result) return $sign * Infinity;\n return $sign * result;\n};\n","var log = Math.log;\n\n// `Math.log1p` method implementation\n// https://tc39.github.io/ecma262/#sec-math.log1p\nmodule.exports = Math.log1p || function log1p(x) {\n return (x = +x) > -1e-8 && x < 1e-8 ? x - x * x / 2 : log(1 + x);\n};\n","// `Math.scale` method implementation\n// https://rwaldron.github.io/proposal-math-extensions/\nmodule.exports = Math.scale || function scale(x, inLow, inHigh, outLow, outHigh) {\n if (\n arguments.length === 0\n /* eslint-disable no-self-compare */\n || x != x\n || inLow != inLow\n || inHigh != inHigh\n || outLow != outLow\n || outHigh != outHigh\n /* eslint-enable no-self-compare */\n ) return NaN;\n if (x === Infinity || x === -Infinity) return x;\n return (x - inLow) * (outHigh - outLow) / (inHigh - inLow) + outLow;\n};\n","// `Math.sign` method implementation\n// https://tc39.github.io/ecma262/#sec-math.sign\nmodule.exports = Math.sign || function sign(x) {\n // eslint-disable-next-line no-self-compare\n return (x = +x) == 0 || x != x ? x : x < 0 ? -1 : 1;\n};\n","var global = require('../internals/global');\nvar getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;\nvar classof = require('../internals/classof-raw');\nvar macrotask = require('../internals/task').set;\nvar IS_IOS = require('../internals/engine-is-ios');\n\nvar MutationObserver = global.MutationObserver || global.WebKitMutationObserver;\nvar process = global.process;\nvar Promise = global.Promise;\nvar IS_NODE = classof(process) == 'process';\n// Node.js 11 shows ExperimentalWarning on getting `queueMicrotask`\nvar queueMicrotaskDescriptor = getOwnPropertyDescriptor(global, 'queueMicrotask');\nvar queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;\n\nvar flush, head, last, notify, toggle, node, promise, then;\n\n// modern engines have queueMicrotask method\nif (!queueMicrotask) {\n flush = function () {\n var parent, fn;\n if (IS_NODE && (parent = process.domain)) parent.exit();\n while (head) {\n fn = head.fn;\n head = head.next;\n try {\n fn();\n } catch (error) {\n if (head) notify();\n else last = undefined;\n throw error;\n }\n } last = undefined;\n if (parent) parent.enter();\n };\n\n // Node.js\n if (IS_NODE) {\n notify = function () {\n process.nextTick(flush);\n };\n // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339\n } else if (MutationObserver && !IS_IOS) {\n toggle = true;\n node = document.createTextNode('');\n new MutationObserver(flush).observe(node, { characterData: true });\n notify = function () {\n node.data = toggle = !toggle;\n };\n // environments with maybe non-completely correct, but existent Promise\n } else if (Promise && Promise.resolve) {\n // Promise.resolve without an argument throws an error in LG WebOS 2\n promise = Promise.resolve(undefined);\n then = promise.then;\n notify = function () {\n then.call(promise, flush);\n };\n // for other environments - macrotask based on:\n // - setImmediate\n // - MessageChannel\n // - window.postMessag\n // - onreadystatechange\n // - setTimeout\n } else {\n notify = function () {\n // strange IE + webpack dev server bug - use .call(global)\n macrotask.call(global, flush);\n };\n }\n}\n\nmodule.exports = queueMicrotask || function (fn) {\n var task = { fn: fn, next: undefined };\n if (last) last.next = task;\n if (!head) {\n head = task;\n notify();\n } last = task;\n};\n","var global = require('../internals/global');\n\nmodule.exports = global.Promise;\n","var fails = require('../internals/fails');\n\nmodule.exports = !!Object.getOwnPropertySymbols && !fails(function () {\n // Chrome 38 Symbol has incorrect toString conversion\n // eslint-disable-next-line no-undef\n return !String(Symbol());\n});\n","var fails = require('../internals/fails');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar IS_PURE = require('../internals/is-pure');\n\nvar ITERATOR = wellKnownSymbol('iterator');\n\nmodule.exports = !fails(function () {\n var url = new URL('b?a=1&b=2&c=3', 'http://a');\n var searchParams = url.searchParams;\n var result = '';\n url.pathname = 'c%20d';\n searchParams.forEach(function (value, key) {\n searchParams['delete']('b');\n result += key + value;\n });\n return (IS_PURE && !url.toJSON)\n || !searchParams.sort\n || url.href !== 'http://a/c%20d?a=1&c=3'\n || searchParams.get('c') !== '3'\n || String(new URLSearchParams('?a=1')) !== 'a=1'\n || !searchParams[ITERATOR]\n // throws in Edge\n || new URL('https://a@b').username !== 'a'\n || new URLSearchParams(new URLSearchParams('a=b')).get('a') !== 'b'\n // not punycoded in Edge\n || new URL('http://тест').host !== 'xn--e1aybc'\n // not escaped in Chrome 62-\n || new URL('http://a#б').hash !== '#%D0%B1'\n // fails in Chrome 66-\n || result !== 'a1c3'\n // throws in Safari\n || new URL('http://x', undefined).host !== 'x';\n});\n","var global = require('../internals/global');\nvar inspectSource = require('../internals/inspect-source');\n\nvar WeakMap = global.WeakMap;\n\nmodule.exports = typeof WeakMap === 'function' && /native code/.test(inspectSource(WeakMap));\n","'use strict';\nvar aFunction = require('../internals/a-function');\n\nvar PromiseCapability = function (C) {\n var resolve, reject;\n this.promise = new C(function ($$resolve, $$reject) {\n if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');\n resolve = $$resolve;\n reject = $$reject;\n });\n this.resolve = aFunction(resolve);\n this.reject = aFunction(reject);\n};\n\n// 25.4.1.5 NewPromiseCapability(C)\nmodule.exports.f = function (C) {\n return new PromiseCapability(C);\n};\n","var isRegExp = require('../internals/is-regexp');\n\nmodule.exports = function (it) {\n if (isRegExp(it)) {\n throw TypeError(\"The method doesn't accept regular expressions\");\n } return it;\n};\n","var global = require('../internals/global');\n\nvar globalIsFinite = global.isFinite;\n\n// `Number.isFinite` method\n// https://tc39.github.io/ecma262/#sec-number.isfinite\nmodule.exports = Number.isFinite || function isFinite(it) {\n return typeof it == 'number' && globalIsFinite(it);\n};\n","var global = require('../internals/global');\nvar trim = require('../internals/string-trim').trim;\nvar whitespaces = require('../internals/whitespaces');\n\nvar $parseFloat = global.parseFloat;\nvar FORCED = 1 / $parseFloat(whitespaces + '-0') !== -Infinity;\n\n// `parseFloat` method\n// https://tc39.github.io/ecma262/#sec-parsefloat-string\nmodule.exports = FORCED ? function parseFloat(string) {\n var trimmedString = trim(String(string));\n var result = $parseFloat(trimmedString);\n return result === 0 && trimmedString.charAt(0) == '-' ? -0 : result;\n} : $parseFloat;\n","var global = require('../internals/global');\nvar trim = require('../internals/string-trim').trim;\nvar whitespaces = require('../internals/whitespaces');\n\nvar $parseInt = global.parseInt;\nvar hex = /^[+-]?0[Xx]/;\nvar FORCED = $parseInt(whitespaces + '08') !== 8 || $parseInt(whitespaces + '0x16') !== 22;\n\n// `parseInt` method\n// https://tc39.github.io/ecma262/#sec-parseint-string-radix\nmodule.exports = FORCED ? function parseInt(string, radix) {\n var S = trim(String(string));\n return $parseInt(S, (radix >>> 0) || (hex.test(S) ? 16 : 10));\n} : $parseInt;\n","'use strict';\nvar DESCRIPTORS = require('../internals/descriptors');\nvar fails = require('../internals/fails');\nvar objectKeys = require('../internals/object-keys');\nvar getOwnPropertySymbolsModule = require('../internals/object-get-own-property-symbols');\nvar propertyIsEnumerableModule = require('../internals/object-property-is-enumerable');\nvar toObject = require('../internals/to-object');\nvar IndexedObject = require('../internals/indexed-object');\n\nvar nativeAssign = Object.assign;\nvar defineProperty = Object.defineProperty;\n\n// `Object.assign` method\n// https://tc39.github.io/ecma262/#sec-object.assign\nmodule.exports = !nativeAssign || fails(function () {\n // should have correct order of operations (Edge bug)\n if (DESCRIPTORS && nativeAssign({ b: 1 }, nativeAssign(defineProperty({}, 'a', {\n enumerable: true,\n get: function () {\n defineProperty(this, 'b', {\n value: 3,\n enumerable: false\n });\n }\n }), { b: 2 })).b !== 1) return true;\n // should work with symbols and should have deterministic property order (V8 bug)\n var A = {};\n var B = {};\n // eslint-disable-next-line no-undef\n var symbol = Symbol();\n var alphabet = 'abcdefghijklmnopqrst';\n A[symbol] = 7;\n alphabet.split('').forEach(function (chr) { B[chr] = chr; });\n return nativeAssign({}, A)[symbol] != 7 || objectKeys(nativeAssign({}, B)).join('') != alphabet;\n}) ? function assign(target, source) { // eslint-disable-line no-unused-vars\n var T = toObject(target);\n var argumentsLength = arguments.length;\n var index = 1;\n var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;\n var propertyIsEnumerable = propertyIsEnumerableModule.f;\n while (argumentsLength > index) {\n var S = IndexedObject(arguments[index++]);\n var keys = getOwnPropertySymbols ? objectKeys(S).concat(getOwnPropertySymbols(S)) : objectKeys(S);\n var length = keys.length;\n var j = 0;\n var key;\n while (length > j) {\n key = keys[j++];\n if (!DESCRIPTORS || propertyIsEnumerable.call(S, key)) T[key] = S[key];\n }\n } return T;\n} : nativeAssign;\n","var anObject = require('../internals/an-object');\nvar defineProperties = require('../internals/object-define-properties');\nvar enumBugKeys = require('../internals/enum-bug-keys');\nvar hiddenKeys = require('../internals/hidden-keys');\nvar html = require('../internals/html');\nvar documentCreateElement = require('../internals/document-create-element');\nvar sharedKey = require('../internals/shared-key');\n\nvar GT = '>';\nvar LT = '<';\nvar PROTOTYPE = 'prototype';\nvar SCRIPT = 'script';\nvar IE_PROTO = sharedKey('IE_PROTO');\n\nvar EmptyConstructor = function () { /* empty */ };\n\nvar scriptTag = function (content) {\n return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;\n};\n\n// Create object with fake `null` prototype: use ActiveX Object with cleared prototype\nvar NullProtoObjectViaActiveX = function (activeXDocument) {\n activeXDocument.write(scriptTag(''));\n activeXDocument.close();\n var temp = activeXDocument.parentWindow.Object;\n activeXDocument = null; // avoid memory leak\n return temp;\n};\n\n// Create object with fake `null` prototype: use iframe Object with cleared prototype\nvar NullProtoObjectViaIFrame = function () {\n // Thrash, waste and sodomy: IE GC bug\n var iframe = documentCreateElement('iframe');\n var JS = 'java' + SCRIPT + ':';\n var iframeDocument;\n iframe.style.display = 'none';\n html.appendChild(iframe);\n // https://github.com/zloirock/core-js/issues/475\n iframe.src = String(JS);\n iframeDocument = iframe.contentWindow.document;\n iframeDocument.open();\n iframeDocument.write(scriptTag('document.F=Object'));\n iframeDocument.close();\n return iframeDocument.F;\n};\n\n// Check for document.domain and active x support\n// No need to use active x approach when document.domain is not set\n// see https://github.com/es-shims/es5-shim/issues/150\n// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346\n// avoid IE GC bug\nvar activeXDocument;\nvar NullProtoObject = function () {\n try {\n /* global ActiveXObject */\n activeXDocument = document.domain && new ActiveXObject('htmlfile');\n } catch (error) { /* ignore */ }\n NullProtoObject = activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) : NullProtoObjectViaIFrame();\n var length = enumBugKeys.length;\n while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];\n return NullProtoObject();\n};\n\nhiddenKeys[IE_PROTO] = true;\n\n// `Object.create` method\n// https://tc39.github.io/ecma262/#sec-object.create\nmodule.exports = Object.create || function create(O, Properties) {\n var result;\n if (O !== null) {\n EmptyConstructor[PROTOTYPE] = anObject(O);\n result = new EmptyConstructor();\n EmptyConstructor[PROTOTYPE] = null;\n // add \"__proto__\" for Object.getPrototypeOf polyfill\n result[IE_PROTO] = O;\n } else result = NullProtoObject();\n return Properties === undefined ? result : defineProperties(result, Properties);\n};\n","var DESCRIPTORS = require('../internals/descriptors');\nvar definePropertyModule = require('../internals/object-define-property');\nvar anObject = require('../internals/an-object');\nvar objectKeys = require('../internals/object-keys');\n\n// `Object.defineProperties` method\n// https://tc39.github.io/ecma262/#sec-object.defineproperties\nmodule.exports = DESCRIPTORS ? Object.defineProperties : function defineProperties(O, Properties) {\n anObject(O);\n var keys = objectKeys(Properties);\n var length = keys.length;\n var index = 0;\n var key;\n while (length > index) definePropertyModule.f(O, key = keys[index++], Properties[key]);\n return O;\n};\n","var DESCRIPTORS = require('../internals/descriptors');\nvar IE8_DOM_DEFINE = require('../internals/ie8-dom-define');\nvar anObject = require('../internals/an-object');\nvar toPrimitive = require('../internals/to-primitive');\n\nvar nativeDefineProperty = Object.defineProperty;\n\n// `Object.defineProperty` method\n// https://tc39.github.io/ecma262/#sec-object.defineproperty\nexports.f = DESCRIPTORS ? nativeDefineProperty : function defineProperty(O, P, Attributes) {\n anObject(O);\n P = toPrimitive(P, true);\n anObject(Attributes);\n if (IE8_DOM_DEFINE) try {\n return nativeDefineProperty(O, P, Attributes);\n } catch (error) { /* empty */ }\n if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');\n if ('value' in Attributes) O[P] = Attributes.value;\n return O;\n};\n","var DESCRIPTORS = require('../internals/descriptors');\nvar propertyIsEnumerableModule = require('../internals/object-property-is-enumerable');\nvar createPropertyDescriptor = require('../internals/create-property-descriptor');\nvar toIndexedObject = require('../internals/to-indexed-object');\nvar toPrimitive = require('../internals/to-primitive');\nvar has = require('../internals/has');\nvar IE8_DOM_DEFINE = require('../internals/ie8-dom-define');\n\nvar nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;\n\n// `Object.getOwnPropertyDescriptor` method\n// https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptor\nexports.f = DESCRIPTORS ? nativeGetOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {\n O = toIndexedObject(O);\n P = toPrimitive(P, true);\n if (IE8_DOM_DEFINE) try {\n return nativeGetOwnPropertyDescriptor(O, P);\n } catch (error) { /* empty */ }\n if (has(O, P)) return createPropertyDescriptor(!propertyIsEnumerableModule.f.call(O, P), O[P]);\n};\n","var toIndexedObject = require('../internals/to-indexed-object');\nvar nativeGetOwnPropertyNames = require('../internals/object-get-own-property-names').f;\n\nvar toString = {}.toString;\n\nvar windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames\n ? Object.getOwnPropertyNames(window) : [];\n\nvar getWindowNames = function (it) {\n try {\n return nativeGetOwnPropertyNames(it);\n } catch (error) {\n return windowNames.slice();\n }\n};\n\n// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window\nmodule.exports.f = function getOwnPropertyNames(it) {\n return windowNames && toString.call(it) == '[object Window]'\n ? getWindowNames(it)\n : nativeGetOwnPropertyNames(toIndexedObject(it));\n};\n","var internalObjectKeys = require('../internals/object-keys-internal');\nvar enumBugKeys = require('../internals/enum-bug-keys');\n\nvar hiddenKeys = enumBugKeys.concat('length', 'prototype');\n\n// `Object.getOwnPropertyNames` method\n// https://tc39.github.io/ecma262/#sec-object.getownpropertynames\nexports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {\n return internalObjectKeys(O, hiddenKeys);\n};\n","exports.f = Object.getOwnPropertySymbols;\n","var has = require('../internals/has');\nvar toObject = require('../internals/to-object');\nvar sharedKey = require('../internals/shared-key');\nvar CORRECT_PROTOTYPE_GETTER = require('../internals/correct-prototype-getter');\n\nvar IE_PROTO = sharedKey('IE_PROTO');\nvar ObjectPrototype = Object.prototype;\n\n// `Object.getPrototypeOf` method\n// https://tc39.github.io/ecma262/#sec-object.getprototypeof\nmodule.exports = CORRECT_PROTOTYPE_GETTER ? Object.getPrototypeOf : function (O) {\n O = toObject(O);\n if (has(O, IE_PROTO)) return O[IE_PROTO];\n if (typeof O.constructor == 'function' && O instanceof O.constructor) {\n return O.constructor.prototype;\n } return O instanceof Object ? ObjectPrototype : null;\n};\n","var has = require('../internals/has');\nvar toIndexedObject = require('../internals/to-indexed-object');\nvar indexOf = require('../internals/array-includes').indexOf;\nvar hiddenKeys = require('../internals/hidden-keys');\n\nmodule.exports = function (object, names) {\n var O = toIndexedObject(object);\n var i = 0;\n var result = [];\n var key;\n for (key in O) !has(hiddenKeys, key) && has(O, key) && result.push(key);\n // Don't enum bug & hidden keys\n while (names.length > i) if (has(O, key = names[i++])) {\n ~indexOf(result, key) || result.push(key);\n }\n return result;\n};\n","var internalObjectKeys = require('../internals/object-keys-internal');\nvar enumBugKeys = require('../internals/enum-bug-keys');\n\n// `Object.keys` method\n// https://tc39.github.io/ecma262/#sec-object.keys\nmodule.exports = Object.keys || function keys(O) {\n return internalObjectKeys(O, enumBugKeys);\n};\n","'use strict';\nvar nativePropertyIsEnumerable = {}.propertyIsEnumerable;\nvar getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;\n\n// Nashorn ~ JDK8 bug\nvar NASHORN_BUG = getOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({ 1: 2 }, 1);\n\n// `Object.prototype.propertyIsEnumerable` method implementation\n// https://tc39.github.io/ecma262/#sec-object.prototype.propertyisenumerable\nexports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {\n var descriptor = getOwnPropertyDescriptor(this, V);\n return !!descriptor && descriptor.enumerable;\n} : nativePropertyIsEnumerable;\n","'use strict';\nvar IS_PURE = require('../internals/is-pure');\nvar global = require('../internals/global');\nvar fails = require('../internals/fails');\n\n// Forced replacement object prototype accessors methods\nmodule.exports = IS_PURE || !fails(function () {\n var key = Math.random();\n // In FF throws only define methods\n // eslint-disable-next-line no-undef, no-useless-call\n __defineSetter__.call(null, key, function () { /* empty */ });\n delete global[key];\n});\n","var anObject = require('../internals/an-object');\nvar aPossiblePrototype = require('../internals/a-possible-prototype');\n\n// `Object.setPrototypeOf` method\n// https://tc39.github.io/ecma262/#sec-object.setprototypeof\n// Works with __proto__ only. Old v8 can't work with null proto objects.\n/* eslint-disable no-proto */\nmodule.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () {\n var CORRECT_SETTER = false;\n var test = {};\n var setter;\n try {\n setter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set;\n setter.call(test, []);\n CORRECT_SETTER = test instanceof Array;\n } catch (error) { /* empty */ }\n return function setPrototypeOf(O, proto) {\n anObject(O);\n aPossiblePrototype(proto);\n if (CORRECT_SETTER) setter.call(O, proto);\n else O.__proto__ = proto;\n return O;\n };\n}() : undefined);\n","var DESCRIPTORS = require('../internals/descriptors');\nvar objectKeys = require('../internals/object-keys');\nvar toIndexedObject = require('../internals/to-indexed-object');\nvar propertyIsEnumerable = require('../internals/object-property-is-enumerable').f;\n\n// `Object.{ entries, values }` methods implementation\nvar createMethod = function (TO_ENTRIES) {\n return function (it) {\n var O = toIndexedObject(it);\n var keys = objectKeys(O);\n var length = keys.length;\n var i = 0;\n var result = [];\n var key;\n while (length > i) {\n key = keys[i++];\n if (!DESCRIPTORS || propertyIsEnumerable.call(O, key)) {\n result.push(TO_ENTRIES ? [key, O[key]] : O[key]);\n }\n }\n return result;\n };\n};\n\nmodule.exports = {\n // `Object.entries` method\n // https://tc39.github.io/ecma262/#sec-object.entries\n entries: createMethod(true),\n // `Object.values` method\n // https://tc39.github.io/ecma262/#sec-object.values\n values: createMethod(false)\n};\n","'use strict';\nvar TO_STRING_TAG_SUPPORT = require('../internals/to-string-tag-support');\nvar classof = require('../internals/classof');\n\n// `Object.prototype.toString` method implementation\n// https://tc39.github.io/ecma262/#sec-object.prototype.tostring\nmodule.exports = TO_STRING_TAG_SUPPORT ? {}.toString : function toString() {\n return '[object ' + classof(this) + ']';\n};\n","var getBuiltIn = require('../internals/get-built-in');\nvar getOwnPropertyNamesModule = require('../internals/object-get-own-property-names');\nvar getOwnPropertySymbolsModule = require('../internals/object-get-own-property-symbols');\nvar anObject = require('../internals/an-object');\n\n// all object keys, includes non-enumerable and symbols\nmodule.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {\n var keys = getOwnPropertyNamesModule.f(anObject(it));\n var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;\n return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;\n};\n","var global = require('../internals/global');\n\nmodule.exports = global;\n","module.exports = function (exec) {\n try {\n return { error: false, value: exec() };\n } catch (error) {\n return { error: true, value: error };\n }\n};\n","var anObject = require('../internals/an-object');\nvar isObject = require('../internals/is-object');\nvar newPromiseCapability = require('../internals/new-promise-capability');\n\nmodule.exports = function (C, x) {\n anObject(C);\n if (isObject(x) && x.constructor === C) return x;\n var promiseCapability = newPromiseCapability.f(C);\n var resolve = promiseCapability.resolve;\n resolve(x);\n return promiseCapability.promise;\n};\n","var redefine = require('../internals/redefine');\n\nmodule.exports = function (target, src, options) {\n for (var key in src) redefine(target, key, src[key], options);\n return target;\n};\n","var global = require('../internals/global');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar has = require('../internals/has');\nvar setGlobal = require('../internals/set-global');\nvar inspectSource = require('../internals/inspect-source');\nvar InternalStateModule = require('../internals/internal-state');\n\nvar getInternalState = InternalStateModule.get;\nvar enforceInternalState = InternalStateModule.enforce;\nvar TEMPLATE = String(String).split('String');\n\n(module.exports = function (O, key, value, options) {\n var unsafe = options ? !!options.unsafe : false;\n var simple = options ? !!options.enumerable : false;\n var noTargetGet = options ? !!options.noTargetGet : false;\n if (typeof value == 'function') {\n if (typeof key == 'string' && !has(value, 'name')) createNonEnumerableProperty(value, 'name', key);\n enforceInternalState(value).source = TEMPLATE.join(typeof key == 'string' ? key : '');\n }\n if (O === global) {\n if (simple) O[key] = value;\n else setGlobal(key, value);\n return;\n } else if (!unsafe) {\n delete O[key];\n } else if (!noTargetGet && O[key]) {\n simple = true;\n }\n if (simple) O[key] = value;\n else createNonEnumerableProperty(O, key, value);\n// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative\n})(Function.prototype, 'toString', function toString() {\n return typeof this == 'function' && getInternalState(this).source || inspectSource(this);\n});\n","// TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`\nvar Map = require('../modules/es.map');\nvar WeakMap = require('../modules/es.weak-map');\nvar shared = require('../internals/shared');\n\nvar metadata = shared('metadata');\nvar store = metadata.store || (metadata.store = new WeakMap());\n\nvar getOrCreateMetadataMap = function (target, targetKey, create) {\n var targetMetadata = store.get(target);\n if (!targetMetadata) {\n if (!create) return;\n store.set(target, targetMetadata = new Map());\n }\n var keyMetadata = targetMetadata.get(targetKey);\n if (!keyMetadata) {\n if (!create) return;\n targetMetadata.set(targetKey, keyMetadata = new Map());\n } return keyMetadata;\n};\n\nvar ordinaryHasOwnMetadata = function (MetadataKey, O, P) {\n var metadataMap = getOrCreateMetadataMap(O, P, false);\n return metadataMap === undefined ? false : metadataMap.has(MetadataKey);\n};\n\nvar ordinaryGetOwnMetadata = function (MetadataKey, O, P) {\n var metadataMap = getOrCreateMetadataMap(O, P, false);\n return metadataMap === undefined ? undefined : metadataMap.get(MetadataKey);\n};\n\nvar ordinaryDefineOwnMetadata = function (MetadataKey, MetadataValue, O, P) {\n getOrCreateMetadataMap(O, P, true).set(MetadataKey, MetadataValue);\n};\n\nvar ordinaryOwnMetadataKeys = function (target, targetKey) {\n var metadataMap = getOrCreateMetadataMap(target, targetKey, false);\n var keys = [];\n if (metadataMap) metadataMap.forEach(function (_, key) { keys.push(key); });\n return keys;\n};\n\nvar toMetadataKey = function (it) {\n return it === undefined || typeof it == 'symbol' ? it : String(it);\n};\n\nmodule.exports = {\n store: store,\n getMap: getOrCreateMetadataMap,\n has: ordinaryHasOwnMetadata,\n get: ordinaryGetOwnMetadata,\n set: ordinaryDefineOwnMetadata,\n keys: ordinaryOwnMetadataKeys,\n toKey: toMetadataKey\n};\n","var classof = require('./classof-raw');\nvar regexpExec = require('./regexp-exec');\n\n// `RegExpExec` abstract operation\n// https://tc39.github.io/ecma262/#sec-regexpexec\nmodule.exports = function (R, S) {\n var exec = R.exec;\n if (typeof exec === 'function') {\n var result = exec.call(R, S);\n if (typeof result !== 'object') {\n throw TypeError('RegExp exec method returned something other than an Object or null');\n }\n return result;\n }\n\n if (classof(R) !== 'RegExp') {\n throw TypeError('RegExp#exec called on incompatible receiver');\n }\n\n return regexpExec.call(R, S);\n};\n\n","'use strict';\nvar regexpFlags = require('./regexp-flags');\nvar stickyHelpers = require('./regexp-sticky-helpers');\n\nvar nativeExec = RegExp.prototype.exec;\n// This always refers to the native implementation, because the\n// String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js,\n// which loads this file before patching the method.\nvar nativeReplace = String.prototype.replace;\n\nvar patchedExec = nativeExec;\n\nvar UPDATES_LAST_INDEX_WRONG = (function () {\n var re1 = /a/;\n var re2 = /b*/g;\n nativeExec.call(re1, 'a');\n nativeExec.call(re2, 'a');\n return re1.lastIndex !== 0 || re2.lastIndex !== 0;\n})();\n\nvar UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y || stickyHelpers.BROKEN_CARET;\n\n// nonparticipating capturing group, copied from es5-shim's String#split patch.\nvar NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;\n\nvar PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y;\n\nif (PATCH) {\n patchedExec = function exec(str) {\n var re = this;\n var lastIndex, reCopy, match, i;\n var sticky = UNSUPPORTED_Y && re.sticky;\n var flags = regexpFlags.call(re);\n var source = re.source;\n var charsAdded = 0;\n var strCopy = str;\n\n if (sticky) {\n flags = flags.replace('y', '');\n if (flags.indexOf('g') === -1) {\n flags += 'g';\n }\n\n strCopy = String(str).slice(re.lastIndex);\n // Support anchored sticky behavior.\n if (re.lastIndex > 0 && (!re.multiline || re.multiline && str[re.lastIndex - 1] !== '\\n')) {\n source = '(?: ' + source + ')';\n strCopy = ' ' + strCopy;\n charsAdded++;\n }\n // ^(? + rx + ) is needed, in combination with some str slicing, to\n // simulate the 'y' flag.\n reCopy = new RegExp('^(?:' + source + ')', flags);\n }\n\n if (NPCG_INCLUDED) {\n reCopy = new RegExp('^' + source + '$(?!\\\\s)', flags);\n }\n if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex;\n\n match = nativeExec.call(sticky ? reCopy : re, strCopy);\n\n if (sticky) {\n if (match) {\n match.input = match.input.slice(charsAdded);\n match[0] = match[0].slice(charsAdded);\n match.index = re.lastIndex;\n re.lastIndex += match[0].length;\n } else re.lastIndex = 0;\n } else if (UPDATES_LAST_INDEX_WRONG && match) {\n re.lastIndex = re.global ? match.index + match[0].length : lastIndex;\n }\n if (NPCG_INCLUDED && match && match.length > 1) {\n // Fix browsers whose `exec` methods don't consistently return `undefined`\n // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/\n nativeReplace.call(match[0], reCopy, function () {\n for (i = 1; i < arguments.length - 2; i++) {\n if (arguments[i] === undefined) match[i] = undefined;\n }\n });\n }\n\n return match;\n };\n}\n\nmodule.exports = patchedExec;\n","'use strict';\nvar anObject = require('../internals/an-object');\n\n// `RegExp.prototype.flags` getter implementation\n// https://tc39.github.io/ecma262/#sec-get-regexp.prototype.flags\nmodule.exports = function () {\n var that = anObject(this);\n var result = '';\n if (that.global) result += 'g';\n if (that.ignoreCase) result += 'i';\n if (that.multiline) result += 'm';\n if (that.dotAll) result += 's';\n if (that.unicode) result += 'u';\n if (that.sticky) result += 'y';\n return result;\n};\n","'use strict';\n\nvar fails = require('./fails');\n\n// babel-minify transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError,\n// so we use an intermediate function.\nfunction RE(s, f) {\n return RegExp(s, f);\n}\n\nexports.UNSUPPORTED_Y = fails(function () {\n // babel-minify transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError\n var re = RE('a', 'y');\n re.lastIndex = 2;\n return re.exec('abcd') != null;\n});\n\nexports.BROKEN_CARET = fails(function () {\n // https://bugzilla.mozilla.org/show_bug.cgi?id=773687\n var re = RE('^r', 'gy');\n re.lastIndex = 2;\n return re.exec('str') != null;\n});\n","// `RequireObjectCoercible` abstract operation\n// https://tc39.github.io/ecma262/#sec-requireobjectcoercible\nmodule.exports = function (it) {\n if (it == undefined) throw TypeError(\"Can't call method on \" + it);\n return it;\n};\n","// `SameValueZero` abstract operation\n// https://tc39.github.io/ecma262/#sec-samevaluezero\nmodule.exports = function (x, y) {\n // eslint-disable-next-line no-self-compare\n return x === y || x != x && y != y;\n};\n","// `SameValue` abstract operation\n// https://tc39.github.io/ecma262/#sec-samevalue\nmodule.exports = Object.is || function is(x, y) {\n // eslint-disable-next-line no-self-compare\n return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;\n};\n","var global = require('../internals/global');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\n\nmodule.exports = function (key, value) {\n try {\n createNonEnumerableProperty(global, key, value);\n } catch (error) {\n global[key] = value;\n } return value;\n};\n","'use strict';\nvar getBuiltIn = require('../internals/get-built-in');\nvar definePropertyModule = require('../internals/object-define-property');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar DESCRIPTORS = require('../internals/descriptors');\n\nvar SPECIES = wellKnownSymbol('species');\n\nmodule.exports = function (CONSTRUCTOR_NAME) {\n var Constructor = getBuiltIn(CONSTRUCTOR_NAME);\n var defineProperty = definePropertyModule.f;\n\n if (DESCRIPTORS && Constructor && !Constructor[SPECIES]) {\n defineProperty(Constructor, SPECIES, {\n configurable: true,\n get: function () { return this; }\n });\n }\n};\n","var defineProperty = require('../internals/object-define-property').f;\nvar has = require('../internals/has');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar TO_STRING_TAG = wellKnownSymbol('toStringTag');\n\nmodule.exports = function (it, TAG, STATIC) {\n if (it && !has(it = STATIC ? it : it.prototype, TO_STRING_TAG)) {\n defineProperty(it, TO_STRING_TAG, { configurable: true, value: TAG });\n }\n};\n","var shared = require('../internals/shared');\nvar uid = require('../internals/uid');\n\nvar keys = shared('keys');\n\nmodule.exports = function (key) {\n return keys[key] || (keys[key] = uid(key));\n};\n","var global = require('../internals/global');\nvar setGlobal = require('../internals/set-global');\n\nvar SHARED = '__core-js_shared__';\nvar store = global[SHARED] || setGlobal(SHARED, {});\n\nmodule.exports = store;\n","var IS_PURE = require('../internals/is-pure');\nvar store = require('../internals/shared-store');\n\n(module.exports = function (key, value) {\n return store[key] || (store[key] = value !== undefined ? value : {});\n})('versions', []).push({\n version: '3.6.5',\n mode: IS_PURE ? 'pure' : 'global',\n copyright: '© 2020 Denis Pushkarev (zloirock.ru)'\n});\n","var anObject = require('../internals/an-object');\nvar aFunction = require('../internals/a-function');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar SPECIES = wellKnownSymbol('species');\n\n// `SpeciesConstructor` abstract operation\n// https://tc39.github.io/ecma262/#sec-speciesconstructor\nmodule.exports = function (O, defaultConstructor) {\n var C = anObject(O).constructor;\n var S;\n return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? defaultConstructor : aFunction(S);\n};\n","var fails = require('../internals/fails');\n\n// check the existence of a method, lowercase\n// of a tag and escaping quotes in arguments\nmodule.exports = function (METHOD_NAME) {\n return fails(function () {\n var test = ''[METHOD_NAME]('\"');\n return test !== test.toLowerCase() || test.split('\"').length > 3;\n });\n};\n","var toInteger = require('../internals/to-integer');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\n\n// `String.prototype.{ codePointAt, at }` methods implementation\nvar createMethod = function (CONVERT_TO_STRING) {\n return function ($this, pos) {\n var S = String(requireObjectCoercible($this));\n var position = toInteger(pos);\n var size = S.length;\n var first, second;\n if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;\n first = S.charCodeAt(position);\n return first < 0xD800 || first > 0xDBFF || position + 1 === size\n || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF\n ? CONVERT_TO_STRING ? S.charAt(position) : first\n : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;\n };\n};\n\nmodule.exports = {\n // `String.prototype.codePointAt` method\n // https://tc39.github.io/ecma262/#sec-string.prototype.codepointat\n codeAt: createMethod(false),\n // `String.prototype.at` method\n // https://github.com/mathiasbynens/String.prototype.at\n charAt: createMethod(true)\n};\n","// https://github.com/zloirock/core-js/issues/280\nvar userAgent = require('../internals/engine-user-agent');\n\n// eslint-disable-next-line unicorn/no-unsafe-regex\nmodule.exports = /Version\\/10\\.\\d+(\\.\\d+)?( Mobile\\/\\w+)? Safari\\//.test(userAgent);\n","// https://github.com/tc39/proposal-string-pad-start-end\nvar toLength = require('../internals/to-length');\nvar repeat = require('../internals/string-repeat');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\n\nvar ceil = Math.ceil;\n\n// `String.prototype.{ padStart, padEnd }` methods implementation\nvar createMethod = function (IS_END) {\n return function ($this, maxLength, fillString) {\n var S = String(requireObjectCoercible($this));\n var stringLength = S.length;\n var fillStr = fillString === undefined ? ' ' : String(fillString);\n var intMaxLength = toLength(maxLength);\n var fillLen, stringFiller;\n if (intMaxLength <= stringLength || fillStr == '') return S;\n fillLen = intMaxLength - stringLength;\n stringFiller = repeat.call(fillStr, ceil(fillLen / fillStr.length));\n if (stringFiller.length > fillLen) stringFiller = stringFiller.slice(0, fillLen);\n return IS_END ? S + stringFiller : stringFiller + S;\n };\n};\n\nmodule.exports = {\n // `String.prototype.padStart` method\n // https://tc39.github.io/ecma262/#sec-string.prototype.padstart\n start: createMethod(false),\n // `String.prototype.padEnd` method\n // https://tc39.github.io/ecma262/#sec-string.prototype.padend\n end: createMethod(true)\n};\n","'use strict';\n// based on https://github.com/bestiejs/punycode.js/blob/master/punycode.js\nvar maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1\nvar base = 36;\nvar tMin = 1;\nvar tMax = 26;\nvar skew = 38;\nvar damp = 700;\nvar initialBias = 72;\nvar initialN = 128; // 0x80\nvar delimiter = '-'; // '\\x2D'\nvar regexNonASCII = /[^\\0-\\u007E]/; // non-ASCII chars\nvar regexSeparators = /[.\\u3002\\uFF0E\\uFF61]/g; // RFC 3490 separators\nvar OVERFLOW_ERROR = 'Overflow: input needs wider integers to process';\nvar baseMinusTMin = base - tMin;\nvar floor = Math.floor;\nvar stringFromCharCode = String.fromCharCode;\n\n/**\n * Creates an array containing the numeric code points of each Unicode\n * character in the string. While JavaScript uses UCS-2 internally,\n * this function will convert a pair of surrogate halves (each of which\n * UCS-2 exposes as separate characters) into a single code point,\n * matching UTF-16.\n */\nvar ucs2decode = function (string) {\n var output = [];\n var counter = 0;\n var length = string.length;\n while (counter < length) {\n var value = string.charCodeAt(counter++);\n if (value >= 0xD800 && value <= 0xDBFF && counter < length) {\n // It's a high surrogate, and there is a next character.\n var extra = string.charCodeAt(counter++);\n if ((extra & 0xFC00) == 0xDC00) { // Low surrogate.\n output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);\n } else {\n // It's an unmatched surrogate; only append this code unit, in case the\n // next code unit is the high surrogate of a surrogate pair.\n output.push(value);\n counter--;\n }\n } else {\n output.push(value);\n }\n }\n return output;\n};\n\n/**\n * Converts a digit/integer into a basic code point.\n */\nvar digitToBasic = function (digit) {\n // 0..25 map to ASCII a..z or A..Z\n // 26..35 map to ASCII 0..9\n return digit + 22 + 75 * (digit < 26);\n};\n\n/**\n * Bias adaptation function as per section 3.4 of RFC 3492.\n * https://tools.ietf.org/html/rfc3492#section-3.4\n */\nvar adapt = function (delta, numPoints, firstTime) {\n var k = 0;\n delta = firstTime ? floor(delta / damp) : delta >> 1;\n delta += floor(delta / numPoints);\n for (; delta > baseMinusTMin * tMax >> 1; k += base) {\n delta = floor(delta / baseMinusTMin);\n }\n return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));\n};\n\n/**\n * Converts a string of Unicode symbols (e.g. a domain name label) to a\n * Punycode string of ASCII-only symbols.\n */\n// eslint-disable-next-line max-statements\nvar encode = function (input) {\n var output = [];\n\n // Convert the input in UCS-2 to an array of Unicode code points.\n input = ucs2decode(input);\n\n // Cache the length.\n var inputLength = input.length;\n\n // Initialize the state.\n var n = initialN;\n var delta = 0;\n var bias = initialBias;\n var i, currentValue;\n\n // Handle the basic code points.\n for (i = 0; i < input.length; i++) {\n currentValue = input[i];\n if (currentValue < 0x80) {\n output.push(stringFromCharCode(currentValue));\n }\n }\n\n var basicLength = output.length; // number of basic code points.\n var handledCPCount = basicLength; // number of code points that have been handled;\n\n // Finish the basic string with a delimiter unless it's empty.\n if (basicLength) {\n output.push(delimiter);\n }\n\n // Main encoding loop:\n while (handledCPCount < inputLength) {\n // All non-basic code points < n have been handled already. Find the next larger one:\n var m = maxInt;\n for (i = 0; i < input.length; i++) {\n currentValue = input[i];\n if (currentValue >= n && currentValue < m) {\n m = currentValue;\n }\n }\n\n // Increase `delta` enough to advance the decoder's state to , but guard against overflow.\n var handledCPCountPlusOne = handledCPCount + 1;\n if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {\n throw RangeError(OVERFLOW_ERROR);\n }\n\n delta += (m - n) * handledCPCountPlusOne;\n n = m;\n\n for (i = 0; i < input.length; i++) {\n currentValue = input[i];\n if (currentValue < n && ++delta > maxInt) {\n throw RangeError(OVERFLOW_ERROR);\n }\n if (currentValue == n) {\n // Represent delta as a generalized variable-length integer.\n var q = delta;\n for (var k = base; /* no condition */; k += base) {\n var t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);\n if (q < t) break;\n var qMinusT = q - t;\n var baseMinusT = base - t;\n output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT)));\n q = floor(qMinusT / baseMinusT);\n }\n\n output.push(stringFromCharCode(digitToBasic(q)));\n bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);\n delta = 0;\n ++handledCPCount;\n }\n }\n\n ++delta;\n ++n;\n }\n return output.join('');\n};\n\nmodule.exports = function (input) {\n var encoded = [];\n var labels = input.toLowerCase().replace(regexSeparators, '\\u002E').split('.');\n var i, label;\n for (i = 0; i < labels.length; i++) {\n label = labels[i];\n encoded.push(regexNonASCII.test(label) ? 'xn--' + encode(label) : label);\n }\n return encoded.join('.');\n};\n","'use strict';\nvar toInteger = require('../internals/to-integer');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\n\n// `String.prototype.repeat` method implementation\n// https://tc39.github.io/ecma262/#sec-string.prototype.repeat\nmodule.exports = ''.repeat || function repeat(count) {\n var str = String(requireObjectCoercible(this));\n var result = '';\n var n = toInteger(count);\n if (n < 0 || n == Infinity) throw RangeError('Wrong number of repetitions');\n for (;n > 0; (n >>>= 1) && (str += str)) if (n & 1) result += str;\n return result;\n};\n","var fails = require('../internals/fails');\nvar whitespaces = require('../internals/whitespaces');\n\nvar non = '\\u200B\\u0085\\u180E';\n\n// check that a method works with the correct list\n// of whitespaces and has a correct name\nmodule.exports = function (METHOD_NAME) {\n return fails(function () {\n return !!whitespaces[METHOD_NAME]() || non[METHOD_NAME]() != non || whitespaces[METHOD_NAME].name !== METHOD_NAME;\n });\n};\n","var requireObjectCoercible = require('../internals/require-object-coercible');\nvar whitespaces = require('../internals/whitespaces');\n\nvar whitespace = '[' + whitespaces + ']';\nvar ltrim = RegExp('^' + whitespace + whitespace + '*');\nvar rtrim = RegExp(whitespace + whitespace + '*$');\n\n// `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation\nvar createMethod = function (TYPE) {\n return function ($this) {\n var string = String(requireObjectCoercible($this));\n if (TYPE & 1) string = string.replace(ltrim, '');\n if (TYPE & 2) string = string.replace(rtrim, '');\n return string;\n };\n};\n\nmodule.exports = {\n // `String.prototype.{ trimLeft, trimStart }` methods\n // https://tc39.github.io/ecma262/#sec-string.prototype.trimstart\n start: createMethod(1),\n // `String.prototype.{ trimRight, trimEnd }` methods\n // https://tc39.github.io/ecma262/#sec-string.prototype.trimend\n end: createMethod(2),\n // `String.prototype.trim` method\n // https://tc39.github.io/ecma262/#sec-string.prototype.trim\n trim: createMethod(3)\n};\n","var global = require('../internals/global');\nvar fails = require('../internals/fails');\nvar classof = require('../internals/classof-raw');\nvar bind = require('../internals/function-bind-context');\nvar html = require('../internals/html');\nvar createElement = require('../internals/document-create-element');\nvar IS_IOS = require('../internals/engine-is-ios');\n\nvar location = global.location;\nvar set = global.setImmediate;\nvar clear = global.clearImmediate;\nvar process = global.process;\nvar MessageChannel = global.MessageChannel;\nvar Dispatch = global.Dispatch;\nvar counter = 0;\nvar queue = {};\nvar ONREADYSTATECHANGE = 'onreadystatechange';\nvar defer, channel, port;\n\nvar run = function (id) {\n // eslint-disable-next-line no-prototype-builtins\n if (queue.hasOwnProperty(id)) {\n var fn = queue[id];\n delete queue[id];\n fn();\n }\n};\n\nvar runner = function (id) {\n return function () {\n run(id);\n };\n};\n\nvar listener = function (event) {\n run(event.data);\n};\n\nvar post = function (id) {\n // old engines have not location.origin\n global.postMessage(id + '', location.protocol + '//' + location.host);\n};\n\n// Node.js 0.9+ & IE10+ has setImmediate, otherwise:\nif (!set || !clear) {\n set = function setImmediate(fn) {\n var args = [];\n var i = 1;\n while (arguments.length > i) args.push(arguments[i++]);\n queue[++counter] = function () {\n // eslint-disable-next-line no-new-func\n (typeof fn == 'function' ? fn : Function(fn)).apply(undefined, args);\n };\n defer(counter);\n return counter;\n };\n clear = function clearImmediate(id) {\n delete queue[id];\n };\n // Node.js 0.8-\n if (classof(process) == 'process') {\n defer = function (id) {\n process.nextTick(runner(id));\n };\n // Sphere (JS game engine) Dispatch API\n } else if (Dispatch && Dispatch.now) {\n defer = function (id) {\n Dispatch.now(runner(id));\n };\n // Browsers with MessageChannel, includes WebWorkers\n // except iOS - https://github.com/zloirock/core-js/issues/624\n } else if (MessageChannel && !IS_IOS) {\n channel = new MessageChannel();\n port = channel.port2;\n channel.port1.onmessage = listener;\n defer = bind(port.postMessage, port, 1);\n // Browsers with postMessage, skip WebWorkers\n // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'\n } else if (\n global.addEventListener &&\n typeof postMessage == 'function' &&\n !global.importScripts &&\n !fails(post) &&\n location.protocol !== 'file:'\n ) {\n defer = post;\n global.addEventListener('message', listener, false);\n // IE8-\n } else if (ONREADYSTATECHANGE in createElement('script')) {\n defer = function (id) {\n html.appendChild(createElement('script'))[ONREADYSTATECHANGE] = function () {\n html.removeChild(this);\n run(id);\n };\n };\n // Rest old browsers\n } else {\n defer = function (id) {\n setTimeout(runner(id), 0);\n };\n }\n}\n\nmodule.exports = {\n set: set,\n clear: clear\n};\n","var classof = require('../internals/classof-raw');\n\n// `thisNumberValue` abstract operation\n// https://tc39.github.io/ecma262/#sec-thisnumbervalue\nmodule.exports = function (value) {\n if (typeof value != 'number' && classof(value) != 'Number') {\n throw TypeError('Incorrect invocation');\n }\n return +value;\n};\n","var toInteger = require('../internals/to-integer');\n\nvar max = Math.max;\nvar min = Math.min;\n\n// Helper for a popular repeating case of the spec:\n// Let integer be ? ToInteger(index).\n// If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).\nmodule.exports = function (index, length) {\n var integer = toInteger(index);\n return integer < 0 ? max(integer + length, 0) : min(integer, length);\n};\n","var toInteger = require('../internals/to-integer');\nvar toLength = require('../internals/to-length');\n\n// `ToIndex` abstract operation\n// https://tc39.github.io/ecma262/#sec-toindex\nmodule.exports = function (it) {\n if (it === undefined) return 0;\n var number = toInteger(it);\n var length = toLength(number);\n if (number !== length) throw RangeError('Wrong length or index');\n return length;\n};\n","// toObject with fallback for non-array-like ES3 strings\nvar IndexedObject = require('../internals/indexed-object');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\n\nmodule.exports = function (it) {\n return IndexedObject(requireObjectCoercible(it));\n};\n","var ceil = Math.ceil;\nvar floor = Math.floor;\n\n// `ToInteger` abstract operation\n// https://tc39.github.io/ecma262/#sec-tointeger\nmodule.exports = function (argument) {\n return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument);\n};\n","var toInteger = require('../internals/to-integer');\n\nvar min = Math.min;\n\n// `ToLength` abstract operation\n// https://tc39.github.io/ecma262/#sec-tolength\nmodule.exports = function (argument) {\n return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991\n};\n","var requireObjectCoercible = require('../internals/require-object-coercible');\n\n// `ToObject` abstract operation\n// https://tc39.github.io/ecma262/#sec-toobject\nmodule.exports = function (argument) {\n return Object(requireObjectCoercible(argument));\n};\n","var toPositiveInteger = require('../internals/to-positive-integer');\n\nmodule.exports = function (it, BYTES) {\n var offset = toPositiveInteger(it);\n if (offset % BYTES) throw RangeError('Wrong offset');\n return offset;\n};\n","var toInteger = require('../internals/to-integer');\n\nmodule.exports = function (it) {\n var result = toInteger(it);\n if (result < 0) throw RangeError(\"The argument can't be less than 0\");\n return result;\n};\n","var isObject = require('../internals/is-object');\n\n// `ToPrimitive` abstract operation\n// https://tc39.github.io/ecma262/#sec-toprimitive\n// instead of the ES6 spec version, we didn't implement @@toPrimitive case\n// and the second argument - flag - preferred type is a string\nmodule.exports = function (input, PREFERRED_STRING) {\n if (!isObject(input)) return input;\n var fn, val;\n if (PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;\n if (typeof (fn = input.valueOf) == 'function' && !isObject(val = fn.call(input))) return val;\n if (!PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;\n throw TypeError(\"Can't convert object to primitive value\");\n};\n","var wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar TO_STRING_TAG = wellKnownSymbol('toStringTag');\nvar test = {};\n\ntest[TO_STRING_TAG] = 'z';\n\nmodule.exports = String(test) === '[object z]';\n","'use strict';\nvar $ = require('../internals/export');\nvar global = require('../internals/global');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS = require('../internals/typed-array-constructors-require-wrappers');\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar ArrayBufferModule = require('../internals/array-buffer');\nvar anInstance = require('../internals/an-instance');\nvar createPropertyDescriptor = require('../internals/create-property-descriptor');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar toLength = require('../internals/to-length');\nvar toIndex = require('../internals/to-index');\nvar toOffset = require('../internals/to-offset');\nvar toPrimitive = require('../internals/to-primitive');\nvar has = require('../internals/has');\nvar classof = require('../internals/classof');\nvar isObject = require('../internals/is-object');\nvar create = require('../internals/object-create');\nvar setPrototypeOf = require('../internals/object-set-prototype-of');\nvar getOwnPropertyNames = require('../internals/object-get-own-property-names').f;\nvar typedArrayFrom = require('../internals/typed-array-from');\nvar forEach = require('../internals/array-iteration').forEach;\nvar setSpecies = require('../internals/set-species');\nvar definePropertyModule = require('../internals/object-define-property');\nvar getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');\nvar InternalStateModule = require('../internals/internal-state');\nvar inheritIfRequired = require('../internals/inherit-if-required');\n\nvar getInternalState = InternalStateModule.get;\nvar setInternalState = InternalStateModule.set;\nvar nativeDefineProperty = definePropertyModule.f;\nvar nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;\nvar round = Math.round;\nvar RangeError = global.RangeError;\nvar ArrayBuffer = ArrayBufferModule.ArrayBuffer;\nvar DataView = ArrayBufferModule.DataView;\nvar NATIVE_ARRAY_BUFFER_VIEWS = ArrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS;\nvar TYPED_ARRAY_TAG = ArrayBufferViewCore.TYPED_ARRAY_TAG;\nvar TypedArray = ArrayBufferViewCore.TypedArray;\nvar TypedArrayPrototype = ArrayBufferViewCore.TypedArrayPrototype;\nvar aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor;\nvar isTypedArray = ArrayBufferViewCore.isTypedArray;\nvar BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT';\nvar WRONG_LENGTH = 'Wrong length';\n\nvar fromList = function (C, list) {\n var index = 0;\n var length = list.length;\n var result = new (aTypedArrayConstructor(C))(length);\n while (length > index) result[index] = list[index++];\n return result;\n};\n\nvar addGetter = function (it, key) {\n nativeDefineProperty(it, key, { get: function () {\n return getInternalState(this)[key];\n } });\n};\n\nvar isArrayBuffer = function (it) {\n var klass;\n return it instanceof ArrayBuffer || (klass = classof(it)) == 'ArrayBuffer' || klass == 'SharedArrayBuffer';\n};\n\nvar isTypedArrayIndex = function (target, key) {\n return isTypedArray(target)\n && typeof key != 'symbol'\n && key in target\n && String(+key) == String(key);\n};\n\nvar wrappedGetOwnPropertyDescriptor = function getOwnPropertyDescriptor(target, key) {\n return isTypedArrayIndex(target, key = toPrimitive(key, true))\n ? createPropertyDescriptor(2, target[key])\n : nativeGetOwnPropertyDescriptor(target, key);\n};\n\nvar wrappedDefineProperty = function defineProperty(target, key, descriptor) {\n if (isTypedArrayIndex(target, key = toPrimitive(key, true))\n && isObject(descriptor)\n && has(descriptor, 'value')\n && !has(descriptor, 'get')\n && !has(descriptor, 'set')\n // TODO: add validation descriptor w/o calling accessors\n && !descriptor.configurable\n && (!has(descriptor, 'writable') || descriptor.writable)\n && (!has(descriptor, 'enumerable') || descriptor.enumerable)\n ) {\n target[key] = descriptor.value;\n return target;\n } return nativeDefineProperty(target, key, descriptor);\n};\n\nif (DESCRIPTORS) {\n if (!NATIVE_ARRAY_BUFFER_VIEWS) {\n getOwnPropertyDescriptorModule.f = wrappedGetOwnPropertyDescriptor;\n definePropertyModule.f = wrappedDefineProperty;\n addGetter(TypedArrayPrototype, 'buffer');\n addGetter(TypedArrayPrototype, 'byteOffset');\n addGetter(TypedArrayPrototype, 'byteLength');\n addGetter(TypedArrayPrototype, 'length');\n }\n\n $({ target: 'Object', stat: true, forced: !NATIVE_ARRAY_BUFFER_VIEWS }, {\n getOwnPropertyDescriptor: wrappedGetOwnPropertyDescriptor,\n defineProperty: wrappedDefineProperty\n });\n\n module.exports = function (TYPE, wrapper, CLAMPED) {\n var BYTES = TYPE.match(/\\d+$/)[0] / 8;\n var CONSTRUCTOR_NAME = TYPE + (CLAMPED ? 'Clamped' : '') + 'Array';\n var GETTER = 'get' + TYPE;\n var SETTER = 'set' + TYPE;\n var NativeTypedArrayConstructor = global[CONSTRUCTOR_NAME];\n var TypedArrayConstructor = NativeTypedArrayConstructor;\n var TypedArrayConstructorPrototype = TypedArrayConstructor && TypedArrayConstructor.prototype;\n var exported = {};\n\n var getter = function (that, index) {\n var data = getInternalState(that);\n return data.view[GETTER](index * BYTES + data.byteOffset, true);\n };\n\n var setter = function (that, index, value) {\n var data = getInternalState(that);\n if (CLAMPED) value = (value = round(value)) < 0 ? 0 : value > 0xFF ? 0xFF : value & 0xFF;\n data.view[SETTER](index * BYTES + data.byteOffset, value, true);\n };\n\n var addElement = function (that, index) {\n nativeDefineProperty(that, index, {\n get: function () {\n return getter(this, index);\n },\n set: function (value) {\n return setter(this, index, value);\n },\n enumerable: true\n });\n };\n\n if (!NATIVE_ARRAY_BUFFER_VIEWS) {\n TypedArrayConstructor = wrapper(function (that, data, offset, $length) {\n anInstance(that, TypedArrayConstructor, CONSTRUCTOR_NAME);\n var index = 0;\n var byteOffset = 0;\n var buffer, byteLength, length;\n if (!isObject(data)) {\n length = toIndex(data);\n byteLength = length * BYTES;\n buffer = new ArrayBuffer(byteLength);\n } else if (isArrayBuffer(data)) {\n buffer = data;\n byteOffset = toOffset(offset, BYTES);\n var $len = data.byteLength;\n if ($length === undefined) {\n if ($len % BYTES) throw RangeError(WRONG_LENGTH);\n byteLength = $len - byteOffset;\n if (byteLength < 0) throw RangeError(WRONG_LENGTH);\n } else {\n byteLength = toLength($length) * BYTES;\n if (byteLength + byteOffset > $len) throw RangeError(WRONG_LENGTH);\n }\n length = byteLength / BYTES;\n } else if (isTypedArray(data)) {\n return fromList(TypedArrayConstructor, data);\n } else {\n return typedArrayFrom.call(TypedArrayConstructor, data);\n }\n setInternalState(that, {\n buffer: buffer,\n byteOffset: byteOffset,\n byteLength: byteLength,\n length: length,\n view: new DataView(buffer)\n });\n while (index < length) addElement(that, index++);\n });\n\n if (setPrototypeOf) setPrototypeOf(TypedArrayConstructor, TypedArray);\n TypedArrayConstructorPrototype = TypedArrayConstructor.prototype = create(TypedArrayPrototype);\n } else if (TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS) {\n TypedArrayConstructor = wrapper(function (dummy, data, typedArrayOffset, $length) {\n anInstance(dummy, TypedArrayConstructor, CONSTRUCTOR_NAME);\n return inheritIfRequired(function () {\n if (!isObject(data)) return new NativeTypedArrayConstructor(toIndex(data));\n if (isArrayBuffer(data)) return $length !== undefined\n ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES), $length)\n : typedArrayOffset !== undefined\n ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES))\n : new NativeTypedArrayConstructor(data);\n if (isTypedArray(data)) return fromList(TypedArrayConstructor, data);\n return typedArrayFrom.call(TypedArrayConstructor, data);\n }(), dummy, TypedArrayConstructor);\n });\n\n if (setPrototypeOf) setPrototypeOf(TypedArrayConstructor, TypedArray);\n forEach(getOwnPropertyNames(NativeTypedArrayConstructor), function (key) {\n if (!(key in TypedArrayConstructor)) {\n createNonEnumerableProperty(TypedArrayConstructor, key, NativeTypedArrayConstructor[key]);\n }\n });\n TypedArrayConstructor.prototype = TypedArrayConstructorPrototype;\n }\n\n if (TypedArrayConstructorPrototype.constructor !== TypedArrayConstructor) {\n createNonEnumerableProperty(TypedArrayConstructorPrototype, 'constructor', TypedArrayConstructor);\n }\n\n if (TYPED_ARRAY_TAG) {\n createNonEnumerableProperty(TypedArrayConstructorPrototype, TYPED_ARRAY_TAG, CONSTRUCTOR_NAME);\n }\n\n exported[CONSTRUCTOR_NAME] = TypedArrayConstructor;\n\n $({\n global: true, forced: TypedArrayConstructor != NativeTypedArrayConstructor, sham: !NATIVE_ARRAY_BUFFER_VIEWS\n }, exported);\n\n if (!(BYTES_PER_ELEMENT in TypedArrayConstructor)) {\n createNonEnumerableProperty(TypedArrayConstructor, BYTES_PER_ELEMENT, BYTES);\n }\n\n if (!(BYTES_PER_ELEMENT in TypedArrayConstructorPrototype)) {\n createNonEnumerableProperty(TypedArrayConstructorPrototype, BYTES_PER_ELEMENT, BYTES);\n }\n\n setSpecies(CONSTRUCTOR_NAME);\n };\n} else module.exports = function () { /* empty */ };\n","/* eslint-disable no-new */\nvar global = require('../internals/global');\nvar fails = require('../internals/fails');\nvar checkCorrectnessOfIteration = require('../internals/check-correctness-of-iteration');\nvar NATIVE_ARRAY_BUFFER_VIEWS = require('../internals/array-buffer-view-core').NATIVE_ARRAY_BUFFER_VIEWS;\n\nvar ArrayBuffer = global.ArrayBuffer;\nvar Int8Array = global.Int8Array;\n\nmodule.exports = !NATIVE_ARRAY_BUFFER_VIEWS || !fails(function () {\n Int8Array(1);\n}) || !fails(function () {\n new Int8Array(-1);\n}) || !checkCorrectnessOfIteration(function (iterable) {\n new Int8Array();\n new Int8Array(null);\n new Int8Array(1.5);\n new Int8Array(iterable);\n}, true) || fails(function () {\n // Safari (11+) bug - a reason why even Safari 13 should load a typed array polyfill\n return new Int8Array(new ArrayBuffer(2), 1, undefined).length !== 1;\n});\n","var toObject = require('../internals/to-object');\nvar toLength = require('../internals/to-length');\nvar getIteratorMethod = require('../internals/get-iterator-method');\nvar isArrayIteratorMethod = require('../internals/is-array-iterator-method');\nvar bind = require('../internals/function-bind-context');\nvar aTypedArrayConstructor = require('../internals/array-buffer-view-core').aTypedArrayConstructor;\n\nmodule.exports = function from(source /* , mapfn, thisArg */) {\n var O = toObject(source);\n var argumentsLength = arguments.length;\n var mapfn = argumentsLength > 1 ? arguments[1] : undefined;\n var mapping = mapfn !== undefined;\n var iteratorMethod = getIteratorMethod(O);\n var i, length, result, step, iterator, next;\n if (iteratorMethod != undefined && !isArrayIteratorMethod(iteratorMethod)) {\n iterator = iteratorMethod.call(O);\n next = iterator.next;\n O = [];\n while (!(step = next.call(iterator)).done) {\n O.push(step.value);\n }\n }\n if (mapping && argumentsLength > 2) {\n mapfn = bind(mapfn, arguments[2], 2);\n }\n length = toLength(O.length);\n result = new (aTypedArrayConstructor(this))(length);\n for (i = 0; length > i; i++) {\n result[i] = mapping ? mapfn(O[i], i) : O[i];\n }\n return result;\n};\n","var id = 0;\nvar postfix = Math.random();\n\nmodule.exports = function (key) {\n return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36);\n};\n","var NATIVE_SYMBOL = require('../internals/native-symbol');\n\nmodule.exports = NATIVE_SYMBOL\n // eslint-disable-next-line no-undef\n && !Symbol.sham\n // eslint-disable-next-line no-undef\n && typeof Symbol.iterator == 'symbol';\n","var wellKnownSymbol = require('../internals/well-known-symbol');\n\nexports.f = wellKnownSymbol;\n","var global = require('../internals/global');\nvar shared = require('../internals/shared');\nvar has = require('../internals/has');\nvar uid = require('../internals/uid');\nvar NATIVE_SYMBOL = require('../internals/native-symbol');\nvar USE_SYMBOL_AS_UID = require('../internals/use-symbol-as-uid');\n\nvar WellKnownSymbolsStore = shared('wks');\nvar Symbol = global.Symbol;\nvar createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol : Symbol && Symbol.withoutSetter || uid;\n\nmodule.exports = function (name) {\n if (!has(WellKnownSymbolsStore, name)) {\n if (NATIVE_SYMBOL && has(Symbol, name)) WellKnownSymbolsStore[name] = Symbol[name];\n else WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name);\n } return WellKnownSymbolsStore[name];\n};\n","// a string of all valid unicode whitespaces\n// eslint-disable-next-line max-len\nmodule.exports = '\\u0009\\u000A\\u000B\\u000C\\u000D\\u0020\\u00A0\\u1680\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000\\u2028\\u2029\\uFEFF';\n","'use strict';\nvar $ = require('../internals/export');\nvar global = require('../internals/global');\nvar arrayBufferModule = require('../internals/array-buffer');\nvar setSpecies = require('../internals/set-species');\n\nvar ARRAY_BUFFER = 'ArrayBuffer';\nvar ArrayBuffer = arrayBufferModule[ARRAY_BUFFER];\nvar NativeArrayBuffer = global[ARRAY_BUFFER];\n\n// `ArrayBuffer` constructor\n// https://tc39.github.io/ecma262/#sec-arraybuffer-constructor\n$({ global: true, forced: NativeArrayBuffer !== ArrayBuffer }, {\n ArrayBuffer: ArrayBuffer\n});\n\nsetSpecies(ARRAY_BUFFER);\n","'use strict';\nvar $ = require('../internals/export');\nvar fails = require('../internals/fails');\nvar isArray = require('../internals/is-array');\nvar isObject = require('../internals/is-object');\nvar toObject = require('../internals/to-object');\nvar toLength = require('../internals/to-length');\nvar createProperty = require('../internals/create-property');\nvar arraySpeciesCreate = require('../internals/array-species-create');\nvar arrayMethodHasSpeciesSupport = require('../internals/array-method-has-species-support');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar V8_VERSION = require('../internals/engine-v8-version');\n\nvar IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable');\nvar MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;\nvar MAXIMUM_ALLOWED_INDEX_EXCEEDED = 'Maximum allowed index exceeded';\n\n// We can't use this feature detection in V8 since it causes\n// deoptimization and serious performance degradation\n// https://github.com/zloirock/core-js/issues/679\nvar IS_CONCAT_SPREADABLE_SUPPORT = V8_VERSION >= 51 || !fails(function () {\n var array = [];\n array[IS_CONCAT_SPREADABLE] = false;\n return array.concat()[0] !== array;\n});\n\nvar SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('concat');\n\nvar isConcatSpreadable = function (O) {\n if (!isObject(O)) return false;\n var spreadable = O[IS_CONCAT_SPREADABLE];\n return spreadable !== undefined ? !!spreadable : isArray(O);\n};\n\nvar FORCED = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT;\n\n// `Array.prototype.concat` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.concat\n// with adding support of @@isConcatSpreadable and @@species\n$({ target: 'Array', proto: true, forced: FORCED }, {\n concat: function concat(arg) { // eslint-disable-line no-unused-vars\n var O = toObject(this);\n var A = arraySpeciesCreate(O, 0);\n var n = 0;\n var i, k, length, len, E;\n for (i = -1, length = arguments.length; i < length; i++) {\n E = i === -1 ? O : arguments[i];\n if (isConcatSpreadable(E)) {\n len = toLength(E.length);\n if (n + len > MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);\n for (k = 0; k < len; k++, n++) if (k in E) createProperty(A, n, E[k]);\n } else {\n if (n >= MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);\n createProperty(A, n++, E);\n }\n }\n A.length = n;\n return A;\n }\n});\n","var $ = require('../internals/export');\nvar copyWithin = require('../internals/array-copy-within');\nvar addToUnscopables = require('../internals/add-to-unscopables');\n\n// `Array.prototype.copyWithin` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.copywithin\n$({ target: 'Array', proto: true }, {\n copyWithin: copyWithin\n});\n\n// https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables\naddToUnscopables('copyWithin');\n","'use strict';\nvar $ = require('../internals/export');\nvar $every = require('../internals/array-iteration').every;\nvar arrayMethodIsStrict = require('../internals/array-method-is-strict');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar STRICT_METHOD = arrayMethodIsStrict('every');\nvar USES_TO_LENGTH = arrayMethodUsesToLength('every');\n\n// `Array.prototype.every` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.every\n$({ target: 'Array', proto: true, forced: !STRICT_METHOD || !USES_TO_LENGTH }, {\n every: function every(callbackfn /* , thisArg */) {\n return $every(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n","var $ = require('../internals/export');\nvar fill = require('../internals/array-fill');\nvar addToUnscopables = require('../internals/add-to-unscopables');\n\n// `Array.prototype.fill` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.fill\n$({ target: 'Array', proto: true }, {\n fill: fill\n});\n\n// https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables\naddToUnscopables('fill');\n","'use strict';\nvar $ = require('../internals/export');\nvar $filter = require('../internals/array-iteration').filter;\nvar arrayMethodHasSpeciesSupport = require('../internals/array-method-has-species-support');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('filter');\n// Edge 14- issue\nvar USES_TO_LENGTH = arrayMethodUsesToLength('filter');\n\n// `Array.prototype.filter` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.filter\n// with adding support of @@species\n$({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT || !USES_TO_LENGTH }, {\n filter: function filter(callbackfn /* , thisArg */) {\n return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar $findIndex = require('../internals/array-iteration').findIndex;\nvar addToUnscopables = require('../internals/add-to-unscopables');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar FIND_INDEX = 'findIndex';\nvar SKIPS_HOLES = true;\n\nvar USES_TO_LENGTH = arrayMethodUsesToLength(FIND_INDEX);\n\n// Shouldn't skip holes\nif (FIND_INDEX in []) Array(1)[FIND_INDEX](function () { SKIPS_HOLES = false; });\n\n// `Array.prototype.findIndex` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.findindex\n$({ target: 'Array', proto: true, forced: SKIPS_HOLES || !USES_TO_LENGTH }, {\n findIndex: function findIndex(callbackfn /* , that = undefined */) {\n return $findIndex(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n\n// https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables\naddToUnscopables(FIND_INDEX);\n","'use strict';\nvar $ = require('../internals/export');\nvar $find = require('../internals/array-iteration').find;\nvar addToUnscopables = require('../internals/add-to-unscopables');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar FIND = 'find';\nvar SKIPS_HOLES = true;\n\nvar USES_TO_LENGTH = arrayMethodUsesToLength(FIND);\n\n// Shouldn't skip holes\nif (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });\n\n// `Array.prototype.find` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.find\n$({ target: 'Array', proto: true, forced: SKIPS_HOLES || !USES_TO_LENGTH }, {\n find: function find(callbackfn /* , that = undefined */) {\n return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n\n// https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables\naddToUnscopables(FIND);\n","'use strict';\nvar $ = require('../internals/export');\nvar flattenIntoArray = require('../internals/flatten-into-array');\nvar toObject = require('../internals/to-object');\nvar toLength = require('../internals/to-length');\nvar aFunction = require('../internals/a-function');\nvar arraySpeciesCreate = require('../internals/array-species-create');\n\n// `Array.prototype.flatMap` method\n// https://github.com/tc39/proposal-flatMap\n$({ target: 'Array', proto: true }, {\n flatMap: function flatMap(callbackfn /* , thisArg */) {\n var O = toObject(this);\n var sourceLen = toLength(O.length);\n var A;\n aFunction(callbackfn);\n A = arraySpeciesCreate(O, 0);\n A.length = flattenIntoArray(A, O, O, sourceLen, 0, 1, callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n return A;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar flattenIntoArray = require('../internals/flatten-into-array');\nvar toObject = require('../internals/to-object');\nvar toLength = require('../internals/to-length');\nvar toInteger = require('../internals/to-integer');\nvar arraySpeciesCreate = require('../internals/array-species-create');\n\n// `Array.prototype.flat` method\n// https://github.com/tc39/proposal-flatMap\n$({ target: 'Array', proto: true }, {\n flat: function flat(/* depthArg = 1 */) {\n var depthArg = arguments.length ? arguments[0] : undefined;\n var O = toObject(this);\n var sourceLen = toLength(O.length);\n var A = arraySpeciesCreate(O, 0);\n A.length = flattenIntoArray(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toInteger(depthArg));\n return A;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar forEach = require('../internals/array-for-each');\n\n// `Array.prototype.forEach` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.foreach\n$({ target: 'Array', proto: true, forced: [].forEach != forEach }, {\n forEach: forEach\n});\n","var $ = require('../internals/export');\nvar from = require('../internals/array-from');\nvar checkCorrectnessOfIteration = require('../internals/check-correctness-of-iteration');\n\nvar INCORRECT_ITERATION = !checkCorrectnessOfIteration(function (iterable) {\n Array.from(iterable);\n});\n\n// `Array.from` method\n// https://tc39.github.io/ecma262/#sec-array.from\n$({ target: 'Array', stat: true, forced: INCORRECT_ITERATION }, {\n from: from\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar $includes = require('../internals/array-includes').includes;\nvar addToUnscopables = require('../internals/add-to-unscopables');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar USES_TO_LENGTH = arrayMethodUsesToLength('indexOf', { ACCESSORS: true, 1: 0 });\n\n// `Array.prototype.includes` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.includes\n$({ target: 'Array', proto: true, forced: !USES_TO_LENGTH }, {\n includes: function includes(el /* , fromIndex = 0 */) {\n return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n\n// https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables\naddToUnscopables('includes');\n","'use strict';\nvar $ = require('../internals/export');\nvar $indexOf = require('../internals/array-includes').indexOf;\nvar arrayMethodIsStrict = require('../internals/array-method-is-strict');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar nativeIndexOf = [].indexOf;\n\nvar NEGATIVE_ZERO = !!nativeIndexOf && 1 / [1].indexOf(1, -0) < 0;\nvar STRICT_METHOD = arrayMethodIsStrict('indexOf');\nvar USES_TO_LENGTH = arrayMethodUsesToLength('indexOf', { ACCESSORS: true, 1: 0 });\n\n// `Array.prototype.indexOf` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.indexof\n$({ target: 'Array', proto: true, forced: NEGATIVE_ZERO || !STRICT_METHOD || !USES_TO_LENGTH }, {\n indexOf: function indexOf(searchElement /* , fromIndex = 0 */) {\n return NEGATIVE_ZERO\n // convert -0 to +0\n ? nativeIndexOf.apply(this, arguments) || 0\n : $indexOf(this, searchElement, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n","'use strict';\nvar toIndexedObject = require('../internals/to-indexed-object');\nvar addToUnscopables = require('../internals/add-to-unscopables');\nvar Iterators = require('../internals/iterators');\nvar InternalStateModule = require('../internals/internal-state');\nvar defineIterator = require('../internals/define-iterator');\n\nvar ARRAY_ITERATOR = 'Array Iterator';\nvar setInternalState = InternalStateModule.set;\nvar getInternalState = InternalStateModule.getterFor(ARRAY_ITERATOR);\n\n// `Array.prototype.entries` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.entries\n// `Array.prototype.keys` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.keys\n// `Array.prototype.values` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.values\n// `Array.prototype[@@iterator]` method\n// https://tc39.github.io/ecma262/#sec-array.prototype-@@iterator\n// `CreateArrayIterator` internal method\n// https://tc39.github.io/ecma262/#sec-createarrayiterator\nmodule.exports = defineIterator(Array, 'Array', function (iterated, kind) {\n setInternalState(this, {\n type: ARRAY_ITERATOR,\n target: toIndexedObject(iterated), // target\n index: 0, // next index\n kind: kind // kind\n });\n// `%ArrayIteratorPrototype%.next` method\n// https://tc39.github.io/ecma262/#sec-%arrayiteratorprototype%.next\n}, function () {\n var state = getInternalState(this);\n var target = state.target;\n var kind = state.kind;\n var index = state.index++;\n if (!target || index >= target.length) {\n state.target = undefined;\n return { value: undefined, done: true };\n }\n if (kind == 'keys') return { value: index, done: false };\n if (kind == 'values') return { value: target[index], done: false };\n return { value: [index, target[index]], done: false };\n}, 'values');\n\n// argumentsList[@@iterator] is %ArrayProto_values%\n// https://tc39.github.io/ecma262/#sec-createunmappedargumentsobject\n// https://tc39.github.io/ecma262/#sec-createmappedargumentsobject\nIterators.Arguments = Iterators.Array;\n\n// https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables\naddToUnscopables('keys');\naddToUnscopables('values');\naddToUnscopables('entries');\n","'use strict';\nvar $ = require('../internals/export');\nvar IndexedObject = require('../internals/indexed-object');\nvar toIndexedObject = require('../internals/to-indexed-object');\nvar arrayMethodIsStrict = require('../internals/array-method-is-strict');\n\nvar nativeJoin = [].join;\n\nvar ES3_STRINGS = IndexedObject != Object;\nvar STRICT_METHOD = arrayMethodIsStrict('join', ',');\n\n// `Array.prototype.join` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.join\n$({ target: 'Array', proto: true, forced: ES3_STRINGS || !STRICT_METHOD }, {\n join: function join(separator) {\n return nativeJoin.call(toIndexedObject(this), separator === undefined ? ',' : separator);\n }\n});\n","var $ = require('../internals/export');\nvar lastIndexOf = require('../internals/array-last-index-of');\n\n// `Array.prototype.lastIndexOf` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.lastindexof\n$({ target: 'Array', proto: true, forced: lastIndexOf !== [].lastIndexOf }, {\n lastIndexOf: lastIndexOf\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar $map = require('../internals/array-iteration').map;\nvar arrayMethodHasSpeciesSupport = require('../internals/array-method-has-species-support');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('map');\n// FF49- issue\nvar USES_TO_LENGTH = arrayMethodUsesToLength('map');\n\n// `Array.prototype.map` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.map\n// with adding support of @@species\n$({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT || !USES_TO_LENGTH }, {\n map: function map(callbackfn /* , thisArg */) {\n return $map(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar fails = require('../internals/fails');\nvar createProperty = require('../internals/create-property');\n\nvar ISNT_GENERIC = fails(function () {\n function F() { /* empty */ }\n return !(Array.of.call(F) instanceof F);\n});\n\n// `Array.of` method\n// https://tc39.github.io/ecma262/#sec-array.of\n// WebKit Array.of isn't generic\n$({ target: 'Array', stat: true, forced: ISNT_GENERIC }, {\n of: function of(/* ...args */) {\n var index = 0;\n var argumentsLength = arguments.length;\n var result = new (typeof this == 'function' ? this : Array)(argumentsLength);\n while (argumentsLength > index) createProperty(result, index, arguments[index++]);\n result.length = argumentsLength;\n return result;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar $reduceRight = require('../internals/array-reduce').right;\nvar arrayMethodIsStrict = require('../internals/array-method-is-strict');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar STRICT_METHOD = arrayMethodIsStrict('reduceRight');\n// For preventing possible almost infinite loop in non-standard implementations, test the forward version of the method\nvar USES_TO_LENGTH = arrayMethodUsesToLength('reduce', { 1: 0 });\n\n// `Array.prototype.reduceRight` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.reduceright\n$({ target: 'Array', proto: true, forced: !STRICT_METHOD || !USES_TO_LENGTH }, {\n reduceRight: function reduceRight(callbackfn /* , initialValue */) {\n return $reduceRight(this, callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar $reduce = require('../internals/array-reduce').left;\nvar arrayMethodIsStrict = require('../internals/array-method-is-strict');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar STRICT_METHOD = arrayMethodIsStrict('reduce');\nvar USES_TO_LENGTH = arrayMethodUsesToLength('reduce', { 1: 0 });\n\n// `Array.prototype.reduce` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.reduce\n$({ target: 'Array', proto: true, forced: !STRICT_METHOD || !USES_TO_LENGTH }, {\n reduce: function reduce(callbackfn /* , initialValue */) {\n return $reduce(this, callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar isObject = require('../internals/is-object');\nvar isArray = require('../internals/is-array');\nvar toAbsoluteIndex = require('../internals/to-absolute-index');\nvar toLength = require('../internals/to-length');\nvar toIndexedObject = require('../internals/to-indexed-object');\nvar createProperty = require('../internals/create-property');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar arrayMethodHasSpeciesSupport = require('../internals/array-method-has-species-support');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('slice');\nvar USES_TO_LENGTH = arrayMethodUsesToLength('slice', { ACCESSORS: true, 0: 0, 1: 2 });\n\nvar SPECIES = wellKnownSymbol('species');\nvar nativeSlice = [].slice;\nvar max = Math.max;\n\n// `Array.prototype.slice` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.slice\n// fallback for not array-like ES3 strings and DOM objects\n$({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT || !USES_TO_LENGTH }, {\n slice: function slice(start, end) {\n var O = toIndexedObject(this);\n var length = toLength(O.length);\n var k = toAbsoluteIndex(start, length);\n var fin = toAbsoluteIndex(end === undefined ? length : end, length);\n // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible\n var Constructor, result, n;\n if (isArray(O)) {\n Constructor = O.constructor;\n // cross-realm fallback\n if (typeof Constructor == 'function' && (Constructor === Array || isArray(Constructor.prototype))) {\n Constructor = undefined;\n } else if (isObject(Constructor)) {\n Constructor = Constructor[SPECIES];\n if (Constructor === null) Constructor = undefined;\n }\n if (Constructor === Array || Constructor === undefined) {\n return nativeSlice.call(O, k, fin);\n }\n }\n result = new (Constructor === undefined ? Array : Constructor)(max(fin - k, 0));\n for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]);\n result.length = n;\n return result;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar $some = require('../internals/array-iteration').some;\nvar arrayMethodIsStrict = require('../internals/array-method-is-strict');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar STRICT_METHOD = arrayMethodIsStrict('some');\nvar USES_TO_LENGTH = arrayMethodUsesToLength('some');\n\n// `Array.prototype.some` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.some\n$({ target: 'Array', proto: true, forced: !STRICT_METHOD || !USES_TO_LENGTH }, {\n some: function some(callbackfn /* , thisArg */) {\n return $some(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar aFunction = require('../internals/a-function');\nvar toObject = require('../internals/to-object');\nvar fails = require('../internals/fails');\nvar arrayMethodIsStrict = require('../internals/array-method-is-strict');\n\nvar test = [];\nvar nativeSort = test.sort;\n\n// IE8-\nvar FAILS_ON_UNDEFINED = fails(function () {\n test.sort(undefined);\n});\n// V8 bug\nvar FAILS_ON_NULL = fails(function () {\n test.sort(null);\n});\n// Old WebKit\nvar STRICT_METHOD = arrayMethodIsStrict('sort');\n\nvar FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD;\n\n// `Array.prototype.sort` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.sort\n$({ target: 'Array', proto: true, forced: FORCED }, {\n sort: function sort(comparefn) {\n return comparefn === undefined\n ? nativeSort.call(toObject(this))\n : nativeSort.call(toObject(this), aFunction(comparefn));\n }\n});\n","var setSpecies = require('../internals/set-species');\n\n// `Array[@@species]` getter\n// https://tc39.github.io/ecma262/#sec-get-array-@@species\nsetSpecies('Array');\n","'use strict';\nvar $ = require('../internals/export');\nvar toAbsoluteIndex = require('../internals/to-absolute-index');\nvar toInteger = require('../internals/to-integer');\nvar toLength = require('../internals/to-length');\nvar toObject = require('../internals/to-object');\nvar arraySpeciesCreate = require('../internals/array-species-create');\nvar createProperty = require('../internals/create-property');\nvar arrayMethodHasSpeciesSupport = require('../internals/array-method-has-species-support');\nvar arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');\n\nvar HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('splice');\nvar USES_TO_LENGTH = arrayMethodUsesToLength('splice', { ACCESSORS: true, 0: 0, 1: 2 });\n\nvar max = Math.max;\nvar min = Math.min;\nvar MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;\nvar MAXIMUM_ALLOWED_LENGTH_EXCEEDED = 'Maximum allowed length exceeded';\n\n// `Array.prototype.splice` method\n// https://tc39.github.io/ecma262/#sec-array.prototype.splice\n// with adding support of @@species\n$({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT || !USES_TO_LENGTH }, {\n splice: function splice(start, deleteCount /* , ...items */) {\n var O = toObject(this);\n var len = toLength(O.length);\n var actualStart = toAbsoluteIndex(start, len);\n var argumentsLength = arguments.length;\n var insertCount, actualDeleteCount, A, k, from, to;\n if (argumentsLength === 0) {\n insertCount = actualDeleteCount = 0;\n } else if (argumentsLength === 1) {\n insertCount = 0;\n actualDeleteCount = len - actualStart;\n } else {\n insertCount = argumentsLength - 2;\n actualDeleteCount = min(max(toInteger(deleteCount), 0), len - actualStart);\n }\n if (len + insertCount - actualDeleteCount > MAX_SAFE_INTEGER) {\n throw TypeError(MAXIMUM_ALLOWED_LENGTH_EXCEEDED);\n }\n A = arraySpeciesCreate(O, actualDeleteCount);\n for (k = 0; k < actualDeleteCount; k++) {\n from = actualStart + k;\n if (from in O) createProperty(A, k, O[from]);\n }\n A.length = actualDeleteCount;\n if (insertCount < actualDeleteCount) {\n for (k = actualStart; k < len - actualDeleteCount; k++) {\n from = k + actualDeleteCount;\n to = k + insertCount;\n if (from in O) O[to] = O[from];\n else delete O[to];\n }\n for (k = len; k > len - actualDeleteCount + insertCount; k--) delete O[k - 1];\n } else if (insertCount > actualDeleteCount) {\n for (k = len - actualDeleteCount; k > actualStart; k--) {\n from = k + actualDeleteCount - 1;\n to = k + insertCount - 1;\n if (from in O) O[to] = O[from];\n else delete O[to];\n }\n }\n for (k = 0; k < insertCount; k++) {\n O[k + actualStart] = arguments[k + 2];\n }\n O.length = len - actualDeleteCount + insertCount;\n return A;\n }\n});\n","// this method was added to unscopables after implementation\n// in popular engines, so it's moved to a separate module\nvar addToUnscopables = require('../internals/add-to-unscopables');\n\naddToUnscopables('flatMap');\n","// this method was added to unscopables after implementation\n// in popular engines, so it's moved to a separate module\nvar addToUnscopables = require('../internals/add-to-unscopables');\n\naddToUnscopables('flat');\n","var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar dateToPrimitive = require('../internals/date-to-primitive');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar TO_PRIMITIVE = wellKnownSymbol('toPrimitive');\nvar DatePrototype = Date.prototype;\n\n// `Date.prototype[@@toPrimitive]` method\n// https://tc39.github.io/ecma262/#sec-date.prototype-@@toprimitive\nif (!(TO_PRIMITIVE in DatePrototype)) {\n createNonEnumerableProperty(DatePrototype, TO_PRIMITIVE, dateToPrimitive);\n}\n","'use strict';\nvar isObject = require('../internals/is-object');\nvar definePropertyModule = require('../internals/object-define-property');\nvar getPrototypeOf = require('../internals/object-get-prototype-of');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar HAS_INSTANCE = wellKnownSymbol('hasInstance');\nvar FunctionPrototype = Function.prototype;\n\n// `Function.prototype[@@hasInstance]` method\n// https://tc39.github.io/ecma262/#sec-function.prototype-@@hasinstance\nif (!(HAS_INSTANCE in FunctionPrototype)) {\n definePropertyModule.f(FunctionPrototype, HAS_INSTANCE, { value: function (O) {\n if (typeof this != 'function' || !isObject(O)) return false;\n if (!isObject(this.prototype)) return O instanceof this;\n // for environment w/o native `@@hasInstance` logic enough `instanceof`, but add this:\n while (O = getPrototypeOf(O)) if (this.prototype === O) return true;\n return false;\n } });\n}\n","var DESCRIPTORS = require('../internals/descriptors');\nvar defineProperty = require('../internals/object-define-property').f;\n\nvar FunctionPrototype = Function.prototype;\nvar FunctionPrototypeToString = FunctionPrototype.toString;\nvar nameRE = /^\\s*function ([^ (]*)/;\nvar NAME = 'name';\n\n// Function instances `.name` property\n// https://tc39.github.io/ecma262/#sec-function-instances-name\nif (DESCRIPTORS && !(NAME in FunctionPrototype)) {\n defineProperty(FunctionPrototype, NAME, {\n configurable: true,\n get: function () {\n try {\n return FunctionPrototypeToString.call(this).match(nameRE)[1];\n } catch (error) {\n return '';\n }\n }\n });\n}\n","var $ = require('../internals/export');\nvar global = require('../internals/global');\n\n// `globalThis` object\n// https://github.com/tc39/proposal-global\n$({ global: true }, {\n globalThis: global\n});\n","var global = require('../internals/global');\nvar setToStringTag = require('../internals/set-to-string-tag');\n\n// JSON[@@toStringTag] property\n// https://tc39.github.io/ecma262/#sec-json-@@tostringtag\nsetToStringTag(global.JSON, 'JSON', true);\n","'use strict';\nvar collection = require('../internals/collection');\nvar collectionStrong = require('../internals/collection-strong');\n\n// `Map` constructor\n// https://tc39.github.io/ecma262/#sec-map-objects\nmodule.exports = collection('Map', function (init) {\n return function Map() { return init(this, arguments.length ? arguments[0] : undefined); };\n}, collectionStrong);\n","var $ = require('../internals/export');\nvar log1p = require('../internals/math-log1p');\n\nvar nativeAcosh = Math.acosh;\nvar log = Math.log;\nvar sqrt = Math.sqrt;\nvar LN2 = Math.LN2;\n\nvar FORCED = !nativeAcosh\n // V8 bug: https://code.google.com/p/v8/issues/detail?id=3509\n || Math.floor(nativeAcosh(Number.MAX_VALUE)) != 710\n // Tor Browser bug: Math.acosh(Infinity) -> NaN\n || nativeAcosh(Infinity) != Infinity;\n\n// `Math.acosh` method\n// https://tc39.github.io/ecma262/#sec-math.acosh\n$({ target: 'Math', stat: true, forced: FORCED }, {\n acosh: function acosh(x) {\n return (x = +x) < 1 ? NaN : x > 94906265.62425156\n ? log(x) + LN2\n : log1p(x - 1 + sqrt(x - 1) * sqrt(x + 1));\n }\n});\n","var $ = require('../internals/export');\n\nvar nativeAsinh = Math.asinh;\nvar log = Math.log;\nvar sqrt = Math.sqrt;\n\nfunction asinh(x) {\n return !isFinite(x = +x) || x == 0 ? x : x < 0 ? -asinh(-x) : log(x + sqrt(x * x + 1));\n}\n\n// `Math.asinh` method\n// https://tc39.github.io/ecma262/#sec-math.asinh\n// Tor Browser bug: Math.asinh(0) -> -0\n$({ target: 'Math', stat: true, forced: !(nativeAsinh && 1 / nativeAsinh(0) > 0) }, {\n asinh: asinh\n});\n","var $ = require('../internals/export');\n\nvar nativeAtanh = Math.atanh;\nvar log = Math.log;\n\n// `Math.atanh` method\n// https://tc39.github.io/ecma262/#sec-math.atanh\n// Tor Browser bug: Math.atanh(-0) -> 0\n$({ target: 'Math', stat: true, forced: !(nativeAtanh && 1 / nativeAtanh(-0) < 0) }, {\n atanh: function atanh(x) {\n return (x = +x) == 0 ? x : log((1 + x) / (1 - x)) / 2;\n }\n});\n","var $ = require('../internals/export');\nvar sign = require('../internals/math-sign');\n\nvar abs = Math.abs;\nvar pow = Math.pow;\n\n// `Math.cbrt` method\n// https://tc39.github.io/ecma262/#sec-math.cbrt\n$({ target: 'Math', stat: true }, {\n cbrt: function cbrt(x) {\n return sign(x = +x) * pow(abs(x), 1 / 3);\n }\n});\n","var $ = require('../internals/export');\n\nvar floor = Math.floor;\nvar log = Math.log;\nvar LOG2E = Math.LOG2E;\n\n// `Math.clz32` method\n// https://tc39.github.io/ecma262/#sec-math.clz32\n$({ target: 'Math', stat: true }, {\n clz32: function clz32(x) {\n return (x >>>= 0) ? 31 - floor(log(x + 0.5) * LOG2E) : 32;\n }\n});\n","var $ = require('../internals/export');\nvar expm1 = require('../internals/math-expm1');\n\nvar nativeCosh = Math.cosh;\nvar abs = Math.abs;\nvar E = Math.E;\n\n// `Math.cosh` method\n// https://tc39.github.io/ecma262/#sec-math.cosh\n$({ target: 'Math', stat: true, forced: !nativeCosh || nativeCosh(710) === Infinity }, {\n cosh: function cosh(x) {\n var t = expm1(abs(x) - 1) + 1;\n return (t + 1 / (t * E * E)) * (E / 2);\n }\n});\n","var $ = require('../internals/export');\nvar expm1 = require('../internals/math-expm1');\n\n// `Math.expm1` method\n// https://tc39.github.io/ecma262/#sec-math.expm1\n$({ target: 'Math', stat: true, forced: expm1 != Math.expm1 }, { expm1: expm1 });\n","var $ = require('../internals/export');\nvar fround = require('../internals/math-fround');\n\n// `Math.fround` method\n// https://tc39.github.io/ecma262/#sec-math.fround\n$({ target: 'Math', stat: true }, { fround: fround });\n","var $ = require('../internals/export');\n\nvar $hypot = Math.hypot;\nvar abs = Math.abs;\nvar sqrt = Math.sqrt;\n\n// Chrome 77 bug\n// https://bugs.chromium.org/p/v8/issues/detail?id=9546\nvar BUGGY = !!$hypot && $hypot(Infinity, NaN) !== Infinity;\n\n// `Math.hypot` method\n// https://tc39.github.io/ecma262/#sec-math.hypot\n$({ target: 'Math', stat: true, forced: BUGGY }, {\n hypot: function hypot(value1, value2) { // eslint-disable-line no-unused-vars\n var sum = 0;\n var i = 0;\n var aLen = arguments.length;\n var larg = 0;\n var arg, div;\n while (i < aLen) {\n arg = abs(arguments[i++]);\n if (larg < arg) {\n div = larg / arg;\n sum = sum * div * div + 1;\n larg = arg;\n } else if (arg > 0) {\n div = arg / larg;\n sum += div * div;\n } else sum += arg;\n }\n return larg === Infinity ? Infinity : larg * sqrt(sum);\n }\n});\n","var $ = require('../internals/export');\nvar fails = require('../internals/fails');\n\nvar nativeImul = Math.imul;\n\nvar FORCED = fails(function () {\n return nativeImul(0xFFFFFFFF, 5) != -5 || nativeImul.length != 2;\n});\n\n// `Math.imul` method\n// https://tc39.github.io/ecma262/#sec-math.imul\n// some WebKit versions fails with big numbers, some has wrong arity\n$({ target: 'Math', stat: true, forced: FORCED }, {\n imul: function imul(x, y) {\n var UINT16 = 0xFFFF;\n var xn = +x;\n var yn = +y;\n var xl = UINT16 & xn;\n var yl = UINT16 & yn;\n return 0 | xl * yl + ((UINT16 & xn >>> 16) * yl + xl * (UINT16 & yn >>> 16) << 16 >>> 0);\n }\n});\n","var $ = require('../internals/export');\n\nvar log = Math.log;\nvar LOG10E = Math.LOG10E;\n\n// `Math.log10` method\n// https://tc39.github.io/ecma262/#sec-math.log10\n$({ target: 'Math', stat: true }, {\n log10: function log10(x) {\n return log(x) * LOG10E;\n }\n});\n","var $ = require('../internals/export');\nvar log1p = require('../internals/math-log1p');\n\n// `Math.log1p` method\n// https://tc39.github.io/ecma262/#sec-math.log1p\n$({ target: 'Math', stat: true }, { log1p: log1p });\n","var $ = require('../internals/export');\n\nvar log = Math.log;\nvar LN2 = Math.LN2;\n\n// `Math.log2` method\n// https://tc39.github.io/ecma262/#sec-math.log2\n$({ target: 'Math', stat: true }, {\n log2: function log2(x) {\n return log(x) / LN2;\n }\n});\n","var $ = require('../internals/export');\nvar sign = require('../internals/math-sign');\n\n// `Math.sign` method\n// https://tc39.github.io/ecma262/#sec-math.sign\n$({ target: 'Math', stat: true }, {\n sign: sign\n});\n","var $ = require('../internals/export');\nvar fails = require('../internals/fails');\nvar expm1 = require('../internals/math-expm1');\n\nvar abs = Math.abs;\nvar exp = Math.exp;\nvar E = Math.E;\n\nvar FORCED = fails(function () {\n return Math.sinh(-2e-17) != -2e-17;\n});\n\n// `Math.sinh` method\n// https://tc39.github.io/ecma262/#sec-math.sinh\n// V8 near Chromium 38 has a problem with very small numbers\n$({ target: 'Math', stat: true, forced: FORCED }, {\n sinh: function sinh(x) {\n return abs(x = +x) < 1 ? (expm1(x) - expm1(-x)) / 2 : (exp(x - 1) - exp(-x - 1)) * (E / 2);\n }\n});\n","var $ = require('../internals/export');\nvar expm1 = require('../internals/math-expm1');\n\nvar exp = Math.exp;\n\n// `Math.tanh` method\n// https://tc39.github.io/ecma262/#sec-math.tanh\n$({ target: 'Math', stat: true }, {\n tanh: function tanh(x) {\n var a = expm1(x = +x);\n var b = expm1(-x);\n return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (exp(x) + exp(-x));\n }\n});\n","var setToStringTag = require('../internals/set-to-string-tag');\n\n// Math[@@toStringTag] property\n// https://tc39.github.io/ecma262/#sec-math-@@tostringtag\nsetToStringTag(Math, 'Math', true);\n","var $ = require('../internals/export');\n\nvar ceil = Math.ceil;\nvar floor = Math.floor;\n\n// `Math.trunc` method\n// https://tc39.github.io/ecma262/#sec-math.trunc\n$({ target: 'Math', stat: true }, {\n trunc: function trunc(it) {\n return (it > 0 ? floor : ceil)(it);\n }\n});\n","'use strict';\nvar DESCRIPTORS = require('../internals/descriptors');\nvar global = require('../internals/global');\nvar isForced = require('../internals/is-forced');\nvar redefine = require('../internals/redefine');\nvar has = require('../internals/has');\nvar classof = require('../internals/classof-raw');\nvar inheritIfRequired = require('../internals/inherit-if-required');\nvar toPrimitive = require('../internals/to-primitive');\nvar fails = require('../internals/fails');\nvar create = require('../internals/object-create');\nvar getOwnPropertyNames = require('../internals/object-get-own-property-names').f;\nvar getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;\nvar defineProperty = require('../internals/object-define-property').f;\nvar trim = require('../internals/string-trim').trim;\n\nvar NUMBER = 'Number';\nvar NativeNumber = global[NUMBER];\nvar NumberPrototype = NativeNumber.prototype;\n\n// Opera ~12 has broken Object#toString\nvar BROKEN_CLASSOF = classof(create(NumberPrototype)) == NUMBER;\n\n// `ToNumber` abstract operation\n// https://tc39.github.io/ecma262/#sec-tonumber\nvar toNumber = function (argument) {\n var it = toPrimitive(argument, false);\n var first, third, radix, maxCode, digits, length, index, code;\n if (typeof it == 'string' && it.length > 2) {\n it = trim(it);\n first = it.charCodeAt(0);\n if (first === 43 || first === 45) {\n third = it.charCodeAt(2);\n if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix\n } else if (first === 48) {\n switch (it.charCodeAt(1)) {\n case 66: case 98: radix = 2; maxCode = 49; break; // fast equal of /^0b[01]+$/i\n case 79: case 111: radix = 8; maxCode = 55; break; // fast equal of /^0o[0-7]+$/i\n default: return +it;\n }\n digits = it.slice(2);\n length = digits.length;\n for (index = 0; index < length; index++) {\n code = digits.charCodeAt(index);\n // parseInt parses a string to a first unavailable symbol\n // but ToNumber should return NaN if a string contains unavailable symbols\n if (code < 48 || code > maxCode) return NaN;\n } return parseInt(digits, radix);\n }\n } return +it;\n};\n\n// `Number` constructor\n// https://tc39.github.io/ecma262/#sec-number-constructor\nif (isForced(NUMBER, !NativeNumber(' 0o1') || !NativeNumber('0b1') || NativeNumber('+0x1'))) {\n var NumberWrapper = function Number(value) {\n var it = arguments.length < 1 ? 0 : value;\n var dummy = this;\n return dummy instanceof NumberWrapper\n // check on 1..constructor(foo) case\n && (BROKEN_CLASSOF ? fails(function () { NumberPrototype.valueOf.call(dummy); }) : classof(dummy) != NUMBER)\n ? inheritIfRequired(new NativeNumber(toNumber(it)), dummy, NumberWrapper) : toNumber(it);\n };\n for (var keys = DESCRIPTORS ? getOwnPropertyNames(NativeNumber) : (\n // ES3:\n 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +\n // ES2015 (in case, if modules with ES2015 Number statics required before):\n 'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' +\n 'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger'\n ).split(','), j = 0, key; keys.length > j; j++) {\n if (has(NativeNumber, key = keys[j]) && !has(NumberWrapper, key)) {\n defineProperty(NumberWrapper, key, getOwnPropertyDescriptor(NativeNumber, key));\n }\n }\n NumberWrapper.prototype = NumberPrototype;\n NumberPrototype.constructor = NumberWrapper;\n redefine(global, NUMBER, NumberWrapper);\n}\n","var $ = require('../internals/export');\n\n// `Number.EPSILON` constant\n// https://tc39.github.io/ecma262/#sec-number.epsilon\n$({ target: 'Number', stat: true }, {\n EPSILON: Math.pow(2, -52)\n});\n","var $ = require('../internals/export');\nvar numberIsFinite = require('../internals/number-is-finite');\n\n// `Number.isFinite` method\n// https://tc39.github.io/ecma262/#sec-number.isfinite\n$({ target: 'Number', stat: true }, { isFinite: numberIsFinite });\n","var $ = require('../internals/export');\nvar isInteger = require('../internals/is-integer');\n\n// `Number.isInteger` method\n// https://tc39.github.io/ecma262/#sec-number.isinteger\n$({ target: 'Number', stat: true }, {\n isInteger: isInteger\n});\n","var $ = require('../internals/export');\n\n// `Number.isNaN` method\n// https://tc39.github.io/ecma262/#sec-number.isnan\n$({ target: 'Number', stat: true }, {\n isNaN: function isNaN(number) {\n // eslint-disable-next-line no-self-compare\n return number != number;\n }\n});\n","var $ = require('../internals/export');\nvar isInteger = require('../internals/is-integer');\n\nvar abs = Math.abs;\n\n// `Number.isSafeInteger` method\n// https://tc39.github.io/ecma262/#sec-number.issafeinteger\n$({ target: 'Number', stat: true }, {\n isSafeInteger: function isSafeInteger(number) {\n return isInteger(number) && abs(number) <= 0x1FFFFFFFFFFFFF;\n }\n});\n","var $ = require('../internals/export');\n\n// `Number.MAX_SAFE_INTEGER` constant\n// https://tc39.github.io/ecma262/#sec-number.max_safe_integer\n$({ target: 'Number', stat: true }, {\n MAX_SAFE_INTEGER: 0x1FFFFFFFFFFFFF\n});\n","var $ = require('../internals/export');\n\n// `Number.MIN_SAFE_INTEGER` constant\n// https://tc39.github.io/ecma262/#sec-number.min_safe_integer\n$({ target: 'Number', stat: true }, {\n MIN_SAFE_INTEGER: -0x1FFFFFFFFFFFFF\n});\n","var $ = require('../internals/export');\nvar parseFloat = require('../internals/number-parse-float');\n\n// `Number.parseFloat` method\n// https://tc39.github.io/ecma262/#sec-number.parseFloat\n$({ target: 'Number', stat: true, forced: Number.parseFloat != parseFloat }, {\n parseFloat: parseFloat\n});\n","var $ = require('../internals/export');\nvar parseInt = require('../internals/number-parse-int');\n\n// `Number.parseInt` method\n// https://tc39.github.io/ecma262/#sec-number.parseint\n$({ target: 'Number', stat: true, forced: Number.parseInt != parseInt }, {\n parseInt: parseInt\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar toInteger = require('../internals/to-integer');\nvar thisNumberValue = require('../internals/this-number-value');\nvar repeat = require('../internals/string-repeat');\nvar fails = require('../internals/fails');\n\nvar nativeToFixed = 1.0.toFixed;\nvar floor = Math.floor;\n\nvar pow = function (x, n, acc) {\n return n === 0 ? acc : n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc);\n};\n\nvar log = function (x) {\n var n = 0;\n var x2 = x;\n while (x2 >= 4096) {\n n += 12;\n x2 /= 4096;\n }\n while (x2 >= 2) {\n n += 1;\n x2 /= 2;\n } return n;\n};\n\nvar FORCED = nativeToFixed && (\n 0.00008.toFixed(3) !== '0.000' ||\n 0.9.toFixed(0) !== '1' ||\n 1.255.toFixed(2) !== '1.25' ||\n 1000000000000000128.0.toFixed(0) !== '1000000000000000128'\n) || !fails(function () {\n // V8 ~ Android 4.3-\n nativeToFixed.call({});\n});\n\n// `Number.prototype.toFixed` method\n// https://tc39.github.io/ecma262/#sec-number.prototype.tofixed\n$({ target: 'Number', proto: true, forced: FORCED }, {\n // eslint-disable-next-line max-statements\n toFixed: function toFixed(fractionDigits) {\n var number = thisNumberValue(this);\n var fractDigits = toInteger(fractionDigits);\n var data = [0, 0, 0, 0, 0, 0];\n var sign = '';\n var result = '0';\n var e, z, j, k;\n\n var multiply = function (n, c) {\n var index = -1;\n var c2 = c;\n while (++index < 6) {\n c2 += n * data[index];\n data[index] = c2 % 1e7;\n c2 = floor(c2 / 1e7);\n }\n };\n\n var divide = function (n) {\n var index = 6;\n var c = 0;\n while (--index >= 0) {\n c += data[index];\n data[index] = floor(c / n);\n c = (c % n) * 1e7;\n }\n };\n\n var dataToString = function () {\n var index = 6;\n var s = '';\n while (--index >= 0) {\n if (s !== '' || index === 0 || data[index] !== 0) {\n var t = String(data[index]);\n s = s === '' ? t : s + repeat.call('0', 7 - t.length) + t;\n }\n } return s;\n };\n\n if (fractDigits < 0 || fractDigits > 20) throw RangeError('Incorrect fraction digits');\n // eslint-disable-next-line no-self-compare\n if (number != number) return 'NaN';\n if (number <= -1e21 || number >= 1e21) return String(number);\n if (number < 0) {\n sign = '-';\n number = -number;\n }\n if (number > 1e-21) {\n e = log(number * pow(2, 69, 1)) - 69;\n z = e < 0 ? number * pow(2, -e, 1) : number / pow(2, e, 1);\n z *= 0x10000000000000;\n e = 52 - e;\n if (e > 0) {\n multiply(0, z);\n j = fractDigits;\n while (j >= 7) {\n multiply(1e7, 0);\n j -= 7;\n }\n multiply(pow(10, j, 1), 0);\n j = e - 1;\n while (j >= 23) {\n divide(1 << 23);\n j -= 23;\n }\n divide(1 << j);\n multiply(1, 1);\n divide(2);\n result = dataToString();\n } else {\n multiply(0, z);\n multiply(1 << -e, 0);\n result = dataToString() + repeat.call('0', fractDigits);\n }\n }\n if (fractDigits > 0) {\n k = result.length;\n result = sign + (k <= fractDigits\n ? '0.' + repeat.call('0', fractDigits - k) + result\n : result.slice(0, k - fractDigits) + '.' + result.slice(k - fractDigits));\n } else {\n result = sign + result;\n } return result;\n }\n});\n","var $ = require('../internals/export');\nvar assign = require('../internals/object-assign');\n\n// `Object.assign` method\n// https://tc39.github.io/ecma262/#sec-object.assign\n$({ target: 'Object', stat: true, forced: Object.assign !== assign }, {\n assign: assign\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar FORCED = require('../internals/object-prototype-accessors-forced');\nvar toObject = require('../internals/to-object');\nvar aFunction = require('../internals/a-function');\nvar definePropertyModule = require('../internals/object-define-property');\n\n// `Object.prototype.__defineGetter__` method\n// https://tc39.github.io/ecma262/#sec-object.prototype.__defineGetter__\nif (DESCRIPTORS) {\n $({ target: 'Object', proto: true, forced: FORCED }, {\n __defineGetter__: function __defineGetter__(P, getter) {\n definePropertyModule.f(toObject(this), P, { get: aFunction(getter), enumerable: true, configurable: true });\n }\n });\n}\n","'use strict';\nvar $ = require('../internals/export');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar FORCED = require('../internals/object-prototype-accessors-forced');\nvar toObject = require('../internals/to-object');\nvar aFunction = require('../internals/a-function');\nvar definePropertyModule = require('../internals/object-define-property');\n\n// `Object.prototype.__defineSetter__` method\n// https://tc39.github.io/ecma262/#sec-object.prototype.__defineSetter__\nif (DESCRIPTORS) {\n $({ target: 'Object', proto: true, forced: FORCED }, {\n __defineSetter__: function __defineSetter__(P, setter) {\n definePropertyModule.f(toObject(this), P, { set: aFunction(setter), enumerable: true, configurable: true });\n }\n });\n}\n","var $ = require('../internals/export');\nvar $entries = require('../internals/object-to-array').entries;\n\n// `Object.entries` method\n// https://tc39.github.io/ecma262/#sec-object.entries\n$({ target: 'Object', stat: true }, {\n entries: function entries(O) {\n return $entries(O);\n }\n});\n","var $ = require('../internals/export');\nvar FREEZING = require('../internals/freezing');\nvar fails = require('../internals/fails');\nvar isObject = require('../internals/is-object');\nvar onFreeze = require('../internals/internal-metadata').onFreeze;\n\nvar nativeFreeze = Object.freeze;\nvar FAILS_ON_PRIMITIVES = fails(function () { nativeFreeze(1); });\n\n// `Object.freeze` method\n// https://tc39.github.io/ecma262/#sec-object.freeze\n$({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !FREEZING }, {\n freeze: function freeze(it) {\n return nativeFreeze && isObject(it) ? nativeFreeze(onFreeze(it)) : it;\n }\n});\n","var $ = require('../internals/export');\nvar iterate = require('../internals/iterate');\nvar createProperty = require('../internals/create-property');\n\n// `Object.fromEntries` method\n// https://github.com/tc39/proposal-object-from-entries\n$({ target: 'Object', stat: true }, {\n fromEntries: function fromEntries(iterable) {\n var obj = {};\n iterate(iterable, function (k, v) {\n createProperty(obj, k, v);\n }, undefined, true);\n return obj;\n }\n});\n","var $ = require('../internals/export');\nvar fails = require('../internals/fails');\nvar toIndexedObject = require('../internals/to-indexed-object');\nvar nativeGetOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;\nvar DESCRIPTORS = require('../internals/descriptors');\n\nvar FAILS_ON_PRIMITIVES = fails(function () { nativeGetOwnPropertyDescriptor(1); });\nvar FORCED = !DESCRIPTORS || FAILS_ON_PRIMITIVES;\n\n// `Object.getOwnPropertyDescriptor` method\n// https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptor\n$({ target: 'Object', stat: true, forced: FORCED, sham: !DESCRIPTORS }, {\n getOwnPropertyDescriptor: function getOwnPropertyDescriptor(it, key) {\n return nativeGetOwnPropertyDescriptor(toIndexedObject(it), key);\n }\n});\n","var $ = require('../internals/export');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar ownKeys = require('../internals/own-keys');\nvar toIndexedObject = require('../internals/to-indexed-object');\nvar getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');\nvar createProperty = require('../internals/create-property');\n\n// `Object.getOwnPropertyDescriptors` method\n// https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptors\n$({ target: 'Object', stat: true, sham: !DESCRIPTORS }, {\n getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) {\n var O = toIndexedObject(object);\n var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;\n var keys = ownKeys(O);\n var result = {};\n var index = 0;\n var key, descriptor;\n while (keys.length > index) {\n descriptor = getOwnPropertyDescriptor(O, key = keys[index++]);\n if (descriptor !== undefined) createProperty(result, key, descriptor);\n }\n return result;\n }\n});\n","var $ = require('../internals/export');\nvar fails = require('../internals/fails');\nvar nativeGetOwnPropertyNames = require('../internals/object-get-own-property-names-external').f;\n\nvar FAILS_ON_PRIMITIVES = fails(function () { return !Object.getOwnPropertyNames(1); });\n\n// `Object.getOwnPropertyNames` method\n// https://tc39.github.io/ecma262/#sec-object.getownpropertynames\n$({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {\n getOwnPropertyNames: nativeGetOwnPropertyNames\n});\n","var $ = require('../internals/export');\nvar fails = require('../internals/fails');\nvar toObject = require('../internals/to-object');\nvar nativeGetPrototypeOf = require('../internals/object-get-prototype-of');\nvar CORRECT_PROTOTYPE_GETTER = require('../internals/correct-prototype-getter');\n\nvar FAILS_ON_PRIMITIVES = fails(function () { nativeGetPrototypeOf(1); });\n\n// `Object.getPrototypeOf` method\n// https://tc39.github.io/ecma262/#sec-object.getprototypeof\n$({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !CORRECT_PROTOTYPE_GETTER }, {\n getPrototypeOf: function getPrototypeOf(it) {\n return nativeGetPrototypeOf(toObject(it));\n }\n});\n\n","var $ = require('../internals/export');\nvar fails = require('../internals/fails');\nvar isObject = require('../internals/is-object');\n\nvar nativeIsExtensible = Object.isExtensible;\nvar FAILS_ON_PRIMITIVES = fails(function () { nativeIsExtensible(1); });\n\n// `Object.isExtensible` method\n// https://tc39.github.io/ecma262/#sec-object.isextensible\n$({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {\n isExtensible: function isExtensible(it) {\n return isObject(it) ? nativeIsExtensible ? nativeIsExtensible(it) : true : false;\n }\n});\n","var $ = require('../internals/export');\nvar fails = require('../internals/fails');\nvar isObject = require('../internals/is-object');\n\nvar nativeIsFrozen = Object.isFrozen;\nvar FAILS_ON_PRIMITIVES = fails(function () { nativeIsFrozen(1); });\n\n// `Object.isFrozen` method\n// https://tc39.github.io/ecma262/#sec-object.isfrozen\n$({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {\n isFrozen: function isFrozen(it) {\n return isObject(it) ? nativeIsFrozen ? nativeIsFrozen(it) : false : true;\n }\n});\n","var $ = require('../internals/export');\nvar fails = require('../internals/fails');\nvar isObject = require('../internals/is-object');\n\nvar nativeIsSealed = Object.isSealed;\nvar FAILS_ON_PRIMITIVES = fails(function () { nativeIsSealed(1); });\n\n// `Object.isSealed` method\n// https://tc39.github.io/ecma262/#sec-object.issealed\n$({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {\n isSealed: function isSealed(it) {\n return isObject(it) ? nativeIsSealed ? nativeIsSealed(it) : false : true;\n }\n});\n","var $ = require('../internals/export');\nvar is = require('../internals/same-value');\n\n// `Object.is` method\n// https://tc39.github.io/ecma262/#sec-object.is\n$({ target: 'Object', stat: true }, {\n is: is\n});\n","var $ = require('../internals/export');\nvar toObject = require('../internals/to-object');\nvar nativeKeys = require('../internals/object-keys');\nvar fails = require('../internals/fails');\n\nvar FAILS_ON_PRIMITIVES = fails(function () { nativeKeys(1); });\n\n// `Object.keys` method\n// https://tc39.github.io/ecma262/#sec-object.keys\n$({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {\n keys: function keys(it) {\n return nativeKeys(toObject(it));\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar FORCED = require('../internals/object-prototype-accessors-forced');\nvar toObject = require('../internals/to-object');\nvar toPrimitive = require('../internals/to-primitive');\nvar getPrototypeOf = require('../internals/object-get-prototype-of');\nvar getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;\n\n// `Object.prototype.__lookupGetter__` method\n// https://tc39.github.io/ecma262/#sec-object.prototype.__lookupGetter__\nif (DESCRIPTORS) {\n $({ target: 'Object', proto: true, forced: FORCED }, {\n __lookupGetter__: function __lookupGetter__(P) {\n var O = toObject(this);\n var key = toPrimitive(P, true);\n var desc;\n do {\n if (desc = getOwnPropertyDescriptor(O, key)) return desc.get;\n } while (O = getPrototypeOf(O));\n }\n });\n}\n","'use strict';\nvar $ = require('../internals/export');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar FORCED = require('../internals/object-prototype-accessors-forced');\nvar toObject = require('../internals/to-object');\nvar toPrimitive = require('../internals/to-primitive');\nvar getPrototypeOf = require('../internals/object-get-prototype-of');\nvar getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;\n\n// `Object.prototype.__lookupSetter__` method\n// https://tc39.github.io/ecma262/#sec-object.prototype.__lookupSetter__\nif (DESCRIPTORS) {\n $({ target: 'Object', proto: true, forced: FORCED }, {\n __lookupSetter__: function __lookupSetter__(P) {\n var O = toObject(this);\n var key = toPrimitive(P, true);\n var desc;\n do {\n if (desc = getOwnPropertyDescriptor(O, key)) return desc.set;\n } while (O = getPrototypeOf(O));\n }\n });\n}\n","var $ = require('../internals/export');\nvar isObject = require('../internals/is-object');\nvar onFreeze = require('../internals/internal-metadata').onFreeze;\nvar FREEZING = require('../internals/freezing');\nvar fails = require('../internals/fails');\n\nvar nativePreventExtensions = Object.preventExtensions;\nvar FAILS_ON_PRIMITIVES = fails(function () { nativePreventExtensions(1); });\n\n// `Object.preventExtensions` method\n// https://tc39.github.io/ecma262/#sec-object.preventextensions\n$({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !FREEZING }, {\n preventExtensions: function preventExtensions(it) {\n return nativePreventExtensions && isObject(it) ? nativePreventExtensions(onFreeze(it)) : it;\n }\n});\n","var $ = require('../internals/export');\nvar isObject = require('../internals/is-object');\nvar onFreeze = require('../internals/internal-metadata').onFreeze;\nvar FREEZING = require('../internals/freezing');\nvar fails = require('../internals/fails');\n\nvar nativeSeal = Object.seal;\nvar FAILS_ON_PRIMITIVES = fails(function () { nativeSeal(1); });\n\n// `Object.seal` method\n// https://tc39.github.io/ecma262/#sec-object.seal\n$({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !FREEZING }, {\n seal: function seal(it) {\n return nativeSeal && isObject(it) ? nativeSeal(onFreeze(it)) : it;\n }\n});\n","var TO_STRING_TAG_SUPPORT = require('../internals/to-string-tag-support');\nvar redefine = require('../internals/redefine');\nvar toString = require('../internals/object-to-string');\n\n// `Object.prototype.toString` method\n// https://tc39.github.io/ecma262/#sec-object.prototype.tostring\nif (!TO_STRING_TAG_SUPPORT) {\n redefine(Object.prototype, 'toString', toString, { unsafe: true });\n}\n","var $ = require('../internals/export');\nvar $values = require('../internals/object-to-array').values;\n\n// `Object.values` method\n// https://tc39.github.io/ecma262/#sec-object.values\n$({ target: 'Object', stat: true }, {\n values: function values(O) {\n return $values(O);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar aFunction = require('../internals/a-function');\nvar newPromiseCapabilityModule = require('../internals/new-promise-capability');\nvar perform = require('../internals/perform');\nvar iterate = require('../internals/iterate');\n\n// `Promise.allSettled` method\n// https://github.com/tc39/proposal-promise-allSettled\n$({ target: 'Promise', stat: true }, {\n allSettled: function allSettled(iterable) {\n var C = this;\n var capability = newPromiseCapabilityModule.f(C);\n var resolve = capability.resolve;\n var reject = capability.reject;\n var result = perform(function () {\n var promiseResolve = aFunction(C.resolve);\n var values = [];\n var counter = 0;\n var remaining = 1;\n iterate(iterable, function (promise) {\n var index = counter++;\n var alreadyCalled = false;\n values.push(undefined);\n remaining++;\n promiseResolve.call(C, promise).then(function (value) {\n if (alreadyCalled) return;\n alreadyCalled = true;\n values[index] = { status: 'fulfilled', value: value };\n --remaining || resolve(values);\n }, function (e) {\n if (alreadyCalled) return;\n alreadyCalled = true;\n values[index] = { status: 'rejected', reason: e };\n --remaining || resolve(values);\n });\n });\n --remaining || resolve(values);\n });\n if (result.error) reject(result.value);\n return capability.promise;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar NativePromise = require('../internals/native-promise-constructor');\nvar fails = require('../internals/fails');\nvar getBuiltIn = require('../internals/get-built-in');\nvar speciesConstructor = require('../internals/species-constructor');\nvar promiseResolve = require('../internals/promise-resolve');\nvar redefine = require('../internals/redefine');\n\n// Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829\nvar NON_GENERIC = !!NativePromise && fails(function () {\n NativePromise.prototype['finally'].call({ then: function () { /* empty */ } }, function () { /* empty */ });\n});\n\n// `Promise.prototype.finally` method\n// https://tc39.github.io/ecma262/#sec-promise.prototype.finally\n$({ target: 'Promise', proto: true, real: true, forced: NON_GENERIC }, {\n 'finally': function (onFinally) {\n var C = speciesConstructor(this, getBuiltIn('Promise'));\n var isFunction = typeof onFinally == 'function';\n return this.then(\n isFunction ? function (x) {\n return promiseResolve(C, onFinally()).then(function () { return x; });\n } : onFinally,\n isFunction ? function (e) {\n return promiseResolve(C, onFinally()).then(function () { throw e; });\n } : onFinally\n );\n }\n});\n\n// patch native Promise.prototype for native async functions\nif (!IS_PURE && typeof NativePromise == 'function' && !NativePromise.prototype['finally']) {\n redefine(NativePromise.prototype, 'finally', getBuiltIn('Promise').prototype['finally']);\n}\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar global = require('../internals/global');\nvar getBuiltIn = require('../internals/get-built-in');\nvar NativePromise = require('../internals/native-promise-constructor');\nvar redefine = require('../internals/redefine');\nvar redefineAll = require('../internals/redefine-all');\nvar setToStringTag = require('../internals/set-to-string-tag');\nvar setSpecies = require('../internals/set-species');\nvar isObject = require('../internals/is-object');\nvar aFunction = require('../internals/a-function');\nvar anInstance = require('../internals/an-instance');\nvar classof = require('../internals/classof-raw');\nvar inspectSource = require('../internals/inspect-source');\nvar iterate = require('../internals/iterate');\nvar checkCorrectnessOfIteration = require('../internals/check-correctness-of-iteration');\nvar speciesConstructor = require('../internals/species-constructor');\nvar task = require('../internals/task').set;\nvar microtask = require('../internals/microtask');\nvar promiseResolve = require('../internals/promise-resolve');\nvar hostReportErrors = require('../internals/host-report-errors');\nvar newPromiseCapabilityModule = require('../internals/new-promise-capability');\nvar perform = require('../internals/perform');\nvar InternalStateModule = require('../internals/internal-state');\nvar isForced = require('../internals/is-forced');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar V8_VERSION = require('../internals/engine-v8-version');\n\nvar SPECIES = wellKnownSymbol('species');\nvar PROMISE = 'Promise';\nvar getInternalState = InternalStateModule.get;\nvar setInternalState = InternalStateModule.set;\nvar getInternalPromiseState = InternalStateModule.getterFor(PROMISE);\nvar PromiseConstructor = NativePromise;\nvar TypeError = global.TypeError;\nvar document = global.document;\nvar process = global.process;\nvar $fetch = getBuiltIn('fetch');\nvar newPromiseCapability = newPromiseCapabilityModule.f;\nvar newGenericPromiseCapability = newPromiseCapability;\nvar IS_NODE = classof(process) == 'process';\nvar DISPATCH_EVENT = !!(document && document.createEvent && global.dispatchEvent);\nvar UNHANDLED_REJECTION = 'unhandledrejection';\nvar REJECTION_HANDLED = 'rejectionhandled';\nvar PENDING = 0;\nvar FULFILLED = 1;\nvar REJECTED = 2;\nvar HANDLED = 1;\nvar UNHANDLED = 2;\nvar Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;\n\nvar FORCED = isForced(PROMISE, function () {\n var GLOBAL_CORE_JS_PROMISE = inspectSource(PromiseConstructor) !== String(PromiseConstructor);\n if (!GLOBAL_CORE_JS_PROMISE) {\n // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables\n // https://bugs.chromium.org/p/chromium/issues/detail?id=830565\n // We can't detect it synchronously, so just check versions\n if (V8_VERSION === 66) return true;\n // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test\n if (!IS_NODE && typeof PromiseRejectionEvent != 'function') return true;\n }\n // We need Promise#finally in the pure version for preventing prototype pollution\n if (IS_PURE && !PromiseConstructor.prototype['finally']) return true;\n // We can't use @@species feature detection in V8 since it causes\n // deoptimization and performance degradation\n // https://github.com/zloirock/core-js/issues/679\n if (V8_VERSION >= 51 && /native code/.test(PromiseConstructor)) return false;\n // Detect correctness of subclassing with @@species support\n var promise = PromiseConstructor.resolve(1);\n var FakePromise = function (exec) {\n exec(function () { /* empty */ }, function () { /* empty */ });\n };\n var constructor = promise.constructor = {};\n constructor[SPECIES] = FakePromise;\n return !(promise.then(function () { /* empty */ }) instanceof FakePromise);\n});\n\nvar INCORRECT_ITERATION = FORCED || !checkCorrectnessOfIteration(function (iterable) {\n PromiseConstructor.all(iterable)['catch'](function () { /* empty */ });\n});\n\n// helpers\nvar isThenable = function (it) {\n var then;\n return isObject(it) && typeof (then = it.then) == 'function' ? then : false;\n};\n\nvar notify = function (promise, state, isReject) {\n if (state.notified) return;\n state.notified = true;\n var chain = state.reactions;\n microtask(function () {\n var value = state.value;\n var ok = state.state == FULFILLED;\n var index = 0;\n // variable length - can't use forEach\n while (chain.length > index) {\n var reaction = chain[index++];\n var handler = ok ? reaction.ok : reaction.fail;\n var resolve = reaction.resolve;\n var reject = reaction.reject;\n var domain = reaction.domain;\n var result, then, exited;\n try {\n if (handler) {\n if (!ok) {\n if (state.rejection === UNHANDLED) onHandleUnhandled(promise, state);\n state.rejection = HANDLED;\n }\n if (handler === true) result = value;\n else {\n if (domain) domain.enter();\n result = handler(value); // can throw\n if (domain) {\n domain.exit();\n exited = true;\n }\n }\n if (result === reaction.promise) {\n reject(TypeError('Promise-chain cycle'));\n } else if (then = isThenable(result)) {\n then.call(result, resolve, reject);\n } else resolve(result);\n } else reject(value);\n } catch (error) {\n if (domain && !exited) domain.exit();\n reject(error);\n }\n }\n state.reactions = [];\n state.notified = false;\n if (isReject && !state.rejection) onUnhandled(promise, state);\n });\n};\n\nvar dispatchEvent = function (name, promise, reason) {\n var event, handler;\n if (DISPATCH_EVENT) {\n event = document.createEvent('Event');\n event.promise = promise;\n event.reason = reason;\n event.initEvent(name, false, true);\n global.dispatchEvent(event);\n } else event = { promise: promise, reason: reason };\n if (handler = global['on' + name]) handler(event);\n else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason);\n};\n\nvar onUnhandled = function (promise, state) {\n task.call(global, function () {\n var value = state.value;\n var IS_UNHANDLED = isUnhandled(state);\n var result;\n if (IS_UNHANDLED) {\n result = perform(function () {\n if (IS_NODE) {\n process.emit('unhandledRejection', value, promise);\n } else dispatchEvent(UNHANDLED_REJECTION, promise, value);\n });\n // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should\n state.rejection = IS_NODE || isUnhandled(state) ? UNHANDLED : HANDLED;\n if (result.error) throw result.value;\n }\n });\n};\n\nvar isUnhandled = function (state) {\n return state.rejection !== HANDLED && !state.parent;\n};\n\nvar onHandleUnhandled = function (promise, state) {\n task.call(global, function () {\n if (IS_NODE) {\n process.emit('rejectionHandled', promise);\n } else dispatchEvent(REJECTION_HANDLED, promise, state.value);\n });\n};\n\nvar bind = function (fn, promise, state, unwrap) {\n return function (value) {\n fn(promise, state, value, unwrap);\n };\n};\n\nvar internalReject = function (promise, state, value, unwrap) {\n if (state.done) return;\n state.done = true;\n if (unwrap) state = unwrap;\n state.value = value;\n state.state = REJECTED;\n notify(promise, state, true);\n};\n\nvar internalResolve = function (promise, state, value, unwrap) {\n if (state.done) return;\n state.done = true;\n if (unwrap) state = unwrap;\n try {\n if (promise === value) throw TypeError(\"Promise can't be resolved itself\");\n var then = isThenable(value);\n if (then) {\n microtask(function () {\n var wrapper = { done: false };\n try {\n then.call(value,\n bind(internalResolve, promise, wrapper, state),\n bind(internalReject, promise, wrapper, state)\n );\n } catch (error) {\n internalReject(promise, wrapper, error, state);\n }\n });\n } else {\n state.value = value;\n state.state = FULFILLED;\n notify(promise, state, false);\n }\n } catch (error) {\n internalReject(promise, { done: false }, error, state);\n }\n};\n\n// constructor polyfill\nif (FORCED) {\n // 25.4.3.1 Promise(executor)\n PromiseConstructor = function Promise(executor) {\n anInstance(this, PromiseConstructor, PROMISE);\n aFunction(executor);\n Internal.call(this);\n var state = getInternalState(this);\n try {\n executor(bind(internalResolve, this, state), bind(internalReject, this, state));\n } catch (error) {\n internalReject(this, state, error);\n }\n };\n // eslint-disable-next-line no-unused-vars\n Internal = function Promise(executor) {\n setInternalState(this, {\n type: PROMISE,\n done: false,\n notified: false,\n parent: false,\n reactions: [],\n rejection: false,\n state: PENDING,\n value: undefined\n });\n };\n Internal.prototype = redefineAll(PromiseConstructor.prototype, {\n // `Promise.prototype.then` method\n // https://tc39.github.io/ecma262/#sec-promise.prototype.then\n then: function then(onFulfilled, onRejected) {\n var state = getInternalPromiseState(this);\n var reaction = newPromiseCapability(speciesConstructor(this, PromiseConstructor));\n reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;\n reaction.fail = typeof onRejected == 'function' && onRejected;\n reaction.domain = IS_NODE ? process.domain : undefined;\n state.parent = true;\n state.reactions.push(reaction);\n if (state.state != PENDING) notify(this, state, false);\n return reaction.promise;\n },\n // `Promise.prototype.catch` method\n // https://tc39.github.io/ecma262/#sec-promise.prototype.catch\n 'catch': function (onRejected) {\n return this.then(undefined, onRejected);\n }\n });\n OwnPromiseCapability = function () {\n var promise = new Internal();\n var state = getInternalState(promise);\n this.promise = promise;\n this.resolve = bind(internalResolve, promise, state);\n this.reject = bind(internalReject, promise, state);\n };\n newPromiseCapabilityModule.f = newPromiseCapability = function (C) {\n return C === PromiseConstructor || C === PromiseWrapper\n ? new OwnPromiseCapability(C)\n : newGenericPromiseCapability(C);\n };\n\n if (!IS_PURE && typeof NativePromise == 'function') {\n nativeThen = NativePromise.prototype.then;\n\n // wrap native Promise#then for native async functions\n redefine(NativePromise.prototype, 'then', function then(onFulfilled, onRejected) {\n var that = this;\n return new PromiseConstructor(function (resolve, reject) {\n nativeThen.call(that, resolve, reject);\n }).then(onFulfilled, onRejected);\n // https://github.com/zloirock/core-js/issues/640\n }, { unsafe: true });\n\n // wrap fetch result\n if (typeof $fetch == 'function') $({ global: true, enumerable: true, forced: true }, {\n // eslint-disable-next-line no-unused-vars\n fetch: function fetch(input /* , init */) {\n return promiseResolve(PromiseConstructor, $fetch.apply(global, arguments));\n }\n });\n }\n}\n\n$({ global: true, wrap: true, forced: FORCED }, {\n Promise: PromiseConstructor\n});\n\nsetToStringTag(PromiseConstructor, PROMISE, false, true);\nsetSpecies(PROMISE);\n\nPromiseWrapper = getBuiltIn(PROMISE);\n\n// statics\n$({ target: PROMISE, stat: true, forced: FORCED }, {\n // `Promise.reject` method\n // https://tc39.github.io/ecma262/#sec-promise.reject\n reject: function reject(r) {\n var capability = newPromiseCapability(this);\n capability.reject.call(undefined, r);\n return capability.promise;\n }\n});\n\n$({ target: PROMISE, stat: true, forced: IS_PURE || FORCED }, {\n // `Promise.resolve` method\n // https://tc39.github.io/ecma262/#sec-promise.resolve\n resolve: function resolve(x) {\n return promiseResolve(IS_PURE && this === PromiseWrapper ? PromiseConstructor : this, x);\n }\n});\n\n$({ target: PROMISE, stat: true, forced: INCORRECT_ITERATION }, {\n // `Promise.all` method\n // https://tc39.github.io/ecma262/#sec-promise.all\n all: function all(iterable) {\n var C = this;\n var capability = newPromiseCapability(C);\n var resolve = capability.resolve;\n var reject = capability.reject;\n var result = perform(function () {\n var $promiseResolve = aFunction(C.resolve);\n var values = [];\n var counter = 0;\n var remaining = 1;\n iterate(iterable, function (promise) {\n var index = counter++;\n var alreadyCalled = false;\n values.push(undefined);\n remaining++;\n $promiseResolve.call(C, promise).then(function (value) {\n if (alreadyCalled) return;\n alreadyCalled = true;\n values[index] = value;\n --remaining || resolve(values);\n }, reject);\n });\n --remaining || resolve(values);\n });\n if (result.error) reject(result.value);\n return capability.promise;\n },\n // `Promise.race` method\n // https://tc39.github.io/ecma262/#sec-promise.race\n race: function race(iterable) {\n var C = this;\n var capability = newPromiseCapability(C);\n var reject = capability.reject;\n var result = perform(function () {\n var $promiseResolve = aFunction(C.resolve);\n iterate(iterable, function (promise) {\n $promiseResolve.call(C, promise).then(capability.resolve, reject);\n });\n });\n if (result.error) reject(result.value);\n return capability.promise;\n }\n});\n","var $ = require('../internals/export');\nvar getBuiltIn = require('../internals/get-built-in');\nvar aFunction = require('../internals/a-function');\nvar anObject = require('../internals/an-object');\nvar fails = require('../internals/fails');\n\nvar nativeApply = getBuiltIn('Reflect', 'apply');\nvar functionApply = Function.apply;\n\n// MS Edge argumentsList argument is optional\nvar OPTIONAL_ARGUMENTS_LIST = !fails(function () {\n nativeApply(function () { /* empty */ });\n});\n\n// `Reflect.apply` method\n// https://tc39.github.io/ecma262/#sec-reflect.apply\n$({ target: 'Reflect', stat: true, forced: OPTIONAL_ARGUMENTS_LIST }, {\n apply: function apply(target, thisArgument, argumentsList) {\n aFunction(target);\n anObject(argumentsList);\n return nativeApply\n ? nativeApply(target, thisArgument, argumentsList)\n : functionApply.call(target, thisArgument, argumentsList);\n }\n});\n","var $ = require('../internals/export');\nvar getBuiltIn = require('../internals/get-built-in');\nvar aFunction = require('../internals/a-function');\nvar anObject = require('../internals/an-object');\nvar isObject = require('../internals/is-object');\nvar create = require('../internals/object-create');\nvar bind = require('../internals/function-bind');\nvar fails = require('../internals/fails');\n\nvar nativeConstruct = getBuiltIn('Reflect', 'construct');\n\n// `Reflect.construct` method\n// https://tc39.github.io/ecma262/#sec-reflect.construct\n// MS Edge supports only 2 arguments and argumentsList argument is optional\n// FF Nightly sets third argument as `new.target`, but does not create `this` from it\nvar NEW_TARGET_BUG = fails(function () {\n function F() { /* empty */ }\n return !(nativeConstruct(function () { /* empty */ }, [], F) instanceof F);\n});\nvar ARGS_BUG = !fails(function () {\n nativeConstruct(function () { /* empty */ });\n});\nvar FORCED = NEW_TARGET_BUG || ARGS_BUG;\n\n$({ target: 'Reflect', stat: true, forced: FORCED, sham: FORCED }, {\n construct: function construct(Target, args /* , newTarget */) {\n aFunction(Target);\n anObject(args);\n var newTarget = arguments.length < 3 ? Target : aFunction(arguments[2]);\n if (ARGS_BUG && !NEW_TARGET_BUG) return nativeConstruct(Target, args, newTarget);\n if (Target == newTarget) {\n // w/o altered newTarget, optimization for 0-4 arguments\n switch (args.length) {\n case 0: return new Target();\n case 1: return new Target(args[0]);\n case 2: return new Target(args[0], args[1]);\n case 3: return new Target(args[0], args[1], args[2]);\n case 4: return new Target(args[0], args[1], args[2], args[3]);\n }\n // w/o altered newTarget, lot of arguments case\n var $args = [null];\n $args.push.apply($args, args);\n return new (bind.apply(Target, $args))();\n }\n // with altered newTarget, not support built-in constructors\n var proto = newTarget.prototype;\n var instance = create(isObject(proto) ? proto : Object.prototype);\n var result = Function.apply.call(Target, instance, args);\n return isObject(result) ? result : instance;\n }\n});\n","var $ = require('../internals/export');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar anObject = require('../internals/an-object');\nvar toPrimitive = require('../internals/to-primitive');\nvar definePropertyModule = require('../internals/object-define-property');\nvar fails = require('../internals/fails');\n\n// MS Edge has broken Reflect.defineProperty - throwing instead of returning false\nvar ERROR_INSTEAD_OF_FALSE = fails(function () {\n // eslint-disable-next-line no-undef\n Reflect.defineProperty(definePropertyModule.f({}, 1, { value: 1 }), 1, { value: 2 });\n});\n\n// `Reflect.defineProperty` method\n// https://tc39.github.io/ecma262/#sec-reflect.defineproperty\n$({ target: 'Reflect', stat: true, forced: ERROR_INSTEAD_OF_FALSE, sham: !DESCRIPTORS }, {\n defineProperty: function defineProperty(target, propertyKey, attributes) {\n anObject(target);\n var key = toPrimitive(propertyKey, true);\n anObject(attributes);\n try {\n definePropertyModule.f(target, key, attributes);\n return true;\n } catch (error) {\n return false;\n }\n }\n});\n","var $ = require('../internals/export');\nvar anObject = require('../internals/an-object');\nvar getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;\n\n// `Reflect.deleteProperty` method\n// https://tc39.github.io/ecma262/#sec-reflect.deleteproperty\n$({ target: 'Reflect', stat: true }, {\n deleteProperty: function deleteProperty(target, propertyKey) {\n var descriptor = getOwnPropertyDescriptor(anObject(target), propertyKey);\n return descriptor && !descriptor.configurable ? false : delete target[propertyKey];\n }\n});\n","var $ = require('../internals/export');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar anObject = require('../internals/an-object');\nvar getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');\n\n// `Reflect.getOwnPropertyDescriptor` method\n// https://tc39.github.io/ecma262/#sec-reflect.getownpropertydescriptor\n$({ target: 'Reflect', stat: true, sham: !DESCRIPTORS }, {\n getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, propertyKey) {\n return getOwnPropertyDescriptorModule.f(anObject(target), propertyKey);\n }\n});\n","var $ = require('../internals/export');\nvar anObject = require('../internals/an-object');\nvar objectGetPrototypeOf = require('../internals/object-get-prototype-of');\nvar CORRECT_PROTOTYPE_GETTER = require('../internals/correct-prototype-getter');\n\n// `Reflect.getPrototypeOf` method\n// https://tc39.github.io/ecma262/#sec-reflect.getprototypeof\n$({ target: 'Reflect', stat: true, sham: !CORRECT_PROTOTYPE_GETTER }, {\n getPrototypeOf: function getPrototypeOf(target) {\n return objectGetPrototypeOf(anObject(target));\n }\n});\n","var $ = require('../internals/export');\nvar isObject = require('../internals/is-object');\nvar anObject = require('../internals/an-object');\nvar has = require('../internals/has');\nvar getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');\nvar getPrototypeOf = require('../internals/object-get-prototype-of');\n\n// `Reflect.get` method\n// https://tc39.github.io/ecma262/#sec-reflect.get\nfunction get(target, propertyKey /* , receiver */) {\n var receiver = arguments.length < 3 ? target : arguments[2];\n var descriptor, prototype;\n if (anObject(target) === receiver) return target[propertyKey];\n if (descriptor = getOwnPropertyDescriptorModule.f(target, propertyKey)) return has(descriptor, 'value')\n ? descriptor.value\n : descriptor.get === undefined\n ? undefined\n : descriptor.get.call(receiver);\n if (isObject(prototype = getPrototypeOf(target))) return get(prototype, propertyKey, receiver);\n}\n\n$({ target: 'Reflect', stat: true }, {\n get: get\n});\n","var $ = require('../internals/export');\n\n// `Reflect.has` method\n// https://tc39.github.io/ecma262/#sec-reflect.has\n$({ target: 'Reflect', stat: true }, {\n has: function has(target, propertyKey) {\n return propertyKey in target;\n }\n});\n","var $ = require('../internals/export');\nvar anObject = require('../internals/an-object');\n\nvar objectIsExtensible = Object.isExtensible;\n\n// `Reflect.isExtensible` method\n// https://tc39.github.io/ecma262/#sec-reflect.isextensible\n$({ target: 'Reflect', stat: true }, {\n isExtensible: function isExtensible(target) {\n anObject(target);\n return objectIsExtensible ? objectIsExtensible(target) : true;\n }\n});\n","var $ = require('../internals/export');\nvar ownKeys = require('../internals/own-keys');\n\n// `Reflect.ownKeys` method\n// https://tc39.github.io/ecma262/#sec-reflect.ownkeys\n$({ target: 'Reflect', stat: true }, {\n ownKeys: ownKeys\n});\n","var $ = require('../internals/export');\nvar getBuiltIn = require('../internals/get-built-in');\nvar anObject = require('../internals/an-object');\nvar FREEZING = require('../internals/freezing');\n\n// `Reflect.preventExtensions` method\n// https://tc39.github.io/ecma262/#sec-reflect.preventextensions\n$({ target: 'Reflect', stat: true, sham: !FREEZING }, {\n preventExtensions: function preventExtensions(target) {\n anObject(target);\n try {\n var objectPreventExtensions = getBuiltIn('Object', 'preventExtensions');\n if (objectPreventExtensions) objectPreventExtensions(target);\n return true;\n } catch (error) {\n return false;\n }\n }\n});\n","var $ = require('../internals/export');\nvar anObject = require('../internals/an-object');\nvar aPossiblePrototype = require('../internals/a-possible-prototype');\nvar objectSetPrototypeOf = require('../internals/object-set-prototype-of');\n\n// `Reflect.setPrototypeOf` method\n// https://tc39.github.io/ecma262/#sec-reflect.setprototypeof\nif (objectSetPrototypeOf) $({ target: 'Reflect', stat: true }, {\n setPrototypeOf: function setPrototypeOf(target, proto) {\n anObject(target);\n aPossiblePrototype(proto);\n try {\n objectSetPrototypeOf(target, proto);\n return true;\n } catch (error) {\n return false;\n }\n }\n});\n","var $ = require('../internals/export');\nvar anObject = require('../internals/an-object');\nvar isObject = require('../internals/is-object');\nvar has = require('../internals/has');\nvar fails = require('../internals/fails');\nvar definePropertyModule = require('../internals/object-define-property');\nvar getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');\nvar getPrototypeOf = require('../internals/object-get-prototype-of');\nvar createPropertyDescriptor = require('../internals/create-property-descriptor');\n\n// `Reflect.set` method\n// https://tc39.github.io/ecma262/#sec-reflect.set\nfunction set(target, propertyKey, V /* , receiver */) {\n var receiver = arguments.length < 4 ? target : arguments[3];\n var ownDescriptor = getOwnPropertyDescriptorModule.f(anObject(target), propertyKey);\n var existingDescriptor, prototype;\n if (!ownDescriptor) {\n if (isObject(prototype = getPrototypeOf(target))) {\n return set(prototype, propertyKey, V, receiver);\n }\n ownDescriptor = createPropertyDescriptor(0);\n }\n if (has(ownDescriptor, 'value')) {\n if (ownDescriptor.writable === false || !isObject(receiver)) return false;\n if (existingDescriptor = getOwnPropertyDescriptorModule.f(receiver, propertyKey)) {\n if (existingDescriptor.get || existingDescriptor.set || existingDescriptor.writable === false) return false;\n existingDescriptor.value = V;\n definePropertyModule.f(receiver, propertyKey, existingDescriptor);\n } else definePropertyModule.f(receiver, propertyKey, createPropertyDescriptor(0, V));\n return true;\n }\n return ownDescriptor.set === undefined ? false : (ownDescriptor.set.call(receiver, V), true);\n}\n\n// MS Edge 17-18 Reflect.set allows setting the property to object\n// with non-writable property on the prototype\nvar MS_EDGE_BUG = fails(function () {\n var object = definePropertyModule.f({}, 'a', { configurable: true });\n // eslint-disable-next-line no-undef\n return Reflect.set(getPrototypeOf(object), 'a', 1, object) !== false;\n});\n\n$({ target: 'Reflect', stat: true, forced: MS_EDGE_BUG }, {\n set: set\n});\n","var DESCRIPTORS = require('../internals/descriptors');\nvar global = require('../internals/global');\nvar isForced = require('../internals/is-forced');\nvar inheritIfRequired = require('../internals/inherit-if-required');\nvar defineProperty = require('../internals/object-define-property').f;\nvar getOwnPropertyNames = require('../internals/object-get-own-property-names').f;\nvar isRegExp = require('../internals/is-regexp');\nvar getFlags = require('../internals/regexp-flags');\nvar stickyHelpers = require('../internals/regexp-sticky-helpers');\nvar redefine = require('../internals/redefine');\nvar fails = require('../internals/fails');\nvar setInternalState = require('../internals/internal-state').set;\nvar setSpecies = require('../internals/set-species');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar MATCH = wellKnownSymbol('match');\nvar NativeRegExp = global.RegExp;\nvar RegExpPrototype = NativeRegExp.prototype;\nvar re1 = /a/g;\nvar re2 = /a/g;\n\n// \"new\" should create a new object, old webkit bug\nvar CORRECT_NEW = new NativeRegExp(re1) !== re1;\n\nvar UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y;\n\nvar FORCED = DESCRIPTORS && isForced('RegExp', (!CORRECT_NEW || UNSUPPORTED_Y || fails(function () {\n re2[MATCH] = false;\n // RegExp constructor can alter flags and IsRegExp works correct with @@match\n return NativeRegExp(re1) != re1 || NativeRegExp(re2) == re2 || NativeRegExp(re1, 'i') != '/a/i';\n})));\n\n// `RegExp` constructor\n// https://tc39.github.io/ecma262/#sec-regexp-constructor\nif (FORCED) {\n var RegExpWrapper = function RegExp(pattern, flags) {\n var thisIsRegExp = this instanceof RegExpWrapper;\n var patternIsRegExp = isRegExp(pattern);\n var flagsAreUndefined = flags === undefined;\n var sticky;\n\n if (!thisIsRegExp && patternIsRegExp && pattern.constructor === RegExpWrapper && flagsAreUndefined) {\n return pattern;\n }\n\n if (CORRECT_NEW) {\n if (patternIsRegExp && !flagsAreUndefined) pattern = pattern.source;\n } else if (pattern instanceof RegExpWrapper) {\n if (flagsAreUndefined) flags = getFlags.call(pattern);\n pattern = pattern.source;\n }\n\n if (UNSUPPORTED_Y) {\n sticky = !!flags && flags.indexOf('y') > -1;\n if (sticky) flags = flags.replace(/y/g, '');\n }\n\n var result = inheritIfRequired(\n CORRECT_NEW ? new NativeRegExp(pattern, flags) : NativeRegExp(pattern, flags),\n thisIsRegExp ? this : RegExpPrototype,\n RegExpWrapper\n );\n\n if (UNSUPPORTED_Y && sticky) setInternalState(result, { sticky: sticky });\n\n return result;\n };\n var proxy = function (key) {\n key in RegExpWrapper || defineProperty(RegExpWrapper, key, {\n configurable: true,\n get: function () { return NativeRegExp[key]; },\n set: function (it) { NativeRegExp[key] = it; }\n });\n };\n var keys = getOwnPropertyNames(NativeRegExp);\n var index = 0;\n while (keys.length > index) proxy(keys[index++]);\n RegExpPrototype.constructor = RegExpWrapper;\n RegExpWrapper.prototype = RegExpPrototype;\n redefine(global, 'RegExp', RegExpWrapper);\n}\n\n// https://tc39.github.io/ecma262/#sec-get-regexp-@@species\nsetSpecies('RegExp');\n","'use strict';\nvar $ = require('../internals/export');\nvar exec = require('../internals/regexp-exec');\n\n$({ target: 'RegExp', proto: true, forced: /./.exec !== exec }, {\n exec: exec\n});\n","var DESCRIPTORS = require('../internals/descriptors');\nvar objectDefinePropertyModule = require('../internals/object-define-property');\nvar regExpFlags = require('../internals/regexp-flags');\nvar UNSUPPORTED_Y = require('../internals/regexp-sticky-helpers').UNSUPPORTED_Y;\n\n// `RegExp.prototype.flags` getter\n// https://tc39.github.io/ecma262/#sec-get-regexp.prototype.flags\nif (DESCRIPTORS && (/./g.flags != 'g' || UNSUPPORTED_Y)) {\n objectDefinePropertyModule.f(RegExp.prototype, 'flags', {\n configurable: true,\n get: regExpFlags\n });\n}\n","'use strict';\nvar redefine = require('../internals/redefine');\nvar anObject = require('../internals/an-object');\nvar fails = require('../internals/fails');\nvar flags = require('../internals/regexp-flags');\n\nvar TO_STRING = 'toString';\nvar RegExpPrototype = RegExp.prototype;\nvar nativeToString = RegExpPrototype[TO_STRING];\n\nvar NOT_GENERIC = fails(function () { return nativeToString.call({ source: 'a', flags: 'b' }) != '/a/b'; });\n// FF44- RegExp#toString has a wrong name\nvar INCORRECT_NAME = nativeToString.name != TO_STRING;\n\n// `RegExp.prototype.toString` method\n// https://tc39.github.io/ecma262/#sec-regexp.prototype.tostring\nif (NOT_GENERIC || INCORRECT_NAME) {\n redefine(RegExp.prototype, TO_STRING, function toString() {\n var R = anObject(this);\n var p = String(R.source);\n var rf = R.flags;\n var f = String(rf === undefined && R instanceof RegExp && !('flags' in RegExpPrototype) ? flags.call(R) : rf);\n return '/' + p + '/' + f;\n }, { unsafe: true });\n}\n","'use strict';\nvar collection = require('../internals/collection');\nvar collectionStrong = require('../internals/collection-strong');\n\n// `Set` constructor\n// https://tc39.github.io/ecma262/#sec-set-objects\nmodule.exports = collection('Set', function (init) {\n return function Set() { return init(this, arguments.length ? arguments[0] : undefined); };\n}, collectionStrong);\n","'use strict';\nvar $ = require('../internals/export');\nvar createHTML = require('../internals/create-html');\nvar forcedStringHTMLMethod = require('../internals/string-html-forced');\n\n// `String.prototype.anchor` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.anchor\n$({ target: 'String', proto: true, forced: forcedStringHTMLMethod('anchor') }, {\n anchor: function anchor(name) {\n return createHTML(this, 'a', 'name', name);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar createHTML = require('../internals/create-html');\nvar forcedStringHTMLMethod = require('../internals/string-html-forced');\n\n// `String.prototype.big` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.big\n$({ target: 'String', proto: true, forced: forcedStringHTMLMethod('big') }, {\n big: function big() {\n return createHTML(this, 'big', '', '');\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar createHTML = require('../internals/create-html');\nvar forcedStringHTMLMethod = require('../internals/string-html-forced');\n\n// `String.prototype.blink` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.blink\n$({ target: 'String', proto: true, forced: forcedStringHTMLMethod('blink') }, {\n blink: function blink() {\n return createHTML(this, 'blink', '', '');\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar createHTML = require('../internals/create-html');\nvar forcedStringHTMLMethod = require('../internals/string-html-forced');\n\n// `String.prototype.bold` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.bold\n$({ target: 'String', proto: true, forced: forcedStringHTMLMethod('bold') }, {\n bold: function bold() {\n return createHTML(this, 'b', '', '');\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar codeAt = require('../internals/string-multibyte').codeAt;\n\n// `String.prototype.codePointAt` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.codepointat\n$({ target: 'String', proto: true }, {\n codePointAt: function codePointAt(pos) {\n return codeAt(this, pos);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;\nvar toLength = require('../internals/to-length');\nvar notARegExp = require('../internals/not-a-regexp');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\nvar correctIsRegExpLogic = require('../internals/correct-is-regexp-logic');\nvar IS_PURE = require('../internals/is-pure');\n\nvar nativeEndsWith = ''.endsWith;\nvar min = Math.min;\n\nvar CORRECT_IS_REGEXP_LOGIC = correctIsRegExpLogic('endsWith');\n// https://github.com/zloirock/core-js/pull/702\nvar MDN_POLYFILL_BUG = !IS_PURE && !CORRECT_IS_REGEXP_LOGIC && !!function () {\n var descriptor = getOwnPropertyDescriptor(String.prototype, 'endsWith');\n return descriptor && !descriptor.writable;\n}();\n\n// `String.prototype.endsWith` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.endswith\n$({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC }, {\n endsWith: function endsWith(searchString /* , endPosition = @length */) {\n var that = String(requireObjectCoercible(this));\n notARegExp(searchString);\n var endPosition = arguments.length > 1 ? arguments[1] : undefined;\n var len = toLength(that.length);\n var end = endPosition === undefined ? len : min(toLength(endPosition), len);\n var search = String(searchString);\n return nativeEndsWith\n ? nativeEndsWith.call(that, search, end)\n : that.slice(end - search.length, end) === search;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar createHTML = require('../internals/create-html');\nvar forcedStringHTMLMethod = require('../internals/string-html-forced');\n\n// `String.prototype.fixed` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.fixed\n$({ target: 'String', proto: true, forced: forcedStringHTMLMethod('fixed') }, {\n fixed: function fixed() {\n return createHTML(this, 'tt', '', '');\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar createHTML = require('../internals/create-html');\nvar forcedStringHTMLMethod = require('../internals/string-html-forced');\n\n// `String.prototype.fontcolor` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.fontcolor\n$({ target: 'String', proto: true, forced: forcedStringHTMLMethod('fontcolor') }, {\n fontcolor: function fontcolor(color) {\n return createHTML(this, 'font', 'color', color);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar createHTML = require('../internals/create-html');\nvar forcedStringHTMLMethod = require('../internals/string-html-forced');\n\n// `String.prototype.fontsize` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.fontsize\n$({ target: 'String', proto: true, forced: forcedStringHTMLMethod('fontsize') }, {\n fontsize: function fontsize(size) {\n return createHTML(this, 'font', 'size', size);\n }\n});\n","var $ = require('../internals/export');\nvar toAbsoluteIndex = require('../internals/to-absolute-index');\n\nvar fromCharCode = String.fromCharCode;\nvar nativeFromCodePoint = String.fromCodePoint;\n\n// length should be 1, old FF problem\nvar INCORRECT_LENGTH = !!nativeFromCodePoint && nativeFromCodePoint.length != 1;\n\n// `String.fromCodePoint` method\n// https://tc39.github.io/ecma262/#sec-string.fromcodepoint\n$({ target: 'String', stat: true, forced: INCORRECT_LENGTH }, {\n fromCodePoint: function fromCodePoint(x) { // eslint-disable-line no-unused-vars\n var elements = [];\n var length = arguments.length;\n var i = 0;\n var code;\n while (length > i) {\n code = +arguments[i++];\n if (toAbsoluteIndex(code, 0x10FFFF) !== code) throw RangeError(code + ' is not a valid code point');\n elements.push(code < 0x10000\n ? fromCharCode(code)\n : fromCharCode(((code -= 0x10000) >> 10) + 0xD800, code % 0x400 + 0xDC00)\n );\n } return elements.join('');\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar notARegExp = require('../internals/not-a-regexp');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\nvar correctIsRegExpLogic = require('../internals/correct-is-regexp-logic');\n\n// `String.prototype.includes` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.includes\n$({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }, {\n includes: function includes(searchString /* , position = 0 */) {\n return !!~String(requireObjectCoercible(this))\n .indexOf(notARegExp(searchString), arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar createHTML = require('../internals/create-html');\nvar forcedStringHTMLMethod = require('../internals/string-html-forced');\n\n// `String.prototype.italics` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.italics\n$({ target: 'String', proto: true, forced: forcedStringHTMLMethod('italics') }, {\n italics: function italics() {\n return createHTML(this, 'i', '', '');\n }\n});\n","'use strict';\nvar charAt = require('../internals/string-multibyte').charAt;\nvar InternalStateModule = require('../internals/internal-state');\nvar defineIterator = require('../internals/define-iterator');\n\nvar STRING_ITERATOR = 'String Iterator';\nvar setInternalState = InternalStateModule.set;\nvar getInternalState = InternalStateModule.getterFor(STRING_ITERATOR);\n\n// `String.prototype[@@iterator]` method\n// https://tc39.github.io/ecma262/#sec-string.prototype-@@iterator\ndefineIterator(String, 'String', function (iterated) {\n setInternalState(this, {\n type: STRING_ITERATOR,\n string: String(iterated),\n index: 0\n });\n// `%StringIteratorPrototype%.next` method\n// https://tc39.github.io/ecma262/#sec-%stringiteratorprototype%.next\n}, function next() {\n var state = getInternalState(this);\n var string = state.string;\n var index = state.index;\n var point;\n if (index >= string.length) return { value: undefined, done: true };\n point = charAt(string, index);\n state.index += point.length;\n return { value: point, done: false };\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar createHTML = require('../internals/create-html');\nvar forcedStringHTMLMethod = require('../internals/string-html-forced');\n\n// `String.prototype.link` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.link\n$({ target: 'String', proto: true, forced: forcedStringHTMLMethod('link') }, {\n link: function link(url) {\n return createHTML(this, 'a', 'href', url);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar createIteratorConstructor = require('../internals/create-iterator-constructor');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\nvar toLength = require('../internals/to-length');\nvar aFunction = require('../internals/a-function');\nvar anObject = require('../internals/an-object');\nvar classof = require('../internals/classof-raw');\nvar isRegExp = require('../internals/is-regexp');\nvar getRegExpFlags = require('../internals/regexp-flags');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar fails = require('../internals/fails');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar speciesConstructor = require('../internals/species-constructor');\nvar advanceStringIndex = require('../internals/advance-string-index');\nvar InternalStateModule = require('../internals/internal-state');\nvar IS_PURE = require('../internals/is-pure');\n\nvar MATCH_ALL = wellKnownSymbol('matchAll');\nvar REGEXP_STRING = 'RegExp String';\nvar REGEXP_STRING_ITERATOR = REGEXP_STRING + ' Iterator';\nvar setInternalState = InternalStateModule.set;\nvar getInternalState = InternalStateModule.getterFor(REGEXP_STRING_ITERATOR);\nvar RegExpPrototype = RegExp.prototype;\nvar regExpBuiltinExec = RegExpPrototype.exec;\nvar nativeMatchAll = ''.matchAll;\n\nvar WORKS_WITH_NON_GLOBAL_REGEX = !!nativeMatchAll && !fails(function () {\n 'a'.matchAll(/./);\n});\n\nvar regExpExec = function (R, S) {\n var exec = R.exec;\n var result;\n if (typeof exec == 'function') {\n result = exec.call(R, S);\n if (typeof result != 'object') throw TypeError('Incorrect exec result');\n return result;\n } return regExpBuiltinExec.call(R, S);\n};\n\n// eslint-disable-next-line max-len\nvar $RegExpStringIterator = createIteratorConstructor(function RegExpStringIterator(regexp, string, global, fullUnicode) {\n setInternalState(this, {\n type: REGEXP_STRING_ITERATOR,\n regexp: regexp,\n string: string,\n global: global,\n unicode: fullUnicode,\n done: false\n });\n}, REGEXP_STRING, function next() {\n var state = getInternalState(this);\n if (state.done) return { value: undefined, done: true };\n var R = state.regexp;\n var S = state.string;\n var match = regExpExec(R, S);\n if (match === null) return { value: undefined, done: state.done = true };\n if (state.global) {\n if (String(match[0]) == '') R.lastIndex = advanceStringIndex(S, toLength(R.lastIndex), state.unicode);\n return { value: match, done: false };\n }\n state.done = true;\n return { value: match, done: false };\n});\n\nvar $matchAll = function (string) {\n var R = anObject(this);\n var S = String(string);\n var C, flagsValue, flags, matcher, global, fullUnicode;\n C = speciesConstructor(R, RegExp);\n flagsValue = R.flags;\n if (flagsValue === undefined && R instanceof RegExp && !('flags' in RegExpPrototype)) {\n flagsValue = getRegExpFlags.call(R);\n }\n flags = flagsValue === undefined ? '' : String(flagsValue);\n matcher = new C(C === RegExp ? R.source : R, flags);\n global = !!~flags.indexOf('g');\n fullUnicode = !!~flags.indexOf('u');\n matcher.lastIndex = toLength(R.lastIndex);\n return new $RegExpStringIterator(matcher, S, global, fullUnicode);\n};\n\n// `String.prototype.matchAll` method\n// https://github.com/tc39/proposal-string-matchall\n$({ target: 'String', proto: true, forced: WORKS_WITH_NON_GLOBAL_REGEX }, {\n matchAll: function matchAll(regexp) {\n var O = requireObjectCoercible(this);\n var flags, S, matcher, rx;\n if (regexp != null) {\n if (isRegExp(regexp)) {\n flags = String(requireObjectCoercible('flags' in RegExpPrototype\n ? regexp.flags\n : getRegExpFlags.call(regexp)\n ));\n if (!~flags.indexOf('g')) throw TypeError('`.matchAll` does not allow non-global regexes');\n }\n if (WORKS_WITH_NON_GLOBAL_REGEX) return nativeMatchAll.apply(O, arguments);\n matcher = regexp[MATCH_ALL];\n if (matcher === undefined && IS_PURE && classof(regexp) == 'RegExp') matcher = $matchAll;\n if (matcher != null) return aFunction(matcher).call(regexp, O);\n } else if (WORKS_WITH_NON_GLOBAL_REGEX) return nativeMatchAll.apply(O, arguments);\n S = String(O);\n rx = new RegExp(regexp, 'g');\n return IS_PURE ? $matchAll.call(rx, S) : rx[MATCH_ALL](S);\n }\n});\n\nIS_PURE || MATCH_ALL in RegExpPrototype || createNonEnumerableProperty(RegExpPrototype, MATCH_ALL, $matchAll);\n","'use strict';\nvar fixRegExpWellKnownSymbolLogic = require('../internals/fix-regexp-well-known-symbol-logic');\nvar anObject = require('../internals/an-object');\nvar toLength = require('../internals/to-length');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\nvar advanceStringIndex = require('../internals/advance-string-index');\nvar regExpExec = require('../internals/regexp-exec-abstract');\n\n// @@match logic\nfixRegExpWellKnownSymbolLogic('match', 1, function (MATCH, nativeMatch, maybeCallNative) {\n return [\n // `String.prototype.match` method\n // https://tc39.github.io/ecma262/#sec-string.prototype.match\n function match(regexp) {\n var O = requireObjectCoercible(this);\n var matcher = regexp == undefined ? undefined : regexp[MATCH];\n return matcher !== undefined ? matcher.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));\n },\n // `RegExp.prototype[@@match]` method\n // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@match\n function (regexp) {\n var res = maybeCallNative(nativeMatch, regexp, this);\n if (res.done) return res.value;\n\n var rx = anObject(regexp);\n var S = String(this);\n\n if (!rx.global) return regExpExec(rx, S);\n\n var fullUnicode = rx.unicode;\n rx.lastIndex = 0;\n var A = [];\n var n = 0;\n var result;\n while ((result = regExpExec(rx, S)) !== null) {\n var matchStr = String(result[0]);\n A[n] = matchStr;\n if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);\n n++;\n }\n return n === 0 ? null : A;\n }\n ];\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar $padEnd = require('../internals/string-pad').end;\nvar WEBKIT_BUG = require('../internals/string-pad-webkit-bug');\n\n// `String.prototype.padEnd` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.padend\n$({ target: 'String', proto: true, forced: WEBKIT_BUG }, {\n padEnd: function padEnd(maxLength /* , fillString = ' ' */) {\n return $padEnd(this, maxLength, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar $padStart = require('../internals/string-pad').start;\nvar WEBKIT_BUG = require('../internals/string-pad-webkit-bug');\n\n// `String.prototype.padStart` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.padstart\n$({ target: 'String', proto: true, forced: WEBKIT_BUG }, {\n padStart: function padStart(maxLength /* , fillString = ' ' */) {\n return $padStart(this, maxLength, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n","var $ = require('../internals/export');\nvar toIndexedObject = require('../internals/to-indexed-object');\nvar toLength = require('../internals/to-length');\n\n// `String.raw` method\n// https://tc39.github.io/ecma262/#sec-string.raw\n$({ target: 'String', stat: true }, {\n raw: function raw(template) {\n var rawTemplate = toIndexedObject(template.raw);\n var literalSegments = toLength(rawTemplate.length);\n var argumentsLength = arguments.length;\n var elements = [];\n var i = 0;\n while (literalSegments > i) {\n elements.push(String(rawTemplate[i++]));\n if (i < argumentsLength) elements.push(String(arguments[i]));\n } return elements.join('');\n }\n});\n","var $ = require('../internals/export');\nvar repeat = require('../internals/string-repeat');\n\n// `String.prototype.repeat` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.repeat\n$({ target: 'String', proto: true }, {\n repeat: repeat\n});\n","'use strict';\nvar fixRegExpWellKnownSymbolLogic = require('../internals/fix-regexp-well-known-symbol-logic');\nvar anObject = require('../internals/an-object');\nvar toObject = require('../internals/to-object');\nvar toLength = require('../internals/to-length');\nvar toInteger = require('../internals/to-integer');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\nvar advanceStringIndex = require('../internals/advance-string-index');\nvar regExpExec = require('../internals/regexp-exec-abstract');\n\nvar max = Math.max;\nvar min = Math.min;\nvar floor = Math.floor;\nvar SUBSTITUTION_SYMBOLS = /\\$([$&'`]|\\d\\d?|<[^>]*>)/g;\nvar SUBSTITUTION_SYMBOLS_NO_NAMED = /\\$([$&'`]|\\d\\d?)/g;\n\nvar maybeToString = function (it) {\n return it === undefined ? it : String(it);\n};\n\n// @@replace logic\nfixRegExpWellKnownSymbolLogic('replace', 2, function (REPLACE, nativeReplace, maybeCallNative, reason) {\n var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = reason.REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE;\n var REPLACE_KEEPS_$0 = reason.REPLACE_KEEPS_$0;\n var UNSAFE_SUBSTITUTE = REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE ? '$' : '$0';\n\n return [\n // `String.prototype.replace` method\n // https://tc39.github.io/ecma262/#sec-string.prototype.replace\n function replace(searchValue, replaceValue) {\n var O = requireObjectCoercible(this);\n var replacer = searchValue == undefined ? undefined : searchValue[REPLACE];\n return replacer !== undefined\n ? replacer.call(searchValue, O, replaceValue)\n : nativeReplace.call(String(O), searchValue, replaceValue);\n },\n // `RegExp.prototype[@@replace]` method\n // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@replace\n function (regexp, replaceValue) {\n if (\n (!REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE && REPLACE_KEEPS_$0) ||\n (typeof replaceValue === 'string' && replaceValue.indexOf(UNSAFE_SUBSTITUTE) === -1)\n ) {\n var res = maybeCallNative(nativeReplace, regexp, this, replaceValue);\n if (res.done) return res.value;\n }\n\n var rx = anObject(regexp);\n var S = String(this);\n\n var functionalReplace = typeof replaceValue === 'function';\n if (!functionalReplace) replaceValue = String(replaceValue);\n\n var global = rx.global;\n if (global) {\n var fullUnicode = rx.unicode;\n rx.lastIndex = 0;\n }\n var results = [];\n while (true) {\n var result = regExpExec(rx, S);\n if (result === null) break;\n\n results.push(result);\n if (!global) break;\n\n var matchStr = String(result[0]);\n if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);\n }\n\n var accumulatedResult = '';\n var nextSourcePosition = 0;\n for (var i = 0; i < results.length; i++) {\n result = results[i];\n\n var matched = String(result[0]);\n var position = max(min(toInteger(result.index), S.length), 0);\n var captures = [];\n // NOTE: This is equivalent to\n // captures = result.slice(1).map(maybeToString)\n // but for some reason `nativeSlice.call(result, 1, result.length)` (called in\n // the slice polyfill when slicing native arrays) \"doesn't work\" in safari 9 and\n // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it.\n for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j]));\n var namedCaptures = result.groups;\n if (functionalReplace) {\n var replacerArgs = [matched].concat(captures, position, S);\n if (namedCaptures !== undefined) replacerArgs.push(namedCaptures);\n var replacement = String(replaceValue.apply(undefined, replacerArgs));\n } else {\n replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue);\n }\n if (position >= nextSourcePosition) {\n accumulatedResult += S.slice(nextSourcePosition, position) + replacement;\n nextSourcePosition = position + matched.length;\n }\n }\n return accumulatedResult + S.slice(nextSourcePosition);\n }\n ];\n\n // https://tc39.github.io/ecma262/#sec-getsubstitution\n function getSubstitution(matched, str, position, captures, namedCaptures, replacement) {\n var tailPos = position + matched.length;\n var m = captures.length;\n var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;\n if (namedCaptures !== undefined) {\n namedCaptures = toObject(namedCaptures);\n symbols = SUBSTITUTION_SYMBOLS;\n }\n return nativeReplace.call(replacement, symbols, function (match, ch) {\n var capture;\n switch (ch.charAt(0)) {\n case '$': return '$';\n case '&': return matched;\n case '`': return str.slice(0, position);\n case \"'\": return str.slice(tailPos);\n case '<':\n capture = namedCaptures[ch.slice(1, -1)];\n break;\n default: // \\d\\d?\n var n = +ch;\n if (n === 0) return match;\n if (n > m) {\n var f = floor(n / 10);\n if (f === 0) return match;\n if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1);\n return match;\n }\n capture = captures[n - 1];\n }\n return capture === undefined ? '' : capture;\n });\n }\n});\n","'use strict';\nvar fixRegExpWellKnownSymbolLogic = require('../internals/fix-regexp-well-known-symbol-logic');\nvar anObject = require('../internals/an-object');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\nvar sameValue = require('../internals/same-value');\nvar regExpExec = require('../internals/regexp-exec-abstract');\n\n// @@search logic\nfixRegExpWellKnownSymbolLogic('search', 1, function (SEARCH, nativeSearch, maybeCallNative) {\n return [\n // `String.prototype.search` method\n // https://tc39.github.io/ecma262/#sec-string.prototype.search\n function search(regexp) {\n var O = requireObjectCoercible(this);\n var searcher = regexp == undefined ? undefined : regexp[SEARCH];\n return searcher !== undefined ? searcher.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O));\n },\n // `RegExp.prototype[@@search]` method\n // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@search\n function (regexp) {\n var res = maybeCallNative(nativeSearch, regexp, this);\n if (res.done) return res.value;\n\n var rx = anObject(regexp);\n var S = String(this);\n\n var previousLastIndex = rx.lastIndex;\n if (!sameValue(previousLastIndex, 0)) rx.lastIndex = 0;\n var result = regExpExec(rx, S);\n if (!sameValue(rx.lastIndex, previousLastIndex)) rx.lastIndex = previousLastIndex;\n return result === null ? -1 : result.index;\n }\n ];\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar createHTML = require('../internals/create-html');\nvar forcedStringHTMLMethod = require('../internals/string-html-forced');\n\n// `String.prototype.small` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.small\n$({ target: 'String', proto: true, forced: forcedStringHTMLMethod('small') }, {\n small: function small() {\n return createHTML(this, 'small', '', '');\n }\n});\n","'use strict';\nvar fixRegExpWellKnownSymbolLogic = require('../internals/fix-regexp-well-known-symbol-logic');\nvar isRegExp = require('../internals/is-regexp');\nvar anObject = require('../internals/an-object');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\nvar speciesConstructor = require('../internals/species-constructor');\nvar advanceStringIndex = require('../internals/advance-string-index');\nvar toLength = require('../internals/to-length');\nvar callRegExpExec = require('../internals/regexp-exec-abstract');\nvar regexpExec = require('../internals/regexp-exec');\nvar fails = require('../internals/fails');\n\nvar arrayPush = [].push;\nvar min = Math.min;\nvar MAX_UINT32 = 0xFFFFFFFF;\n\n// babel-minify transpiles RegExp('x', 'y') -> /x/y and it causes SyntaxError\nvar SUPPORTS_Y = !fails(function () { return !RegExp(MAX_UINT32, 'y'); });\n\n// @@split logic\nfixRegExpWellKnownSymbolLogic('split', 2, function (SPLIT, nativeSplit, maybeCallNative) {\n var internalSplit;\n if (\n 'abbc'.split(/(b)*/)[1] == 'c' ||\n 'test'.split(/(?:)/, -1).length != 4 ||\n 'ab'.split(/(?:ab)*/).length != 2 ||\n '.'.split(/(.?)(.?)/).length != 4 ||\n '.'.split(/()()/).length > 1 ||\n ''.split(/.?/).length\n ) {\n // based on es5-shim implementation, need to rework it\n internalSplit = function (separator, limit) {\n var string = String(requireObjectCoercible(this));\n var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;\n if (lim === 0) return [];\n if (separator === undefined) return [string];\n // If `separator` is not a regex, use native split\n if (!isRegExp(separator)) {\n return nativeSplit.call(string, separator, lim);\n }\n var output = [];\n var flags = (separator.ignoreCase ? 'i' : '') +\n (separator.multiline ? 'm' : '') +\n (separator.unicode ? 'u' : '') +\n (separator.sticky ? 'y' : '');\n var lastLastIndex = 0;\n // Make `global` and avoid `lastIndex` issues by working with a copy\n var separatorCopy = new RegExp(separator.source, flags + 'g');\n var match, lastIndex, lastLength;\n while (match = regexpExec.call(separatorCopy, string)) {\n lastIndex = separatorCopy.lastIndex;\n if (lastIndex > lastLastIndex) {\n output.push(string.slice(lastLastIndex, match.index));\n if (match.length > 1 && match.index < string.length) arrayPush.apply(output, match.slice(1));\n lastLength = match[0].length;\n lastLastIndex = lastIndex;\n if (output.length >= lim) break;\n }\n if (separatorCopy.lastIndex === match.index) separatorCopy.lastIndex++; // Avoid an infinite loop\n }\n if (lastLastIndex === string.length) {\n if (lastLength || !separatorCopy.test('')) output.push('');\n } else output.push(string.slice(lastLastIndex));\n return output.length > lim ? output.slice(0, lim) : output;\n };\n // Chakra, V8\n } else if ('0'.split(undefined, 0).length) {\n internalSplit = function (separator, limit) {\n return separator === undefined && limit === 0 ? [] : nativeSplit.call(this, separator, limit);\n };\n } else internalSplit = nativeSplit;\n\n return [\n // `String.prototype.split` method\n // https://tc39.github.io/ecma262/#sec-string.prototype.split\n function split(separator, limit) {\n var O = requireObjectCoercible(this);\n var splitter = separator == undefined ? undefined : separator[SPLIT];\n return splitter !== undefined\n ? splitter.call(separator, O, limit)\n : internalSplit.call(String(O), separator, limit);\n },\n // `RegExp.prototype[@@split]` method\n // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@split\n //\n // NOTE: This cannot be properly polyfilled in engines that don't support\n // the 'y' flag.\n function (regexp, limit) {\n var res = maybeCallNative(internalSplit, regexp, this, limit, internalSplit !== nativeSplit);\n if (res.done) return res.value;\n\n var rx = anObject(regexp);\n var S = String(this);\n var C = speciesConstructor(rx, RegExp);\n\n var unicodeMatching = rx.unicode;\n var flags = (rx.ignoreCase ? 'i' : '') +\n (rx.multiline ? 'm' : '') +\n (rx.unicode ? 'u' : '') +\n (SUPPORTS_Y ? 'y' : 'g');\n\n // ^(? + rx + ) is needed, in combination with some S slicing, to\n // simulate the 'y' flag.\n var splitter = new C(SUPPORTS_Y ? rx : '^(?:' + rx.source + ')', flags);\n var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;\n if (lim === 0) return [];\n if (S.length === 0) return callRegExpExec(splitter, S) === null ? [S] : [];\n var p = 0;\n var q = 0;\n var A = [];\n while (q < S.length) {\n splitter.lastIndex = SUPPORTS_Y ? q : 0;\n var z = callRegExpExec(splitter, SUPPORTS_Y ? S : S.slice(q));\n var e;\n if (\n z === null ||\n (e = min(toLength(splitter.lastIndex + (SUPPORTS_Y ? 0 : q)), S.length)) === p\n ) {\n q = advanceStringIndex(S, q, unicodeMatching);\n } else {\n A.push(S.slice(p, q));\n if (A.length === lim) return A;\n for (var i = 1; i <= z.length - 1; i++) {\n A.push(z[i]);\n if (A.length === lim) return A;\n }\n q = p = e;\n }\n }\n A.push(S.slice(p));\n return A;\n }\n ];\n}, !SUPPORTS_Y);\n","'use strict';\nvar $ = require('../internals/export');\nvar getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;\nvar toLength = require('../internals/to-length');\nvar notARegExp = require('../internals/not-a-regexp');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\nvar correctIsRegExpLogic = require('../internals/correct-is-regexp-logic');\nvar IS_PURE = require('../internals/is-pure');\n\nvar nativeStartsWith = ''.startsWith;\nvar min = Math.min;\n\nvar CORRECT_IS_REGEXP_LOGIC = correctIsRegExpLogic('startsWith');\n// https://github.com/zloirock/core-js/pull/702\nvar MDN_POLYFILL_BUG = !IS_PURE && !CORRECT_IS_REGEXP_LOGIC && !!function () {\n var descriptor = getOwnPropertyDescriptor(String.prototype, 'startsWith');\n return descriptor && !descriptor.writable;\n}();\n\n// `String.prototype.startsWith` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.startswith\n$({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC }, {\n startsWith: function startsWith(searchString /* , position = 0 */) {\n var that = String(requireObjectCoercible(this));\n notARegExp(searchString);\n var index = toLength(min(arguments.length > 1 ? arguments[1] : undefined, that.length));\n var search = String(searchString);\n return nativeStartsWith\n ? nativeStartsWith.call(that, search, index)\n : that.slice(index, index + search.length) === search;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar createHTML = require('../internals/create-html');\nvar forcedStringHTMLMethod = require('../internals/string-html-forced');\n\n// `String.prototype.strike` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.strike\n$({ target: 'String', proto: true, forced: forcedStringHTMLMethod('strike') }, {\n strike: function strike() {\n return createHTML(this, 'strike', '', '');\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar createHTML = require('../internals/create-html');\nvar forcedStringHTMLMethod = require('../internals/string-html-forced');\n\n// `String.prototype.sub` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.sub\n$({ target: 'String', proto: true, forced: forcedStringHTMLMethod('sub') }, {\n sub: function sub() {\n return createHTML(this, 'sub', '', '');\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar createHTML = require('../internals/create-html');\nvar forcedStringHTMLMethod = require('../internals/string-html-forced');\n\n// `String.prototype.sup` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.sup\n$({ target: 'String', proto: true, forced: forcedStringHTMLMethod('sup') }, {\n sup: function sup() {\n return createHTML(this, 'sup', '', '');\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar $trimEnd = require('../internals/string-trim').end;\nvar forcedStringTrimMethod = require('../internals/string-trim-forced');\n\nvar FORCED = forcedStringTrimMethod('trimEnd');\n\nvar trimEnd = FORCED ? function trimEnd() {\n return $trimEnd(this);\n} : ''.trimEnd;\n\n// `String.prototype.{ trimEnd, trimRight }` methods\n// https://github.com/tc39/ecmascript-string-left-right-trim\n$({ target: 'String', proto: true, forced: FORCED }, {\n trimEnd: trimEnd,\n trimRight: trimEnd\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar $trimStart = require('../internals/string-trim').start;\nvar forcedStringTrimMethod = require('../internals/string-trim-forced');\n\nvar FORCED = forcedStringTrimMethod('trimStart');\n\nvar trimStart = FORCED ? function trimStart() {\n return $trimStart(this);\n} : ''.trimStart;\n\n// `String.prototype.{ trimStart, trimLeft }` methods\n// https://github.com/tc39/ecmascript-string-left-right-trim\n$({ target: 'String', proto: true, forced: FORCED }, {\n trimStart: trimStart,\n trimLeft: trimStart\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar $trim = require('../internals/string-trim').trim;\nvar forcedStringTrimMethod = require('../internals/string-trim-forced');\n\n// `String.prototype.trim` method\n// https://tc39.github.io/ecma262/#sec-string.prototype.trim\n$({ target: 'String', proto: true, forced: forcedStringTrimMethod('trim') }, {\n trim: function trim() {\n return $trim(this);\n }\n});\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.asyncIterator` well-known symbol\n// https://tc39.github.io/ecma262/#sec-symbol.asynciterator\ndefineWellKnownSymbol('asyncIterator');\n","// `Symbol.prototype.description` getter\n// https://tc39.github.io/ecma262/#sec-symbol.prototype.description\n'use strict';\nvar $ = require('../internals/export');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar global = require('../internals/global');\nvar has = require('../internals/has');\nvar isObject = require('../internals/is-object');\nvar defineProperty = require('../internals/object-define-property').f;\nvar copyConstructorProperties = require('../internals/copy-constructor-properties');\n\nvar NativeSymbol = global.Symbol;\n\nif (DESCRIPTORS && typeof NativeSymbol == 'function' && (!('description' in NativeSymbol.prototype) ||\n // Safari 12 bug\n NativeSymbol().description !== undefined\n)) {\n var EmptyStringDescriptionStore = {};\n // wrap Symbol constructor for correct work with undefined description\n var SymbolWrapper = function Symbol() {\n var description = arguments.length < 1 || arguments[0] === undefined ? undefined : String(arguments[0]);\n var result = this instanceof SymbolWrapper\n ? new NativeSymbol(description)\n // in Edge 13, String(Symbol(undefined)) === 'Symbol(undefined)'\n : description === undefined ? NativeSymbol() : NativeSymbol(description);\n if (description === '') EmptyStringDescriptionStore[result] = true;\n return result;\n };\n copyConstructorProperties(SymbolWrapper, NativeSymbol);\n var symbolPrototype = SymbolWrapper.prototype = NativeSymbol.prototype;\n symbolPrototype.constructor = SymbolWrapper;\n\n var symbolToString = symbolPrototype.toString;\n var native = String(NativeSymbol('test')) == 'Symbol(test)';\n var regexp = /^Symbol\\((.*)\\)[^)]+$/;\n defineProperty(symbolPrototype, 'description', {\n configurable: true,\n get: function description() {\n var symbol = isObject(this) ? this.valueOf() : this;\n var string = symbolToString.call(symbol);\n if (has(EmptyStringDescriptionStore, symbol)) return '';\n var desc = native ? string.slice(7, -1) : string.replace(regexp, '$1');\n return desc === '' ? undefined : desc;\n }\n });\n\n $({ global: true, forced: true }, {\n Symbol: SymbolWrapper\n });\n}\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.hasInstance` well-known symbol\n// https://tc39.github.io/ecma262/#sec-symbol.hasinstance\ndefineWellKnownSymbol('hasInstance');\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.isConcatSpreadable` well-known symbol\n// https://tc39.github.io/ecma262/#sec-symbol.isconcatspreadable\ndefineWellKnownSymbol('isConcatSpreadable');\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.iterator` well-known symbol\n// https://tc39.github.io/ecma262/#sec-symbol.iterator\ndefineWellKnownSymbol('iterator');\n","'use strict';\nvar $ = require('../internals/export');\nvar global = require('../internals/global');\nvar getBuiltIn = require('../internals/get-built-in');\nvar IS_PURE = require('../internals/is-pure');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar NATIVE_SYMBOL = require('../internals/native-symbol');\nvar USE_SYMBOL_AS_UID = require('../internals/use-symbol-as-uid');\nvar fails = require('../internals/fails');\nvar has = require('../internals/has');\nvar isArray = require('../internals/is-array');\nvar isObject = require('../internals/is-object');\nvar anObject = require('../internals/an-object');\nvar toObject = require('../internals/to-object');\nvar toIndexedObject = require('../internals/to-indexed-object');\nvar toPrimitive = require('../internals/to-primitive');\nvar createPropertyDescriptor = require('../internals/create-property-descriptor');\nvar nativeObjectCreate = require('../internals/object-create');\nvar objectKeys = require('../internals/object-keys');\nvar getOwnPropertyNamesModule = require('../internals/object-get-own-property-names');\nvar getOwnPropertyNamesExternal = require('../internals/object-get-own-property-names-external');\nvar getOwnPropertySymbolsModule = require('../internals/object-get-own-property-symbols');\nvar getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');\nvar definePropertyModule = require('../internals/object-define-property');\nvar propertyIsEnumerableModule = require('../internals/object-property-is-enumerable');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar redefine = require('../internals/redefine');\nvar shared = require('../internals/shared');\nvar sharedKey = require('../internals/shared-key');\nvar hiddenKeys = require('../internals/hidden-keys');\nvar uid = require('../internals/uid');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar wrappedWellKnownSymbolModule = require('../internals/well-known-symbol-wrapped');\nvar defineWellKnownSymbol = require('../internals/define-well-known-symbol');\nvar setToStringTag = require('../internals/set-to-string-tag');\nvar InternalStateModule = require('../internals/internal-state');\nvar $forEach = require('../internals/array-iteration').forEach;\n\nvar HIDDEN = sharedKey('hidden');\nvar SYMBOL = 'Symbol';\nvar PROTOTYPE = 'prototype';\nvar TO_PRIMITIVE = wellKnownSymbol('toPrimitive');\nvar setInternalState = InternalStateModule.set;\nvar getInternalState = InternalStateModule.getterFor(SYMBOL);\nvar ObjectPrototype = Object[PROTOTYPE];\nvar $Symbol = global.Symbol;\nvar $stringify = getBuiltIn('JSON', 'stringify');\nvar nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;\nvar nativeDefineProperty = definePropertyModule.f;\nvar nativeGetOwnPropertyNames = getOwnPropertyNamesExternal.f;\nvar nativePropertyIsEnumerable = propertyIsEnumerableModule.f;\nvar AllSymbols = shared('symbols');\nvar ObjectPrototypeSymbols = shared('op-symbols');\nvar StringToSymbolRegistry = shared('string-to-symbol-registry');\nvar SymbolToStringRegistry = shared('symbol-to-string-registry');\nvar WellKnownSymbolsStore = shared('wks');\nvar QObject = global.QObject;\n// Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173\nvar USE_SETTER = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;\n\n// fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687\nvar setSymbolDescriptor = DESCRIPTORS && fails(function () {\n return nativeObjectCreate(nativeDefineProperty({}, 'a', {\n get: function () { return nativeDefineProperty(this, 'a', { value: 7 }).a; }\n })).a != 7;\n}) ? function (O, P, Attributes) {\n var ObjectPrototypeDescriptor = nativeGetOwnPropertyDescriptor(ObjectPrototype, P);\n if (ObjectPrototypeDescriptor) delete ObjectPrototype[P];\n nativeDefineProperty(O, P, Attributes);\n if (ObjectPrototypeDescriptor && O !== ObjectPrototype) {\n nativeDefineProperty(ObjectPrototype, P, ObjectPrototypeDescriptor);\n }\n} : nativeDefineProperty;\n\nvar wrap = function (tag, description) {\n var symbol = AllSymbols[tag] = nativeObjectCreate($Symbol[PROTOTYPE]);\n setInternalState(symbol, {\n type: SYMBOL,\n tag: tag,\n description: description\n });\n if (!DESCRIPTORS) symbol.description = description;\n return symbol;\n};\n\nvar isSymbol = USE_SYMBOL_AS_UID ? function (it) {\n return typeof it == 'symbol';\n} : function (it) {\n return Object(it) instanceof $Symbol;\n};\n\nvar $defineProperty = function defineProperty(O, P, Attributes) {\n if (O === ObjectPrototype) $defineProperty(ObjectPrototypeSymbols, P, Attributes);\n anObject(O);\n var key = toPrimitive(P, true);\n anObject(Attributes);\n if (has(AllSymbols, key)) {\n if (!Attributes.enumerable) {\n if (!has(O, HIDDEN)) nativeDefineProperty(O, HIDDEN, createPropertyDescriptor(1, {}));\n O[HIDDEN][key] = true;\n } else {\n if (has(O, HIDDEN) && O[HIDDEN][key]) O[HIDDEN][key] = false;\n Attributes = nativeObjectCreate(Attributes, { enumerable: createPropertyDescriptor(0, false) });\n } return setSymbolDescriptor(O, key, Attributes);\n } return nativeDefineProperty(O, key, Attributes);\n};\n\nvar $defineProperties = function defineProperties(O, Properties) {\n anObject(O);\n var properties = toIndexedObject(Properties);\n var keys = objectKeys(properties).concat($getOwnPropertySymbols(properties));\n $forEach(keys, function (key) {\n if (!DESCRIPTORS || $propertyIsEnumerable.call(properties, key)) $defineProperty(O, key, properties[key]);\n });\n return O;\n};\n\nvar $create = function create(O, Properties) {\n return Properties === undefined ? nativeObjectCreate(O) : $defineProperties(nativeObjectCreate(O), Properties);\n};\n\nvar $propertyIsEnumerable = function propertyIsEnumerable(V) {\n var P = toPrimitive(V, true);\n var enumerable = nativePropertyIsEnumerable.call(this, P);\n if (this === ObjectPrototype && has(AllSymbols, P) && !has(ObjectPrototypeSymbols, P)) return false;\n return enumerable || !has(this, P) || !has(AllSymbols, P) || has(this, HIDDEN) && this[HIDDEN][P] ? enumerable : true;\n};\n\nvar $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(O, P) {\n var it = toIndexedObject(O);\n var key = toPrimitive(P, true);\n if (it === ObjectPrototype && has(AllSymbols, key) && !has(ObjectPrototypeSymbols, key)) return;\n var descriptor = nativeGetOwnPropertyDescriptor(it, key);\n if (descriptor && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) {\n descriptor.enumerable = true;\n }\n return descriptor;\n};\n\nvar $getOwnPropertyNames = function getOwnPropertyNames(O) {\n var names = nativeGetOwnPropertyNames(toIndexedObject(O));\n var result = [];\n $forEach(names, function (key) {\n if (!has(AllSymbols, key) && !has(hiddenKeys, key)) result.push(key);\n });\n return result;\n};\n\nvar $getOwnPropertySymbols = function getOwnPropertySymbols(O) {\n var IS_OBJECT_PROTOTYPE = O === ObjectPrototype;\n var names = nativeGetOwnPropertyNames(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toIndexedObject(O));\n var result = [];\n $forEach(names, function (key) {\n if (has(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || has(ObjectPrototype, key))) {\n result.push(AllSymbols[key]);\n }\n });\n return result;\n};\n\n// `Symbol` constructor\n// https://tc39.github.io/ecma262/#sec-symbol-constructor\nif (!NATIVE_SYMBOL) {\n $Symbol = function Symbol() {\n if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor');\n var description = !arguments.length || arguments[0] === undefined ? undefined : String(arguments[0]);\n var tag = uid(description);\n var setter = function (value) {\n if (this === ObjectPrototype) setter.call(ObjectPrototypeSymbols, value);\n if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;\n setSymbolDescriptor(this, tag, createPropertyDescriptor(1, value));\n };\n if (DESCRIPTORS && USE_SETTER) setSymbolDescriptor(ObjectPrototype, tag, { configurable: true, set: setter });\n return wrap(tag, description);\n };\n\n redefine($Symbol[PROTOTYPE], 'toString', function toString() {\n return getInternalState(this).tag;\n });\n\n redefine($Symbol, 'withoutSetter', function (description) {\n return wrap(uid(description), description);\n });\n\n propertyIsEnumerableModule.f = $propertyIsEnumerable;\n definePropertyModule.f = $defineProperty;\n getOwnPropertyDescriptorModule.f = $getOwnPropertyDescriptor;\n getOwnPropertyNamesModule.f = getOwnPropertyNamesExternal.f = $getOwnPropertyNames;\n getOwnPropertySymbolsModule.f = $getOwnPropertySymbols;\n\n wrappedWellKnownSymbolModule.f = function (name) {\n return wrap(wellKnownSymbol(name), name);\n };\n\n if (DESCRIPTORS) {\n // https://github.com/tc39/proposal-Symbol-description\n nativeDefineProperty($Symbol[PROTOTYPE], 'description', {\n configurable: true,\n get: function description() {\n return getInternalState(this).description;\n }\n });\n if (!IS_PURE) {\n redefine(ObjectPrototype, 'propertyIsEnumerable', $propertyIsEnumerable, { unsafe: true });\n }\n }\n}\n\n$({ global: true, wrap: true, forced: !NATIVE_SYMBOL, sham: !NATIVE_SYMBOL }, {\n Symbol: $Symbol\n});\n\n$forEach(objectKeys(WellKnownSymbolsStore), function (name) {\n defineWellKnownSymbol(name);\n});\n\n$({ target: SYMBOL, stat: true, forced: !NATIVE_SYMBOL }, {\n // `Symbol.for` method\n // https://tc39.github.io/ecma262/#sec-symbol.for\n 'for': function (key) {\n var string = String(key);\n if (has(StringToSymbolRegistry, string)) return StringToSymbolRegistry[string];\n var symbol = $Symbol(string);\n StringToSymbolRegistry[string] = symbol;\n SymbolToStringRegistry[symbol] = string;\n return symbol;\n },\n // `Symbol.keyFor` method\n // https://tc39.github.io/ecma262/#sec-symbol.keyfor\n keyFor: function keyFor(sym) {\n if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol');\n if (has(SymbolToStringRegistry, sym)) return SymbolToStringRegistry[sym];\n },\n useSetter: function () { USE_SETTER = true; },\n useSimple: function () { USE_SETTER = false; }\n});\n\n$({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL, sham: !DESCRIPTORS }, {\n // `Object.create` method\n // https://tc39.github.io/ecma262/#sec-object.create\n create: $create,\n // `Object.defineProperty` method\n // https://tc39.github.io/ecma262/#sec-object.defineproperty\n defineProperty: $defineProperty,\n // `Object.defineProperties` method\n // https://tc39.github.io/ecma262/#sec-object.defineproperties\n defineProperties: $defineProperties,\n // `Object.getOwnPropertyDescriptor` method\n // https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptors\n getOwnPropertyDescriptor: $getOwnPropertyDescriptor\n});\n\n$({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL }, {\n // `Object.getOwnPropertyNames` method\n // https://tc39.github.io/ecma262/#sec-object.getownpropertynames\n getOwnPropertyNames: $getOwnPropertyNames,\n // `Object.getOwnPropertySymbols` method\n // https://tc39.github.io/ecma262/#sec-object.getownpropertysymbols\n getOwnPropertySymbols: $getOwnPropertySymbols\n});\n\n// Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives\n// https://bugs.chromium.org/p/v8/issues/detail?id=3443\n$({ target: 'Object', stat: true, forced: fails(function () { getOwnPropertySymbolsModule.f(1); }) }, {\n getOwnPropertySymbols: function getOwnPropertySymbols(it) {\n return getOwnPropertySymbolsModule.f(toObject(it));\n }\n});\n\n// `JSON.stringify` method behavior with symbols\n// https://tc39.github.io/ecma262/#sec-json.stringify\nif ($stringify) {\n var FORCED_JSON_STRINGIFY = !NATIVE_SYMBOL || fails(function () {\n var symbol = $Symbol();\n // MS Edge converts symbol values to JSON as {}\n return $stringify([symbol]) != '[null]'\n // WebKit converts symbol values to JSON as null\n || $stringify({ a: symbol }) != '{}'\n // V8 throws on boxed symbols\n || $stringify(Object(symbol)) != '{}';\n });\n\n $({ target: 'JSON', stat: true, forced: FORCED_JSON_STRINGIFY }, {\n // eslint-disable-next-line no-unused-vars\n stringify: function stringify(it, replacer, space) {\n var args = [it];\n var index = 1;\n var $replacer;\n while (arguments.length > index) args.push(arguments[index++]);\n $replacer = replacer;\n if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined\n if (!isArray(replacer)) replacer = function (key, value) {\n if (typeof $replacer == 'function') value = $replacer.call(this, key, value);\n if (!isSymbol(value)) return value;\n };\n args[1] = replacer;\n return $stringify.apply(null, args);\n }\n });\n}\n\n// `Symbol.prototype[@@toPrimitive]` method\n// https://tc39.github.io/ecma262/#sec-symbol.prototype-@@toprimitive\nif (!$Symbol[PROTOTYPE][TO_PRIMITIVE]) {\n createNonEnumerableProperty($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);\n}\n// `Symbol.prototype[@@toStringTag]` property\n// https://tc39.github.io/ecma262/#sec-symbol.prototype-@@tostringtag\nsetToStringTag($Symbol, SYMBOL);\n\nhiddenKeys[HIDDEN] = true;\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.match` well-known symbol\n// https://tc39.github.io/ecma262/#sec-symbol.match\ndefineWellKnownSymbol('match');\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.replace` well-known symbol\n// https://tc39.github.io/ecma262/#sec-symbol.replace\ndefineWellKnownSymbol('replace');\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.search` well-known symbol\n// https://tc39.github.io/ecma262/#sec-symbol.search\ndefineWellKnownSymbol('search');\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.species` well-known symbol\n// https://tc39.github.io/ecma262/#sec-symbol.species\ndefineWellKnownSymbol('species');\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.split` well-known symbol\n// https://tc39.github.io/ecma262/#sec-symbol.split\ndefineWellKnownSymbol('split');\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.toPrimitive` well-known symbol\n// https://tc39.github.io/ecma262/#sec-symbol.toprimitive\ndefineWellKnownSymbol('toPrimitive');\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.toStringTag` well-known symbol\n// https://tc39.github.io/ecma262/#sec-symbol.tostringtag\ndefineWellKnownSymbol('toStringTag');\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.unscopables` well-known symbol\n// https://tc39.github.io/ecma262/#sec-symbol.unscopables\ndefineWellKnownSymbol('unscopables');\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $copyWithin = require('../internals/array-copy-within');\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.copyWithin` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.copywithin\nexportTypedArrayMethod('copyWithin', function copyWithin(target, start /* , end */) {\n return $copyWithin.call(aTypedArray(this), target, start, arguments.length > 2 ? arguments[2] : undefined);\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $every = require('../internals/array-iteration').every;\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.every` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.every\nexportTypedArrayMethod('every', function every(callbackfn /* , thisArg */) {\n return $every(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $fill = require('../internals/array-fill');\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.fill` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.fill\n// eslint-disable-next-line no-unused-vars\nexportTypedArrayMethod('fill', function fill(value /* , start, end */) {\n return $fill.apply(aTypedArray(this), arguments);\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $filter = require('../internals/array-iteration').filter;\nvar speciesConstructor = require('../internals/species-constructor');\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.filter` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.filter\nexportTypedArrayMethod('filter', function filter(callbackfn /* , thisArg */) {\n var list = $filter(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n var C = speciesConstructor(this, this.constructor);\n var index = 0;\n var length = list.length;\n var result = new (aTypedArrayConstructor(C))(length);\n while (length > index) result[index] = list[index++];\n return result;\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $findIndex = require('../internals/array-iteration').findIndex;\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.findIndex` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.findindex\nexportTypedArrayMethod('findIndex', function findIndex(predicate /* , thisArg */) {\n return $findIndex(aTypedArray(this), predicate, arguments.length > 1 ? arguments[1] : undefined);\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $find = require('../internals/array-iteration').find;\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.find` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.find\nexportTypedArrayMethod('find', function find(predicate /* , thisArg */) {\n return $find(aTypedArray(this), predicate, arguments.length > 1 ? arguments[1] : undefined);\n});\n","var createTypedArrayConstructor = require('../internals/typed-array-constructor');\n\n// `Float32Array` constructor\n// https://tc39.github.io/ecma262/#sec-typedarray-objects\ncreateTypedArrayConstructor('Float32', function (init) {\n return function Float32Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","var createTypedArrayConstructor = require('../internals/typed-array-constructor');\n\n// `Float64Array` constructor\n// https://tc39.github.io/ecma262/#sec-typedarray-objects\ncreateTypedArrayConstructor('Float64', function (init) {\n return function Float64Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $forEach = require('../internals/array-iteration').forEach;\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.forEach` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.foreach\nexportTypedArrayMethod('forEach', function forEach(callbackfn /* , thisArg */) {\n $forEach(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n});\n","'use strict';\nvar TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS = require('../internals/typed-array-constructors-require-wrappers');\nvar exportTypedArrayStaticMethod = require('../internals/array-buffer-view-core').exportTypedArrayStaticMethod;\nvar typedArrayFrom = require('../internals/typed-array-from');\n\n// `%TypedArray%.from` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.from\nexportTypedArrayStaticMethod('from', typedArrayFrom, TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS);\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $includes = require('../internals/array-includes').includes;\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.includes` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.includes\nexportTypedArrayMethod('includes', function includes(searchElement /* , fromIndex */) {\n return $includes(aTypedArray(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $indexOf = require('../internals/array-includes').indexOf;\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.indexOf` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.indexof\nexportTypedArrayMethod('indexOf', function indexOf(searchElement /* , fromIndex */) {\n return $indexOf(aTypedArray(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);\n});\n","var createTypedArrayConstructor = require('../internals/typed-array-constructor');\n\n// `Int16Array` constructor\n// https://tc39.github.io/ecma262/#sec-typedarray-objects\ncreateTypedArrayConstructor('Int16', function (init) {\n return function Int16Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","var createTypedArrayConstructor = require('../internals/typed-array-constructor');\n\n// `Int32Array` constructor\n// https://tc39.github.io/ecma262/#sec-typedarray-objects\ncreateTypedArrayConstructor('Int32', function (init) {\n return function Int32Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","var createTypedArrayConstructor = require('../internals/typed-array-constructor');\n\n// `Int8Array` constructor\n// https://tc39.github.io/ecma262/#sec-typedarray-objects\ncreateTypedArrayConstructor('Int8', function (init) {\n return function Int8Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","'use strict';\nvar global = require('../internals/global');\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar ArrayIterators = require('../modules/es.array.iterator');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar ITERATOR = wellKnownSymbol('iterator');\nvar Uint8Array = global.Uint8Array;\nvar arrayValues = ArrayIterators.values;\nvar arrayKeys = ArrayIterators.keys;\nvar arrayEntries = ArrayIterators.entries;\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\nvar nativeTypedArrayIterator = Uint8Array && Uint8Array.prototype[ITERATOR];\n\nvar CORRECT_ITER_NAME = !!nativeTypedArrayIterator\n && (nativeTypedArrayIterator.name == 'values' || nativeTypedArrayIterator.name == undefined);\n\nvar typedArrayValues = function values() {\n return arrayValues.call(aTypedArray(this));\n};\n\n// `%TypedArray%.prototype.entries` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.entries\nexportTypedArrayMethod('entries', function entries() {\n return arrayEntries.call(aTypedArray(this));\n});\n// `%TypedArray%.prototype.keys` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.keys\nexportTypedArrayMethod('keys', function keys() {\n return arrayKeys.call(aTypedArray(this));\n});\n// `%TypedArray%.prototype.values` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.values\nexportTypedArrayMethod('values', typedArrayValues, !CORRECT_ITER_NAME);\n// `%TypedArray%.prototype[@@iterator]` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype-@@iterator\nexportTypedArrayMethod(ITERATOR, typedArrayValues, !CORRECT_ITER_NAME);\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\nvar $join = [].join;\n\n// `%TypedArray%.prototype.join` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.join\n// eslint-disable-next-line no-unused-vars\nexportTypedArrayMethod('join', function join(separator) {\n return $join.apply(aTypedArray(this), arguments);\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $lastIndexOf = require('../internals/array-last-index-of');\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.lastIndexOf` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.lastindexof\n// eslint-disable-next-line no-unused-vars\nexportTypedArrayMethod('lastIndexOf', function lastIndexOf(searchElement /* , fromIndex */) {\n return $lastIndexOf.apply(aTypedArray(this), arguments);\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $map = require('../internals/array-iteration').map;\nvar speciesConstructor = require('../internals/species-constructor');\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.map` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.map\nexportTypedArrayMethod('map', function map(mapfn /* , thisArg */) {\n return $map(aTypedArray(this), mapfn, arguments.length > 1 ? arguments[1] : undefined, function (O, length) {\n return new (aTypedArrayConstructor(speciesConstructor(O, O.constructor)))(length);\n });\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS = require('../internals/typed-array-constructors-require-wrappers');\n\nvar aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor;\nvar exportTypedArrayStaticMethod = ArrayBufferViewCore.exportTypedArrayStaticMethod;\n\n// `%TypedArray%.of` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.of\nexportTypedArrayStaticMethod('of', function of(/* ...items */) {\n var index = 0;\n var length = arguments.length;\n var result = new (aTypedArrayConstructor(this))(length);\n while (length > index) result[index] = arguments[index++];\n return result;\n}, TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS);\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $reduceRight = require('../internals/array-reduce').right;\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.reduceRicht` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.reduceright\nexportTypedArrayMethod('reduceRight', function reduceRight(callbackfn /* , initialValue */) {\n return $reduceRight(aTypedArray(this), callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined);\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $reduce = require('../internals/array-reduce').left;\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.reduce` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.reduce\nexportTypedArrayMethod('reduce', function reduce(callbackfn /* , initialValue */) {\n return $reduce(aTypedArray(this), callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined);\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\nvar floor = Math.floor;\n\n// `%TypedArray%.prototype.reverse` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.reverse\nexportTypedArrayMethod('reverse', function reverse() {\n var that = this;\n var length = aTypedArray(that).length;\n var middle = floor(length / 2);\n var index = 0;\n var value;\n while (index < middle) {\n value = that[index];\n that[index++] = that[--length];\n that[length] = value;\n } return that;\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar toLength = require('../internals/to-length');\nvar toOffset = require('../internals/to-offset');\nvar toObject = require('../internals/to-object');\nvar fails = require('../internals/fails');\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\nvar FORCED = fails(function () {\n // eslint-disable-next-line no-undef\n new Int8Array(1).set({});\n});\n\n// `%TypedArray%.prototype.set` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.set\nexportTypedArrayMethod('set', function set(arrayLike /* , offset */) {\n aTypedArray(this);\n var offset = toOffset(arguments.length > 1 ? arguments[1] : undefined, 1);\n var length = this.length;\n var src = toObject(arrayLike);\n var len = toLength(src.length);\n var index = 0;\n if (len + offset > length) throw RangeError('Wrong length');\n while (index < len) this[offset + index] = src[index++];\n}, FORCED);\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar speciesConstructor = require('../internals/species-constructor');\nvar fails = require('../internals/fails');\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\nvar $slice = [].slice;\n\nvar FORCED = fails(function () {\n // eslint-disable-next-line no-undef\n new Int8Array(1).slice();\n});\n\n// `%TypedArray%.prototype.slice` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.slice\nexportTypedArrayMethod('slice', function slice(start, end) {\n var list = $slice.call(aTypedArray(this), start, end);\n var C = speciesConstructor(this, this.constructor);\n var index = 0;\n var length = list.length;\n var result = new (aTypedArrayConstructor(C))(length);\n while (length > index) result[index] = list[index++];\n return result;\n}, FORCED);\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar $some = require('../internals/array-iteration').some;\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.some` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.some\nexportTypedArrayMethod('some', function some(callbackfn /* , thisArg */) {\n return $some(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\nvar $sort = [].sort;\n\n// `%TypedArray%.prototype.sort` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.sort\nexportTypedArrayMethod('sort', function sort(comparefn) {\n return $sort.call(aTypedArray(this), comparefn);\n});\n","'use strict';\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar toLength = require('../internals/to-length');\nvar toAbsoluteIndex = require('../internals/to-absolute-index');\nvar speciesConstructor = require('../internals/species-constructor');\n\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\n\n// `%TypedArray%.prototype.subarray` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.subarray\nexportTypedArrayMethod('subarray', function subarray(begin, end) {\n var O = aTypedArray(this);\n var length = O.length;\n var beginIndex = toAbsoluteIndex(begin, length);\n return new (speciesConstructor(O, O.constructor))(\n O.buffer,\n O.byteOffset + beginIndex * O.BYTES_PER_ELEMENT,\n toLength((end === undefined ? length : toAbsoluteIndex(end, length)) - beginIndex)\n );\n});\n","'use strict';\nvar global = require('../internals/global');\nvar ArrayBufferViewCore = require('../internals/array-buffer-view-core');\nvar fails = require('../internals/fails');\n\nvar Int8Array = global.Int8Array;\nvar aTypedArray = ArrayBufferViewCore.aTypedArray;\nvar exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;\nvar $toLocaleString = [].toLocaleString;\nvar $slice = [].slice;\n\n// iOS Safari 6.x fails here\nvar TO_LOCALE_STRING_BUG = !!Int8Array && fails(function () {\n $toLocaleString.call(new Int8Array(1));\n});\n\nvar FORCED = fails(function () {\n return [1, 2].toLocaleString() != new Int8Array([1, 2]).toLocaleString();\n}) || !fails(function () {\n Int8Array.prototype.toLocaleString.call([1, 2]);\n});\n\n// `%TypedArray%.prototype.toLocaleString` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.tolocalestring\nexportTypedArrayMethod('toLocaleString', function toLocaleString() {\n return $toLocaleString.apply(TO_LOCALE_STRING_BUG ? $slice.call(aTypedArray(this)) : aTypedArray(this), arguments);\n}, FORCED);\n","'use strict';\nvar exportTypedArrayMethod = require('../internals/array-buffer-view-core').exportTypedArrayMethod;\nvar fails = require('../internals/fails');\nvar global = require('../internals/global');\n\nvar Uint8Array = global.Uint8Array;\nvar Uint8ArrayPrototype = Uint8Array && Uint8Array.prototype || {};\nvar arrayToString = [].toString;\nvar arrayJoin = [].join;\n\nif (fails(function () { arrayToString.call({}); })) {\n arrayToString = function toString() {\n return arrayJoin.call(this);\n };\n}\n\nvar IS_NOT_ARRAY_METHOD = Uint8ArrayPrototype.toString != arrayToString;\n\n// `%TypedArray%.prototype.toString` method\n// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.tostring\nexportTypedArrayMethod('toString', arrayToString, IS_NOT_ARRAY_METHOD);\n","var createTypedArrayConstructor = require('../internals/typed-array-constructor');\n\n// `Uint16Array` constructor\n// https://tc39.github.io/ecma262/#sec-typedarray-objects\ncreateTypedArrayConstructor('Uint16', function (init) {\n return function Uint16Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","var createTypedArrayConstructor = require('../internals/typed-array-constructor');\n\n// `Uint32Array` constructor\n// https://tc39.github.io/ecma262/#sec-typedarray-objects\ncreateTypedArrayConstructor('Uint32', function (init) {\n return function Uint32Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","var createTypedArrayConstructor = require('../internals/typed-array-constructor');\n\n// `Uint8Array` constructor\n// https://tc39.github.io/ecma262/#sec-typedarray-objects\ncreateTypedArrayConstructor('Uint8', function (init) {\n return function Uint8Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","var createTypedArrayConstructor = require('../internals/typed-array-constructor');\n\n// `Uint8ClampedArray` constructor\n// https://tc39.github.io/ecma262/#sec-typedarray-objects\ncreateTypedArrayConstructor('Uint8', function (init) {\n return function Uint8ClampedArray(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n}, true);\n","'use strict';\nvar global = require('../internals/global');\nvar redefineAll = require('../internals/redefine-all');\nvar InternalMetadataModule = require('../internals/internal-metadata');\nvar collection = require('../internals/collection');\nvar collectionWeak = require('../internals/collection-weak');\nvar isObject = require('../internals/is-object');\nvar enforceIternalState = require('../internals/internal-state').enforce;\nvar NATIVE_WEAK_MAP = require('../internals/native-weak-map');\n\nvar IS_IE11 = !global.ActiveXObject && 'ActiveXObject' in global;\nvar isExtensible = Object.isExtensible;\nvar InternalWeakMap;\n\nvar wrapper = function (init) {\n return function WeakMap() {\n return init(this, arguments.length ? arguments[0] : undefined);\n };\n};\n\n// `WeakMap` constructor\n// https://tc39.github.io/ecma262/#sec-weakmap-constructor\nvar $WeakMap = module.exports = collection('WeakMap', wrapper, collectionWeak);\n\n// IE11 WeakMap frozen keys fix\n// We can't use feature detection because it crash some old IE builds\n// https://github.com/zloirock/core-js/issues/485\nif (NATIVE_WEAK_MAP && IS_IE11) {\n InternalWeakMap = collectionWeak.getConstructor(wrapper, 'WeakMap', true);\n InternalMetadataModule.REQUIRED = true;\n var WeakMapPrototype = $WeakMap.prototype;\n var nativeDelete = WeakMapPrototype['delete'];\n var nativeHas = WeakMapPrototype.has;\n var nativeGet = WeakMapPrototype.get;\n var nativeSet = WeakMapPrototype.set;\n redefineAll(WeakMapPrototype, {\n 'delete': function (key) {\n if (isObject(key) && !isExtensible(key)) {\n var state = enforceIternalState(this);\n if (!state.frozen) state.frozen = new InternalWeakMap();\n return nativeDelete.call(this, key) || state.frozen['delete'](key);\n } return nativeDelete.call(this, key);\n },\n has: function has(key) {\n if (isObject(key) && !isExtensible(key)) {\n var state = enforceIternalState(this);\n if (!state.frozen) state.frozen = new InternalWeakMap();\n return nativeHas.call(this, key) || state.frozen.has(key);\n } return nativeHas.call(this, key);\n },\n get: function get(key) {\n if (isObject(key) && !isExtensible(key)) {\n var state = enforceIternalState(this);\n if (!state.frozen) state.frozen = new InternalWeakMap();\n return nativeHas.call(this, key) ? nativeGet.call(this, key) : state.frozen.get(key);\n } return nativeGet.call(this, key);\n },\n set: function set(key, value) {\n if (isObject(key) && !isExtensible(key)) {\n var state = enforceIternalState(this);\n if (!state.frozen) state.frozen = new InternalWeakMap();\n nativeHas.call(this, key) ? nativeSet.call(this, key, value) : state.frozen.set(key, value);\n } else nativeSet.call(this, key, value);\n return this;\n }\n });\n}\n","'use strict';\nvar collection = require('../internals/collection');\nvar collectionWeak = require('../internals/collection-weak');\n\n// `WeakSet` constructor\n// https://tc39.github.io/ecma262/#sec-weakset-constructor\ncollection('WeakSet', function (init) {\n return function WeakSet() { return init(this, arguments.length ? arguments[0] : undefined); };\n}, collectionWeak);\n","'use strict';\nvar $ = require('../internals/export');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar getPrototypeOf = require('../internals/object-get-prototype-of');\nvar setPrototypeOf = require('../internals/object-set-prototype-of');\nvar create = require('../internals/object-create');\nvar defineProperty = require('../internals/object-define-property');\nvar createPropertyDescriptor = require('../internals/create-property-descriptor');\nvar iterate = require('../internals/iterate');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar InternalStateModule = require('../internals/internal-state');\n\nvar setInternalState = InternalStateModule.set;\nvar getInternalAggregateErrorState = InternalStateModule.getterFor('AggregateError');\n\nvar $AggregateError = function AggregateError(errors, message) {\n var that = this;\n if (!(that instanceof $AggregateError)) return new $AggregateError(errors, message);\n if (setPrototypeOf) {\n that = setPrototypeOf(new Error(message), getPrototypeOf(that));\n }\n var errorsArray = [];\n iterate(errors, errorsArray.push, errorsArray);\n if (DESCRIPTORS) setInternalState(that, { errors: errorsArray, type: 'AggregateError' });\n else that.errors = errorsArray;\n if (message !== undefined) createNonEnumerableProperty(that, 'message', String(message));\n return that;\n};\n\n$AggregateError.prototype = create(Error.prototype, {\n constructor: createPropertyDescriptor(5, $AggregateError),\n message: createPropertyDescriptor(5, ''),\n name: createPropertyDescriptor(5, 'AggregateError')\n});\n\nif (DESCRIPTORS) defineProperty.f($AggregateError.prototype, 'errors', {\n get: function () {\n return getInternalAggregateErrorState(this).errors;\n },\n configurable: true\n});\n\n$({ global: true }, {\n AggregateError: $AggregateError\n});\n","'use strict';\nvar DESCRIPTORS = require('../internals/descriptors');\nvar addToUnscopables = require('../internals/add-to-unscopables');\nvar toObject = require('../internals/to-object');\nvar toLength = require('../internals/to-length');\nvar defineProperty = require('../internals/object-define-property').f;\n\n// `Array.prototype.lastIndex` getter\n// https://github.com/keithamus/proposal-array-last\nif (DESCRIPTORS && !('lastIndex' in [])) {\n defineProperty(Array.prototype, 'lastIndex', {\n configurable: true,\n get: function lastIndex() {\n var O = toObject(this);\n var len = toLength(O.length);\n return len == 0 ? 0 : len - 1;\n }\n });\n\n addToUnscopables('lastIndex');\n}\n","'use strict';\nvar DESCRIPTORS = require('../internals/descriptors');\nvar addToUnscopables = require('../internals/add-to-unscopables');\nvar toObject = require('../internals/to-object');\nvar toLength = require('../internals/to-length');\nvar defineProperty = require('../internals/object-define-property').f;\n\n// `Array.prototype.lastIndex` accessor\n// https://github.com/keithamus/proposal-array-last\nif (DESCRIPTORS && !('lastItem' in [])) {\n defineProperty(Array.prototype, 'lastItem', {\n configurable: true,\n get: function lastItem() {\n var O = toObject(this);\n var len = toLength(O.length);\n return len == 0 ? undefined : O[len - 1];\n },\n set: function lastItem(value) {\n var O = toObject(this);\n var len = toLength(O.length);\n return O[len == 0 ? 0 : len - 1] = value;\n }\n });\n\n addToUnscopables('lastItem');\n}\n","var $ = require('../internals/export');\nvar getCompositeKeyNode = require('../internals/composite-key');\nvar getBuiltIn = require('../internals/get-built-in');\nvar create = require('../internals/object-create');\n\nvar initializer = function () {\n var freeze = getBuiltIn('Object', 'freeze');\n return freeze ? freeze(create(null)) : create(null);\n};\n\n// https://github.com/tc39/proposal-richer-keys/tree/master/compositeKey\n$({ global: true }, {\n compositeKey: function compositeKey() {\n return getCompositeKeyNode.apply(Object, arguments).get('object', initializer);\n }\n});\n","var $ = require('../internals/export');\nvar getCompositeKeyNode = require('../internals/composite-key');\nvar getBuiltIn = require('../internals/get-built-in');\n\n// https://github.com/tc39/proposal-richer-keys/tree/master/compositeKey\n$({ global: true }, {\n compositeSymbol: function compositeSymbol() {\n if (arguments.length === 1 && typeof arguments[0] === 'string') return getBuiltIn('Symbol')['for'](arguments[0]);\n return getCompositeKeyNode.apply(null, arguments).get('symbol', getBuiltIn('Symbol'));\n }\n});\n","// TODO: Remove from `core-js@4`\nrequire('./es.global-this');\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar collectionDeleteAll = require('../internals/collection-delete-all');\n\n// `Map.prototype.deleteAll` method\n// https://github.com/tc39/proposal-collection-methods\n$({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {\n deleteAll: function deleteAll(/* ...elements */) {\n return collectionDeleteAll.apply(this, arguments);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar anObject = require('../internals/an-object');\nvar bind = require('../internals/function-bind-context');\nvar getMapIterator = require('../internals/get-map-iterator');\nvar iterate = require('../internals/iterate');\n\n// `Map.prototype.every` method\n// https://github.com/tc39/proposal-collection-methods\n$({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {\n every: function every(callbackfn /* , thisArg */) {\n var map = anObject(this);\n var iterator = getMapIterator(map);\n var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);\n return !iterate(iterator, function (key, value) {\n if (!boundFunction(value, key, map)) return iterate.stop();\n }, undefined, true, true).stopped;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar getBuiltIn = require('../internals/get-built-in');\nvar anObject = require('../internals/an-object');\nvar aFunction = require('../internals/a-function');\nvar bind = require('../internals/function-bind-context');\nvar speciesConstructor = require('../internals/species-constructor');\nvar getMapIterator = require('../internals/get-map-iterator');\nvar iterate = require('../internals/iterate');\n\n// `Map.prototype.filter` method\n// https://github.com/tc39/proposal-collection-methods\n$({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {\n filter: function filter(callbackfn /* , thisArg */) {\n var map = anObject(this);\n var iterator = getMapIterator(map);\n var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);\n var newMap = new (speciesConstructor(map, getBuiltIn('Map')))();\n var setter = aFunction(newMap.set);\n iterate(iterator, function (key, value) {\n if (boundFunction(value, key, map)) setter.call(newMap, key, value);\n }, undefined, true, true);\n return newMap;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar anObject = require('../internals/an-object');\nvar bind = require('../internals/function-bind-context');\nvar getMapIterator = require('../internals/get-map-iterator');\nvar iterate = require('../internals/iterate');\n\n// `Map.prototype.findKey` method\n// https://github.com/tc39/proposal-collection-methods\n$({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {\n findKey: function findKey(callbackfn /* , thisArg */) {\n var map = anObject(this);\n var iterator = getMapIterator(map);\n var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);\n return iterate(iterator, function (key, value) {\n if (boundFunction(value, key, map)) return iterate.stop(key);\n }, undefined, true, true).result;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar anObject = require('../internals/an-object');\nvar bind = require('../internals/function-bind-context');\nvar getMapIterator = require('../internals/get-map-iterator');\nvar iterate = require('../internals/iterate');\n\n// `Map.prototype.find` method\n// https://github.com/tc39/proposal-collection-methods\n$({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {\n find: function find(callbackfn /* , thisArg */) {\n var map = anObject(this);\n var iterator = getMapIterator(map);\n var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);\n return iterate(iterator, function (key, value) {\n if (boundFunction(value, key, map)) return iterate.stop(value);\n }, undefined, true, true).result;\n }\n});\n","var $ = require('../internals/export');\nvar from = require('../internals/collection-from');\n\n// `Map.from` method\n// https://tc39.github.io/proposal-setmap-offrom/#sec-map.from\n$({ target: 'Map', stat: true }, {\n from: from\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar iterate = require('../internals/iterate');\nvar aFunction = require('../internals/a-function');\n\n// `Map.groupBy` method\n// https://github.com/tc39/proposal-collection-methods\n$({ target: 'Map', stat: true }, {\n groupBy: function groupBy(iterable, keyDerivative) {\n var newMap = new this();\n aFunction(keyDerivative);\n var has = aFunction(newMap.has);\n var get = aFunction(newMap.get);\n var set = aFunction(newMap.set);\n iterate(iterable, function (element) {\n var derivedKey = keyDerivative(element);\n if (!has.call(newMap, derivedKey)) set.call(newMap, derivedKey, [element]);\n else get.call(newMap, derivedKey).push(element);\n });\n return newMap;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar anObject = require('../internals/an-object');\nvar getMapIterator = require('../internals/get-map-iterator');\nvar sameValueZero = require('../internals/same-value-zero');\nvar iterate = require('../internals/iterate');\n\n// `Map.prototype.includes` method\n// https://github.com/tc39/proposal-collection-methods\n$({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {\n includes: function includes(searchElement) {\n return iterate(getMapIterator(anObject(this)), function (key, value) {\n if (sameValueZero(value, searchElement)) return iterate.stop();\n }, undefined, true, true).stopped;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar iterate = require('../internals/iterate');\nvar aFunction = require('../internals/a-function');\n\n// `Map.keyBy` method\n// https://github.com/tc39/proposal-collection-methods\n$({ target: 'Map', stat: true }, {\n keyBy: function keyBy(iterable, keyDerivative) {\n var newMap = new this();\n aFunction(keyDerivative);\n var setter = aFunction(newMap.set);\n iterate(iterable, function (element) {\n setter.call(newMap, keyDerivative(element), element);\n });\n return newMap;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar anObject = require('../internals/an-object');\nvar getMapIterator = require('../internals/get-map-iterator');\nvar iterate = require('../internals/iterate');\n\n// `Map.prototype.includes` method\n// https://github.com/tc39/proposal-collection-methods\n$({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {\n keyOf: function keyOf(searchElement) {\n return iterate(getMapIterator(anObject(this)), function (key, value) {\n if (value === searchElement) return iterate.stop(key);\n }, undefined, true, true).result;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar getBuiltIn = require('../internals/get-built-in');\nvar anObject = require('../internals/an-object');\nvar aFunction = require('../internals/a-function');\nvar bind = require('../internals/function-bind-context');\nvar speciesConstructor = require('../internals/species-constructor');\nvar getMapIterator = require('../internals/get-map-iterator');\nvar iterate = require('../internals/iterate');\n\n// `Map.prototype.mapKeys` method\n// https://github.com/tc39/proposal-collection-methods\n$({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {\n mapKeys: function mapKeys(callbackfn /* , thisArg */) {\n var map = anObject(this);\n var iterator = getMapIterator(map);\n var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);\n var newMap = new (speciesConstructor(map, getBuiltIn('Map')))();\n var setter = aFunction(newMap.set);\n iterate(iterator, function (key, value) {\n setter.call(newMap, boundFunction(value, key, map), value);\n }, undefined, true, true);\n return newMap;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar getBuiltIn = require('../internals/get-built-in');\nvar anObject = require('../internals/an-object');\nvar aFunction = require('../internals/a-function');\nvar bind = require('../internals/function-bind-context');\nvar speciesConstructor = require('../internals/species-constructor');\nvar getMapIterator = require('../internals/get-map-iterator');\nvar iterate = require('../internals/iterate');\n\n// `Map.prototype.mapValues` method\n// https://github.com/tc39/proposal-collection-methods\n$({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {\n mapValues: function mapValues(callbackfn /* , thisArg */) {\n var map = anObject(this);\n var iterator = getMapIterator(map);\n var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);\n var newMap = new (speciesConstructor(map, getBuiltIn('Map')))();\n var setter = aFunction(newMap.set);\n iterate(iterator, function (key, value) {\n setter.call(newMap, key, boundFunction(value, key, map));\n }, undefined, true, true);\n return newMap;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar anObject = require('../internals/an-object');\nvar aFunction = require('../internals/a-function');\nvar iterate = require('../internals/iterate');\n\n// `Map.prototype.merge` method\n// https://github.com/tc39/proposal-collection-methods\n$({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {\n // eslint-disable-next-line no-unused-vars\n merge: function merge(iterable /* ...iterbles */) {\n var map = anObject(this);\n var setter = aFunction(map.set);\n var i = 0;\n while (i < arguments.length) {\n iterate(arguments[i++], setter, map, true);\n }\n return map;\n }\n});\n","var $ = require('../internals/export');\nvar of = require('../internals/collection-of');\n\n// `Map.of` method\n// https://tc39.github.io/proposal-setmap-offrom/#sec-map.of\n$({ target: 'Map', stat: true }, {\n of: of\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar anObject = require('../internals/an-object');\nvar aFunction = require('../internals/a-function');\nvar getMapIterator = require('../internals/get-map-iterator');\nvar iterate = require('../internals/iterate');\n\n// `Map.prototype.reduce` method\n// https://github.com/tc39/proposal-collection-methods\n$({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {\n reduce: function reduce(callbackfn /* , initialValue */) {\n var map = anObject(this);\n var iterator = getMapIterator(map);\n var noInitial = arguments.length < 2;\n var accumulator = noInitial ? undefined : arguments[1];\n aFunction(callbackfn);\n iterate(iterator, function (key, value) {\n if (noInitial) {\n noInitial = false;\n accumulator = value;\n } else {\n accumulator = callbackfn(accumulator, value, key, map);\n }\n }, undefined, true, true);\n if (noInitial) throw TypeError('Reduce of empty map with no initial value');\n return accumulator;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar anObject = require('../internals/an-object');\nvar bind = require('../internals/function-bind-context');\nvar getMapIterator = require('../internals/get-map-iterator');\nvar iterate = require('../internals/iterate');\n\n// `Set.prototype.some` method\n// https://github.com/tc39/proposal-collection-methods\n$({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {\n some: function some(callbackfn /* , thisArg */) {\n var map = anObject(this);\n var iterator = getMapIterator(map);\n var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);\n return iterate(iterator, function (key, value) {\n if (boundFunction(value, key, map)) return iterate.stop();\n }, undefined, true, true).stopped;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar anObject = require('../internals/an-object');\nvar aFunction = require('../internals/a-function');\n\n// `Set.prototype.update` method\n// https://github.com/tc39/proposal-collection-methods\n$({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {\n update: function update(key, callback /* , thunk */) {\n var map = anObject(this);\n var length = arguments.length;\n aFunction(callback);\n var isPresentInMap = map.has(key);\n if (!isPresentInMap && length < 3) {\n throw TypeError('Updating absent value');\n }\n var value = isPresentInMap ? map.get(key) : aFunction(length > 2 ? arguments[2] : undefined)(key, map);\n map.set(key, callback(value, key, map));\n return map;\n }\n});\n","var $ = require('../internals/export');\n\nvar min = Math.min;\nvar max = Math.max;\n\n// `Math.clamp` method\n// https://rwaldron.github.io/proposal-math-extensions/\n$({ target: 'Math', stat: true }, {\n clamp: function clamp(x, lower, upper) {\n return min(upper, max(lower, x));\n }\n});\n","var $ = require('../internals/export');\n\n// `Math.DEG_PER_RAD` constant\n// https://rwaldron.github.io/proposal-math-extensions/\n$({ target: 'Math', stat: true }, {\n DEG_PER_RAD: Math.PI / 180\n});\n","var $ = require('../internals/export');\n\nvar RAD_PER_DEG = 180 / Math.PI;\n\n// `Math.degrees` method\n// https://rwaldron.github.io/proposal-math-extensions/\n$({ target: 'Math', stat: true }, {\n degrees: function degrees(radians) {\n return radians * RAD_PER_DEG;\n }\n});\n","var $ = require('../internals/export');\n\nvar scale = require('../internals/math-scale');\nvar fround = require('../internals/math-fround');\n\n// `Math.fscale` method\n// https://rwaldron.github.io/proposal-math-extensions/\n$({ target: 'Math', stat: true }, {\n fscale: function fscale(x, inLow, inHigh, outLow, outHigh) {\n return fround(scale(x, inLow, inHigh, outLow, outHigh));\n }\n});\n","var $ = require('../internals/export');\n\n// `Math.iaddh` method\n// https://gist.github.com/BrendanEich/4294d5c212a6d2254703\n// TODO: Remove from `core-js@4`\n$({ target: 'Math', stat: true }, {\n iaddh: function iaddh(x0, x1, y0, y1) {\n var $x0 = x0 >>> 0;\n var $x1 = x1 >>> 0;\n var $y0 = y0 >>> 0;\n return $x1 + (y1 >>> 0) + (($x0 & $y0 | ($x0 | $y0) & ~($x0 + $y0 >>> 0)) >>> 31) | 0;\n }\n});\n","var $ = require('../internals/export');\n\n// `Math.imulh` method\n// https://gist.github.com/BrendanEich/4294d5c212a6d2254703\n// TODO: Remove from `core-js@4`\n$({ target: 'Math', stat: true }, {\n imulh: function imulh(u, v) {\n var UINT16 = 0xFFFF;\n var $u = +u;\n var $v = +v;\n var u0 = $u & UINT16;\n var v0 = $v & UINT16;\n var u1 = $u >> 16;\n var v1 = $v >> 16;\n var t = (u1 * v0 >>> 0) + (u0 * v0 >>> 16);\n return u1 * v1 + (t >> 16) + ((u0 * v1 >>> 0) + (t & UINT16) >> 16);\n }\n});\n","var $ = require('../internals/export');\n\n// `Math.isubh` method\n// https://gist.github.com/BrendanEich/4294d5c212a6d2254703\n// TODO: Remove from `core-js@4`\n$({ target: 'Math', stat: true }, {\n isubh: function isubh(x0, x1, y0, y1) {\n var $x0 = x0 >>> 0;\n var $x1 = x1 >>> 0;\n var $y0 = y0 >>> 0;\n return $x1 - (y1 >>> 0) - ((~$x0 & $y0 | ~($x0 ^ $y0) & $x0 - $y0 >>> 0) >>> 31) | 0;\n }\n});\n","var $ = require('../internals/export');\n\n// `Math.RAD_PER_DEG` constant\n// https://rwaldron.github.io/proposal-math-extensions/\n$({ target: 'Math', stat: true }, {\n RAD_PER_DEG: 180 / Math.PI\n});\n","var $ = require('../internals/export');\n\nvar DEG_PER_RAD = Math.PI / 180;\n\n// `Math.radians` method\n// https://rwaldron.github.io/proposal-math-extensions/\n$({ target: 'Math', stat: true }, {\n radians: function radians(degrees) {\n return degrees * DEG_PER_RAD;\n }\n});\n","var $ = require('../internals/export');\nvar scale = require('../internals/math-scale');\n\n// `Math.scale` method\n// https://rwaldron.github.io/proposal-math-extensions/\n$({ target: 'Math', stat: true }, {\n scale: scale\n});\n","var $ = require('../internals/export');\nvar anObject = require('../internals/an-object');\nvar numberIsFinite = require('../internals/number-is-finite');\nvar createIteratorConstructor = require('../internals/create-iterator-constructor');\nvar InternalStateModule = require('../internals/internal-state');\n\nvar SEEDED_RANDOM = 'Seeded Random';\nvar SEEDED_RANDOM_GENERATOR = SEEDED_RANDOM + ' Generator';\nvar setInternalState = InternalStateModule.set;\nvar getInternalState = InternalStateModule.getterFor(SEEDED_RANDOM_GENERATOR);\nvar SEED_TYPE_ERROR = 'Math.seededPRNG() argument should have a \"seed\" field with a finite value.';\n\nvar $SeededRandomGenerator = createIteratorConstructor(function SeededRandomGenerator(seed) {\n setInternalState(this, {\n type: SEEDED_RANDOM_GENERATOR,\n seed: seed % 2147483647\n });\n}, SEEDED_RANDOM, function next() {\n var state = getInternalState(this);\n var seed = state.seed = (state.seed * 1103515245 + 12345) % 2147483647;\n return { value: (seed & 1073741823) / 1073741823, done: false };\n});\n\n// `Math.seededPRNG` method\n// https://github.com/tc39/proposal-seeded-random\n// based on https://github.com/tc39/proposal-seeded-random/blob/78b8258835b57fc2100d076151ab506bc3202ae6/demo.html\n$({ target: 'Math', stat: true, forced: true }, {\n seededPRNG: function seededPRNG(it) {\n var seed = anObject(it).seed;\n if (!numberIsFinite(seed)) throw TypeError(SEED_TYPE_ERROR);\n return new $SeededRandomGenerator(seed);\n }\n});\n","var $ = require('../internals/export');\n\n// `Math.signbit` method\n// https://github.com/tc39/proposal-Math.signbit\n$({ target: 'Math', stat: true }, {\n signbit: function signbit(x) {\n return (x = +x) == x && x == 0 ? 1 / x == -Infinity : x < 0;\n }\n});\n","var $ = require('../internals/export');\n\n// `Math.umulh` method\n// https://gist.github.com/BrendanEich/4294d5c212a6d2254703\n// TODO: Remove from `core-js@4`\n$({ target: 'Math', stat: true }, {\n umulh: function umulh(u, v) {\n var UINT16 = 0xFFFF;\n var $u = +u;\n var $v = +v;\n var u0 = $u & UINT16;\n var v0 = $v & UINT16;\n var u1 = $u >>> 16;\n var v1 = $v >>> 16;\n var t = (u1 * v0 >>> 0) + (u0 * v0 >>> 16);\n return u1 * v1 + (t >>> 16) + ((u0 * v1 >>> 0) + (t & UINT16) >>> 16);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar toInteger = require('../internals/to-integer');\nvar parseInt = require('../internals/number-parse-int');\n\nvar INVALID_NUMBER_REPRESENTATION = 'Invalid number representation';\nvar INVALID_RADIX = 'Invalid radix';\nvar valid = /^[\\da-z]+$/;\n\n// `Number.fromString` method\n// https://github.com/tc39/proposal-number-fromstring\n$({ target: 'Number', stat: true }, {\n fromString: function fromString(string, radix) {\n var sign = 1;\n var R, mathNum;\n if (typeof string != 'string') throw TypeError(INVALID_NUMBER_REPRESENTATION);\n if (!string.length) throw SyntaxError(INVALID_NUMBER_REPRESENTATION);\n if (string.charAt(0) == '-') {\n sign = -1;\n string = string.slice(1);\n if (!string.length) throw SyntaxError(INVALID_NUMBER_REPRESENTATION);\n }\n R = radix === undefined ? 10 : toInteger(radix);\n if (R < 2 || R > 36) throw RangeError(INVALID_RADIX);\n if (!valid.test(string) || (mathNum = parseInt(string, R)).toString(R) !== string) {\n throw SyntaxError(INVALID_NUMBER_REPRESENTATION);\n }\n return sign * mathNum;\n }\n});\n","'use strict';\n// https://github.com/tc39/proposal-observable\nvar $ = require('../internals/export');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar setSpecies = require('../internals/set-species');\nvar aFunction = require('../internals/a-function');\nvar anObject = require('../internals/an-object');\nvar isObject = require('../internals/is-object');\nvar anInstance = require('../internals/an-instance');\nvar defineProperty = require('../internals/object-define-property').f;\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar redefineAll = require('../internals/redefine-all');\nvar getIterator = require('../internals/get-iterator');\nvar iterate = require('../internals/iterate');\nvar hostReportErrors = require('../internals/host-report-errors');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar InternalStateModule = require('../internals/internal-state');\n\nvar OBSERVABLE = wellKnownSymbol('observable');\nvar getInternalState = InternalStateModule.get;\nvar setInternalState = InternalStateModule.set;\n\nvar getMethod = function (fn) {\n return fn == null ? undefined : aFunction(fn);\n};\n\nvar cleanupSubscription = function (subscriptionState) {\n var cleanup = subscriptionState.cleanup;\n if (cleanup) {\n subscriptionState.cleanup = undefined;\n try {\n cleanup();\n } catch (error) {\n hostReportErrors(error);\n }\n }\n};\n\nvar subscriptionClosed = function (subscriptionState) {\n return subscriptionState.observer === undefined;\n};\n\nvar close = function (subscription, subscriptionState) {\n if (!DESCRIPTORS) {\n subscription.closed = true;\n var subscriptionObserver = subscriptionState.subscriptionObserver;\n if (subscriptionObserver) subscriptionObserver.closed = true;\n } subscriptionState.observer = undefined;\n};\n\nvar Subscription = function (observer, subscriber) {\n var subscriptionState = setInternalState(this, {\n cleanup: undefined,\n observer: anObject(observer),\n subscriptionObserver: undefined\n });\n var start;\n if (!DESCRIPTORS) this.closed = false;\n try {\n if (start = getMethod(observer.start)) start.call(observer, this);\n } catch (error) {\n hostReportErrors(error);\n }\n if (subscriptionClosed(subscriptionState)) return;\n var subscriptionObserver = subscriptionState.subscriptionObserver = new SubscriptionObserver(this);\n try {\n var cleanup = subscriber(subscriptionObserver);\n var subscription = cleanup;\n if (cleanup != null) subscriptionState.cleanup = typeof cleanup.unsubscribe === 'function'\n ? function () { subscription.unsubscribe(); }\n : aFunction(cleanup);\n } catch (error) {\n subscriptionObserver.error(error);\n return;\n } if (subscriptionClosed(subscriptionState)) cleanupSubscription(subscriptionState);\n};\n\nSubscription.prototype = redefineAll({}, {\n unsubscribe: function unsubscribe() {\n var subscriptionState = getInternalState(this);\n if (!subscriptionClosed(subscriptionState)) {\n close(this, subscriptionState);\n cleanupSubscription(subscriptionState);\n }\n }\n});\n\nif (DESCRIPTORS) defineProperty(Subscription.prototype, 'closed', {\n configurable: true,\n get: function () {\n return subscriptionClosed(getInternalState(this));\n }\n});\n\nvar SubscriptionObserver = function (subscription) {\n setInternalState(this, { subscription: subscription });\n if (!DESCRIPTORS) this.closed = false;\n};\n\nSubscriptionObserver.prototype = redefineAll({}, {\n next: function next(value) {\n var subscriptionState = getInternalState(getInternalState(this).subscription);\n if (!subscriptionClosed(subscriptionState)) {\n var observer = subscriptionState.observer;\n try {\n var nextMethod = getMethod(observer.next);\n if (nextMethod) nextMethod.call(observer, value);\n } catch (error) {\n hostReportErrors(error);\n }\n }\n },\n error: function error(value) {\n var subscription = getInternalState(this).subscription;\n var subscriptionState = getInternalState(subscription);\n if (!subscriptionClosed(subscriptionState)) {\n var observer = subscriptionState.observer;\n close(subscription, subscriptionState);\n try {\n var errorMethod = getMethod(observer.error);\n if (errorMethod) errorMethod.call(observer, value);\n else hostReportErrors(value);\n } catch (err) {\n hostReportErrors(err);\n } cleanupSubscription(subscriptionState);\n }\n },\n complete: function complete() {\n var subscription = getInternalState(this).subscription;\n var subscriptionState = getInternalState(subscription);\n if (!subscriptionClosed(subscriptionState)) {\n var observer = subscriptionState.observer;\n close(subscription, subscriptionState);\n try {\n var completeMethod = getMethod(observer.complete);\n if (completeMethod) completeMethod.call(observer);\n } catch (error) {\n hostReportErrors(error);\n } cleanupSubscription(subscriptionState);\n }\n }\n});\n\nif (DESCRIPTORS) defineProperty(SubscriptionObserver.prototype, 'closed', {\n configurable: true,\n get: function () {\n return subscriptionClosed(getInternalState(getInternalState(this).subscription));\n }\n});\n\nvar $Observable = function Observable(subscriber) {\n anInstance(this, $Observable, 'Observable');\n setInternalState(this, { subscriber: aFunction(subscriber) });\n};\n\nredefineAll($Observable.prototype, {\n subscribe: function subscribe(observer) {\n var length = arguments.length;\n return new Subscription(typeof observer === 'function' ? {\n next: observer,\n error: length > 1 ? arguments[1] : undefined,\n complete: length > 2 ? arguments[2] : undefined\n } : isObject(observer) ? observer : {}, getInternalState(this).subscriber);\n }\n});\n\nredefineAll($Observable, {\n from: function from(x) {\n var C = typeof this === 'function' ? this : $Observable;\n var observableMethod = getMethod(anObject(x)[OBSERVABLE]);\n if (observableMethod) {\n var observable = anObject(observableMethod.call(x));\n return observable.constructor === C ? observable : new C(function (observer) {\n return observable.subscribe(observer);\n });\n }\n var iterator = getIterator(x);\n return new C(function (observer) {\n iterate(iterator, function (it) {\n observer.next(it);\n if (observer.closed) return iterate.stop();\n }, undefined, false, true);\n observer.complete();\n });\n },\n of: function of() {\n var C = typeof this === 'function' ? this : $Observable;\n var length = arguments.length;\n var items = new Array(length);\n var index = 0;\n while (index < length) items[index] = arguments[index++];\n return new C(function (observer) {\n for (var i = 0; i < length; i++) {\n observer.next(items[i]);\n if (observer.closed) return;\n } observer.complete();\n });\n }\n});\n\ncreateNonEnumerableProperty($Observable.prototype, OBSERVABLE, function () { return this; });\n\n$({ global: true }, {\n Observable: $Observable\n});\n\nsetSpecies('Observable');\n","// TODO: Remove from `core-js@4`\nrequire('./es.promise.all-settled.js');\n","'use strict';\nvar $ = require('../internals/export');\nvar aFunction = require('../internals/a-function');\nvar getBuiltIn = require('../internals/get-built-in');\nvar newPromiseCapabilityModule = require('../internals/new-promise-capability');\nvar perform = require('../internals/perform');\nvar iterate = require('../internals/iterate');\n\nvar PROMISE_ANY_ERROR = 'No one promise resolved';\n\n// `Promise.any` method\n// https://github.com/tc39/proposal-promise-any\n$({ target: 'Promise', stat: true }, {\n any: function any(iterable) {\n var C = this;\n var capability = newPromiseCapabilityModule.f(C);\n var resolve = capability.resolve;\n var reject = capability.reject;\n var result = perform(function () {\n var promiseResolve = aFunction(C.resolve);\n var errors = [];\n var counter = 0;\n var remaining = 1;\n var alreadyResolved = false;\n iterate(iterable, function (promise) {\n var index = counter++;\n var alreadyRejected = false;\n errors.push(undefined);\n remaining++;\n promiseResolve.call(C, promise).then(function (value) {\n if (alreadyRejected || alreadyResolved) return;\n alreadyResolved = true;\n resolve(value);\n }, function (e) {\n if (alreadyRejected || alreadyResolved) return;\n alreadyRejected = true;\n errors[index] = e;\n --remaining || reject(new (getBuiltIn('AggregateError'))(errors, PROMISE_ANY_ERROR));\n });\n });\n --remaining || reject(new (getBuiltIn('AggregateError'))(errors, PROMISE_ANY_ERROR));\n });\n if (result.error) reject(result.value);\n return capability.promise;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar newPromiseCapabilityModule = require('../internals/new-promise-capability');\nvar perform = require('../internals/perform');\n\n// `Promise.try` method\n// https://github.com/tc39/proposal-promise-try\n$({ target: 'Promise', stat: true }, {\n 'try': function (callbackfn) {\n var promiseCapability = newPromiseCapabilityModule.f(this);\n var result = perform(callbackfn);\n (result.error ? promiseCapability.reject : promiseCapability.resolve)(result.value);\n return promiseCapability.promise;\n }\n});\n","var $ = require('../internals/export');\nvar ReflectMetadataModule = require('../internals/reflect-metadata');\nvar anObject = require('../internals/an-object');\n\nvar toMetadataKey = ReflectMetadataModule.toKey;\nvar ordinaryDefineOwnMetadata = ReflectMetadataModule.set;\n\n// `Reflect.defineMetadata` method\n// https://github.com/rbuckton/reflect-metadata\n$({ target: 'Reflect', stat: true }, {\n defineMetadata: function defineMetadata(metadataKey, metadataValue, target /* , targetKey */) {\n var targetKey = arguments.length < 4 ? undefined : toMetadataKey(arguments[3]);\n ordinaryDefineOwnMetadata(metadataKey, metadataValue, anObject(target), targetKey);\n }\n});\n","var $ = require('../internals/export');\nvar ReflectMetadataModule = require('../internals/reflect-metadata');\nvar anObject = require('../internals/an-object');\n\nvar toMetadataKey = ReflectMetadataModule.toKey;\nvar getOrCreateMetadataMap = ReflectMetadataModule.getMap;\nvar store = ReflectMetadataModule.store;\n\n// `Reflect.deleteMetadata` method\n// https://github.com/rbuckton/reflect-metadata\n$({ target: 'Reflect', stat: true }, {\n deleteMetadata: function deleteMetadata(metadataKey, target /* , targetKey */) {\n var targetKey = arguments.length < 3 ? undefined : toMetadataKey(arguments[2]);\n var metadataMap = getOrCreateMetadataMap(anObject(target), targetKey, false);\n if (metadataMap === undefined || !metadataMap['delete'](metadataKey)) return false;\n if (metadataMap.size) return true;\n var targetMetadata = store.get(target);\n targetMetadata['delete'](targetKey);\n return !!targetMetadata.size || store['delete'](target);\n }\n});\n","var $ = require('../internals/export');\n// TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`\nvar Set = require('../modules/es.set');\nvar ReflectMetadataModule = require('../internals/reflect-metadata');\nvar anObject = require('../internals/an-object');\nvar getPrototypeOf = require('../internals/object-get-prototype-of');\nvar iterate = require('../internals/iterate');\n\nvar ordinaryOwnMetadataKeys = ReflectMetadataModule.keys;\nvar toMetadataKey = ReflectMetadataModule.toKey;\n\nvar from = function (iter) {\n var result = [];\n iterate(iter, result.push, result);\n return result;\n};\n\nvar ordinaryMetadataKeys = function (O, P) {\n var oKeys = ordinaryOwnMetadataKeys(O, P);\n var parent = getPrototypeOf(O);\n if (parent === null) return oKeys;\n var pKeys = ordinaryMetadataKeys(parent, P);\n return pKeys.length ? oKeys.length ? from(new Set(oKeys.concat(pKeys))) : pKeys : oKeys;\n};\n\n// `Reflect.getMetadataKeys` method\n// https://github.com/rbuckton/reflect-metadata\n$({ target: 'Reflect', stat: true }, {\n getMetadataKeys: function getMetadataKeys(target /* , targetKey */) {\n var targetKey = arguments.length < 2 ? undefined : toMetadataKey(arguments[1]);\n return ordinaryMetadataKeys(anObject(target), targetKey);\n }\n});\n","var $ = require('../internals/export');\nvar ReflectMetadataModule = require('../internals/reflect-metadata');\nvar anObject = require('../internals/an-object');\nvar getPrototypeOf = require('../internals/object-get-prototype-of');\n\nvar ordinaryHasOwnMetadata = ReflectMetadataModule.has;\nvar ordinaryGetOwnMetadata = ReflectMetadataModule.get;\nvar toMetadataKey = ReflectMetadataModule.toKey;\n\nvar ordinaryGetMetadata = function (MetadataKey, O, P) {\n var hasOwn = ordinaryHasOwnMetadata(MetadataKey, O, P);\n if (hasOwn) return ordinaryGetOwnMetadata(MetadataKey, O, P);\n var parent = getPrototypeOf(O);\n return parent !== null ? ordinaryGetMetadata(MetadataKey, parent, P) : undefined;\n};\n\n// `Reflect.getMetadata` method\n// https://github.com/rbuckton/reflect-metadata\n$({ target: 'Reflect', stat: true }, {\n getMetadata: function getMetadata(metadataKey, target /* , targetKey */) {\n var targetKey = arguments.length < 3 ? undefined : toMetadataKey(arguments[2]);\n return ordinaryGetMetadata(metadataKey, anObject(target), targetKey);\n }\n});\n","var $ = require('../internals/export');\nvar ReflectMetadataModule = require('../internals/reflect-metadata');\nvar anObject = require('../internals/an-object');\n\nvar ordinaryOwnMetadataKeys = ReflectMetadataModule.keys;\nvar toMetadataKey = ReflectMetadataModule.toKey;\n\n// `Reflect.getOwnMetadataKeys` method\n// https://github.com/rbuckton/reflect-metadata\n$({ target: 'Reflect', stat: true }, {\n getOwnMetadataKeys: function getOwnMetadataKeys(target /* , targetKey */) {\n var targetKey = arguments.length < 2 ? undefined : toMetadataKey(arguments[1]);\n return ordinaryOwnMetadataKeys(anObject(target), targetKey);\n }\n});\n","var $ = require('../internals/export');\nvar ReflectMetadataModule = require('../internals/reflect-metadata');\nvar anObject = require('../internals/an-object');\n\nvar ordinaryGetOwnMetadata = ReflectMetadataModule.get;\nvar toMetadataKey = ReflectMetadataModule.toKey;\n\n// `Reflect.getOwnMetadata` method\n// https://github.com/rbuckton/reflect-metadata\n$({ target: 'Reflect', stat: true }, {\n getOwnMetadata: function getOwnMetadata(metadataKey, target /* , targetKey */) {\n var targetKey = arguments.length < 3 ? undefined : toMetadataKey(arguments[2]);\n return ordinaryGetOwnMetadata(metadataKey, anObject(target), targetKey);\n }\n});\n","var $ = require('../internals/export');\nvar ReflectMetadataModule = require('../internals/reflect-metadata');\nvar anObject = require('../internals/an-object');\nvar getPrototypeOf = require('../internals/object-get-prototype-of');\n\nvar ordinaryHasOwnMetadata = ReflectMetadataModule.has;\nvar toMetadataKey = ReflectMetadataModule.toKey;\n\nvar ordinaryHasMetadata = function (MetadataKey, O, P) {\n var hasOwn = ordinaryHasOwnMetadata(MetadataKey, O, P);\n if (hasOwn) return true;\n var parent = getPrototypeOf(O);\n return parent !== null ? ordinaryHasMetadata(MetadataKey, parent, P) : false;\n};\n\n// `Reflect.hasMetadata` method\n// https://github.com/rbuckton/reflect-metadata\n$({ target: 'Reflect', stat: true }, {\n hasMetadata: function hasMetadata(metadataKey, target /* , targetKey */) {\n var targetKey = arguments.length < 3 ? undefined : toMetadataKey(arguments[2]);\n return ordinaryHasMetadata(metadataKey, anObject(target), targetKey);\n }\n});\n","var $ = require('../internals/export');\nvar ReflectMetadataModule = require('../internals/reflect-metadata');\nvar anObject = require('../internals/an-object');\n\nvar ordinaryHasOwnMetadata = ReflectMetadataModule.has;\nvar toMetadataKey = ReflectMetadataModule.toKey;\n\n// `Reflect.hasOwnMetadata` method\n// https://github.com/rbuckton/reflect-metadata\n$({ target: 'Reflect', stat: true }, {\n hasOwnMetadata: function hasOwnMetadata(metadataKey, target /* , targetKey */) {\n var targetKey = arguments.length < 3 ? undefined : toMetadataKey(arguments[2]);\n return ordinaryHasOwnMetadata(metadataKey, anObject(target), targetKey);\n }\n});\n","var $ = require('../internals/export');\nvar ReflectMetadataModule = require('../internals/reflect-metadata');\nvar anObject = require('../internals/an-object');\n\nvar toMetadataKey = ReflectMetadataModule.toKey;\nvar ordinaryDefineOwnMetadata = ReflectMetadataModule.set;\n\n// `Reflect.metadata` method\n// https://github.com/rbuckton/reflect-metadata\n$({ target: 'Reflect', stat: true }, {\n metadata: function metadata(metadataKey, metadataValue) {\n return function decorator(target, key) {\n ordinaryDefineOwnMetadata(metadataKey, metadataValue, anObject(target), toMetadataKey(key));\n };\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar collectionAddAll = require('../internals/collection-add-all');\n\n// `Set.prototype.addAll` method\n// https://github.com/tc39/proposal-collection-methods\n$({ target: 'Set', proto: true, real: true, forced: IS_PURE }, {\n addAll: function addAll(/* ...elements */) {\n return collectionAddAll.apply(this, arguments);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar collectionDeleteAll = require('../internals/collection-delete-all');\n\n// `Set.prototype.deleteAll` method\n// https://github.com/tc39/proposal-collection-methods\n$({ target: 'Set', proto: true, real: true, forced: IS_PURE }, {\n deleteAll: function deleteAll(/* ...elements */) {\n return collectionDeleteAll.apply(this, arguments);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar getBuiltIn = require('../internals/get-built-in');\nvar anObject = require('../internals/an-object');\nvar aFunction = require('../internals/a-function');\nvar speciesConstructor = require('../internals/species-constructor');\nvar iterate = require('../internals/iterate');\n\n// `Set.prototype.difference` method\n// https://github.com/tc39/proposal-set-methods\n$({ target: 'Set', proto: true, real: true, forced: IS_PURE }, {\n difference: function difference(iterable) {\n var set = anObject(this);\n var newSet = new (speciesConstructor(set, getBuiltIn('Set')))(set);\n var remover = aFunction(newSet['delete']);\n iterate(iterable, function (value) {\n remover.call(newSet, value);\n });\n return newSet;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar anObject = require('../internals/an-object');\nvar bind = require('../internals/function-bind-context');\nvar getSetIterator = require('../internals/get-set-iterator');\nvar iterate = require('../internals/iterate');\n\n// `Set.prototype.every` method\n// https://github.com/tc39/proposal-collection-methods\n$({ target: 'Set', proto: true, real: true, forced: IS_PURE }, {\n every: function every(callbackfn /* , thisArg */) {\n var set = anObject(this);\n var iterator = getSetIterator(set);\n var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);\n return !iterate(iterator, function (value) {\n if (!boundFunction(value, value, set)) return iterate.stop();\n }, undefined, false, true).stopped;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar getBuiltIn = require('../internals/get-built-in');\nvar anObject = require('../internals/an-object');\nvar aFunction = require('../internals/a-function');\nvar bind = require('../internals/function-bind-context');\nvar speciesConstructor = require('../internals/species-constructor');\nvar getSetIterator = require('../internals/get-set-iterator');\nvar iterate = require('../internals/iterate');\n\n// `Set.prototype.filter` method\n// https://github.com/tc39/proposal-collection-methods\n$({ target: 'Set', proto: true, real: true, forced: IS_PURE }, {\n filter: function filter(callbackfn /* , thisArg */) {\n var set = anObject(this);\n var iterator = getSetIterator(set);\n var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);\n var newSet = new (speciesConstructor(set, getBuiltIn('Set')))();\n var adder = aFunction(newSet.add);\n iterate(iterator, function (value) {\n if (boundFunction(value, value, set)) adder.call(newSet, value);\n }, undefined, false, true);\n return newSet;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar anObject = require('../internals/an-object');\nvar bind = require('../internals/function-bind-context');\nvar getSetIterator = require('../internals/get-set-iterator');\nvar iterate = require('../internals/iterate');\n\n// `Set.prototype.find` method\n// https://github.com/tc39/proposal-collection-methods\n$({ target: 'Set', proto: true, real: true, forced: IS_PURE }, {\n find: function find(callbackfn /* , thisArg */) {\n var set = anObject(this);\n var iterator = getSetIterator(set);\n var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);\n return iterate(iterator, function (value) {\n if (boundFunction(value, value, set)) return iterate.stop(value);\n }, undefined, false, true).result;\n }\n});\n","var $ = require('../internals/export');\nvar from = require('../internals/collection-from');\n\n// `Set.from` method\n// https://tc39.github.io/proposal-setmap-offrom/#sec-set.from\n$({ target: 'Set', stat: true }, {\n from: from\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar getBuiltIn = require('../internals/get-built-in');\nvar anObject = require('../internals/an-object');\nvar aFunction = require('../internals/a-function');\nvar speciesConstructor = require('../internals/species-constructor');\nvar iterate = require('../internals/iterate');\n\n// `Set.prototype.intersection` method\n// https://github.com/tc39/proposal-set-methods\n$({ target: 'Set', proto: true, real: true, forced: IS_PURE }, {\n intersection: function intersection(iterable) {\n var set = anObject(this);\n var newSet = new (speciesConstructor(set, getBuiltIn('Set')))();\n var hasCheck = aFunction(set.has);\n var adder = aFunction(newSet.add);\n iterate(iterable, function (value) {\n if (hasCheck.call(set, value)) adder.call(newSet, value);\n });\n return newSet;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar anObject = require('../internals/an-object');\nvar aFunction = require('../internals/a-function');\nvar iterate = require('../internals/iterate');\n\n// `Set.prototype.isDisjointFrom` method\n// https://tc39.github.io/proposal-set-methods/#Set.prototype.isDisjointFrom\n$({ target: 'Set', proto: true, real: true, forced: IS_PURE }, {\n isDisjointFrom: function isDisjointFrom(iterable) {\n var set = anObject(this);\n var hasCheck = aFunction(set.has);\n return !iterate(iterable, function (value) {\n if (hasCheck.call(set, value) === true) return iterate.stop();\n }).stopped;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar getBuiltIn = require('../internals/get-built-in');\nvar anObject = require('../internals/an-object');\nvar aFunction = require('../internals/a-function');\nvar getIterator = require('../internals/get-iterator');\nvar iterate = require('../internals/iterate');\n\n// `Set.prototype.isSubsetOf` method\n// https://tc39.github.io/proposal-set-methods/#Set.prototype.isSubsetOf\n$({ target: 'Set', proto: true, real: true, forced: IS_PURE }, {\n isSubsetOf: function isSubsetOf(iterable) {\n var iterator = getIterator(this);\n var otherSet = anObject(iterable);\n var hasCheck = otherSet.has;\n if (typeof hasCheck != 'function') {\n otherSet = new (getBuiltIn('Set'))(iterable);\n hasCheck = aFunction(otherSet.has);\n }\n return !iterate(iterator, function (value) {\n if (hasCheck.call(otherSet, value) === false) return iterate.stop();\n }, undefined, false, true).stopped;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar anObject = require('../internals/an-object');\nvar aFunction = require('../internals/a-function');\nvar iterate = require('../internals/iterate');\n\n// `Set.prototype.isSupersetOf` method\n// https://tc39.github.io/proposal-set-methods/#Set.prototype.isSupersetOf\n$({ target: 'Set', proto: true, real: true, forced: IS_PURE }, {\n isSupersetOf: function isSupersetOf(iterable) {\n var set = anObject(this);\n var hasCheck = aFunction(set.has);\n return !iterate(iterable, function (value) {\n if (hasCheck.call(set, value) === false) return iterate.stop();\n }).stopped;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar anObject = require('../internals/an-object');\nvar getSetIterator = require('../internals/get-set-iterator');\nvar iterate = require('../internals/iterate');\n\n// `Set.prototype.join` method\n// https://github.com/tc39/proposal-collection-methods\n$({ target: 'Set', proto: true, real: true, forced: IS_PURE }, {\n join: function join(separator) {\n var set = anObject(this);\n var iterator = getSetIterator(set);\n var sep = separator === undefined ? ',' : String(separator);\n var result = [];\n iterate(iterator, result.push, result, false, true);\n return result.join(sep);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar getBuiltIn = require('../internals/get-built-in');\nvar anObject = require('../internals/an-object');\nvar aFunction = require('../internals/a-function');\nvar bind = require('../internals/function-bind-context');\nvar speciesConstructor = require('../internals/species-constructor');\nvar getSetIterator = require('../internals/get-set-iterator');\nvar iterate = require('../internals/iterate');\n\n// `Set.prototype.map` method\n// https://github.com/tc39/proposal-collection-methods\n$({ target: 'Set', proto: true, real: true, forced: IS_PURE }, {\n map: function map(callbackfn /* , thisArg */) {\n var set = anObject(this);\n var iterator = getSetIterator(set);\n var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);\n var newSet = new (speciesConstructor(set, getBuiltIn('Set')))();\n var adder = aFunction(newSet.add);\n iterate(iterator, function (value) {\n adder.call(newSet, boundFunction(value, value, set));\n }, undefined, false, true);\n return newSet;\n }\n});\n","var $ = require('../internals/export');\nvar of = require('../internals/collection-of');\n\n// `Set.of` method\n// https://tc39.github.io/proposal-setmap-offrom/#sec-set.of\n$({ target: 'Set', stat: true }, {\n of: of\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar anObject = require('../internals/an-object');\nvar aFunction = require('../internals/a-function');\nvar getSetIterator = require('../internals/get-set-iterator');\nvar iterate = require('../internals/iterate');\n\n// `Set.prototype.reduce` method\n// https://github.com/tc39/proposal-collection-methods\n$({ target: 'Set', proto: true, real: true, forced: IS_PURE }, {\n reduce: function reduce(callbackfn /* , initialValue */) {\n var set = anObject(this);\n var iterator = getSetIterator(set);\n var noInitial = arguments.length < 2;\n var accumulator = noInitial ? undefined : arguments[1];\n aFunction(callbackfn);\n iterate(iterator, function (value) {\n if (noInitial) {\n noInitial = false;\n accumulator = value;\n } else {\n accumulator = callbackfn(accumulator, value, value, set);\n }\n }, undefined, false, true);\n if (noInitial) throw TypeError('Reduce of empty set with no initial value');\n return accumulator;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar anObject = require('../internals/an-object');\nvar bind = require('../internals/function-bind-context');\nvar getSetIterator = require('../internals/get-set-iterator');\nvar iterate = require('../internals/iterate');\n\n// `Set.prototype.some` method\n// https://github.com/tc39/proposal-collection-methods\n$({ target: 'Set', proto: true, real: true, forced: IS_PURE }, {\n some: function some(callbackfn /* , thisArg */) {\n var set = anObject(this);\n var iterator = getSetIterator(set);\n var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);\n return iterate(iterator, function (value) {\n if (boundFunction(value, value, set)) return iterate.stop();\n }, undefined, false, true).stopped;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar getBuiltIn = require('../internals/get-built-in');\nvar anObject = require('../internals/an-object');\nvar aFunction = require('../internals/a-function');\nvar speciesConstructor = require('../internals/species-constructor');\nvar iterate = require('../internals/iterate');\n\n// `Set.prototype.symmetricDifference` method\n// https://github.com/tc39/proposal-set-methods\n$({ target: 'Set', proto: true, real: true, forced: IS_PURE }, {\n symmetricDifference: function symmetricDifference(iterable) {\n var set = anObject(this);\n var newSet = new (speciesConstructor(set, getBuiltIn('Set')))(set);\n var remover = aFunction(newSet['delete']);\n var adder = aFunction(newSet.add);\n iterate(iterable, function (value) {\n remover.call(newSet, value) || adder.call(newSet, value);\n });\n return newSet;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar getBuiltIn = require('../internals/get-built-in');\nvar anObject = require('../internals/an-object');\nvar aFunction = require('../internals/a-function');\nvar speciesConstructor = require('../internals/species-constructor');\nvar iterate = require('../internals/iterate');\n\n// `Set.prototype.union` method\n// https://github.com/tc39/proposal-set-methods\n$({ target: 'Set', proto: true, real: true, forced: IS_PURE }, {\n union: function union(iterable) {\n var set = anObject(this);\n var newSet = new (speciesConstructor(set, getBuiltIn('Set')))(set);\n iterate(iterable, aFunction(newSet.add), newSet);\n return newSet;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar charAt = require('../internals/string-multibyte').charAt;\n\n// `String.prototype.at` method\n// https://github.com/mathiasbynens/String.prototype.at\n$({ target: 'String', proto: true }, {\n at: function at(pos) {\n return charAt(this, pos);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar createIteratorConstructor = require('../internals/create-iterator-constructor');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\nvar InternalStateModule = require('../internals/internal-state');\nvar StringMultibyteModule = require('../internals/string-multibyte');\n\nvar codeAt = StringMultibyteModule.codeAt;\nvar charAt = StringMultibyteModule.charAt;\nvar STRING_ITERATOR = 'String Iterator';\nvar setInternalState = InternalStateModule.set;\nvar getInternalState = InternalStateModule.getterFor(STRING_ITERATOR);\n\n// TODO: unify with String#@@iterator\nvar $StringIterator = createIteratorConstructor(function StringIterator(string) {\n setInternalState(this, {\n type: STRING_ITERATOR,\n string: string,\n index: 0\n });\n}, 'String', function next() {\n var state = getInternalState(this);\n var string = state.string;\n var index = state.index;\n var point;\n if (index >= string.length) return { value: undefined, done: true };\n point = charAt(string, index);\n state.index += point.length;\n return { value: { codePoint: codeAt(point, 0), position: index }, done: false };\n});\n\n// `String.prototype.codePoints` method\n// https://github.com/tc39/proposal-string-prototype-codepoints\n$({ target: 'String', proto: true }, {\n codePoints: function codePoints() {\n return new $StringIterator(String(requireObjectCoercible(this)));\n }\n});\n","// TODO: Remove from `core-js@4`\nrequire('./es.string.match-all');\n","'use strict';\nvar $ = require('../internals/export');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\nvar isRegExp = require('../internals/is-regexp');\nvar getRegExpFlags = require('../internals/regexp-flags');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar IS_PURE = require('../internals/is-pure');\n\nvar REPLACE = wellKnownSymbol('replace');\nvar RegExpPrototype = RegExp.prototype;\n\n// `String.prototype.replaceAll` method\n// https://github.com/tc39/proposal-string-replace-all\n$({ target: 'String', proto: true }, {\n replaceAll: function replaceAll(searchValue, replaceValue) {\n var O = requireObjectCoercible(this);\n var IS_REG_EXP, flags, replacer, string, searchString, template, result, position, index;\n if (searchValue != null) {\n IS_REG_EXP = isRegExp(searchValue);\n if (IS_REG_EXP) {\n flags = String(requireObjectCoercible('flags' in RegExpPrototype\n ? searchValue.flags\n : getRegExpFlags.call(searchValue)\n ));\n if (!~flags.indexOf('g')) throw TypeError('`.replaceAll` does not allow non-global regexes');\n }\n replacer = searchValue[REPLACE];\n if (replacer !== undefined) {\n return replacer.call(searchValue, O, replaceValue);\n } else if (IS_PURE && IS_REG_EXP) {\n return String(O).replace(searchValue, replaceValue);\n }\n }\n string = String(O);\n searchString = String(searchValue);\n if (searchString === '') return replaceAll.call(string, /(?:)/g, replaceValue);\n template = string.split(searchString);\n if (typeof replaceValue !== 'function') {\n return template.join(String(replaceValue));\n }\n result = template[0];\n position = result.length;\n for (index = 1; index < template.length; index++) {\n result += String(replaceValue(searchString, position, string));\n position += searchString.length + template[index].length;\n result += template[index];\n }\n return result;\n }\n});\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.dispose` well-known symbol\n// https://github.com/tc39/proposal-using-statement\ndefineWellKnownSymbol('dispose');\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.observable` well-known symbol\n// https://github.com/tc39/proposal-observable\ndefineWellKnownSymbol('observable');\n","var defineWellKnownSymbol = require('../internals/define-well-known-symbol');\n\n// `Symbol.patternMatch` well-known symbol\n// https://github.com/tc39/proposal-pattern-matching\ndefineWellKnownSymbol('patternMatch');\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar collectionDeleteAll = require('../internals/collection-delete-all');\n\n// `WeakMap.prototype.deleteAll` method\n// https://github.com/tc39/proposal-collection-methods\n$({ target: 'WeakMap', proto: true, real: true, forced: IS_PURE }, {\n deleteAll: function deleteAll(/* ...elements */) {\n return collectionDeleteAll.apply(this, arguments);\n }\n});\n","var $ = require('../internals/export');\nvar from = require('../internals/collection-from');\n\n// `WeakMap.from` method\n// https://tc39.github.io/proposal-setmap-offrom/#sec-weakmap.from\n$({ target: 'WeakMap', stat: true }, {\n from: from\n});\n","var $ = require('../internals/export');\nvar of = require('../internals/collection-of');\n\n// `WeakMap.of` method\n// https://tc39.github.io/proposal-setmap-offrom/#sec-weakmap.of\n$({ target: 'WeakMap', stat: true }, {\n of: of\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar collectionAddAll = require('../internals/collection-add-all');\n\n// `WeakSet.prototype.addAll` method\n// https://github.com/tc39/proposal-collection-methods\n$({ target: 'WeakSet', proto: true, real: true, forced: IS_PURE }, {\n addAll: function addAll(/* ...elements */) {\n return collectionAddAll.apply(this, arguments);\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar collectionDeleteAll = require('../internals/collection-delete-all');\n\n// `WeakSet.prototype.deleteAll` method\n// https://github.com/tc39/proposal-collection-methods\n$({ target: 'WeakSet', proto: true, real: true, forced: IS_PURE }, {\n deleteAll: function deleteAll(/* ...elements */) {\n return collectionDeleteAll.apply(this, arguments);\n }\n});\n","var $ = require('../internals/export');\nvar from = require('../internals/collection-from');\n\n// `WeakSet.from` method\n// https://tc39.github.io/proposal-setmap-offrom/#sec-weakset.from\n$({ target: 'WeakSet', stat: true }, {\n from: from\n});\n","var $ = require('../internals/export');\nvar of = require('../internals/collection-of');\n\n// `WeakSet.of` method\n// https://tc39.github.io/proposal-setmap-offrom/#sec-weakset.of\n$({ target: 'WeakSet', stat: true }, {\n of: of\n});\n","var global = require('../internals/global');\nvar DOMIterables = require('../internals/dom-iterables');\nvar forEach = require('../internals/array-for-each');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\n\nfor (var COLLECTION_NAME in DOMIterables) {\n var Collection = global[COLLECTION_NAME];\n var CollectionPrototype = Collection && Collection.prototype;\n // some Chrome versions have non-configurable methods on DOMTokenList\n if (CollectionPrototype && CollectionPrototype.forEach !== forEach) try {\n createNonEnumerableProperty(CollectionPrototype, 'forEach', forEach);\n } catch (error) {\n CollectionPrototype.forEach = forEach;\n }\n}\n","var global = require('../internals/global');\nvar DOMIterables = require('../internals/dom-iterables');\nvar ArrayIteratorMethods = require('../modules/es.array.iterator');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar ITERATOR = wellKnownSymbol('iterator');\nvar TO_STRING_TAG = wellKnownSymbol('toStringTag');\nvar ArrayValues = ArrayIteratorMethods.values;\n\nfor (var COLLECTION_NAME in DOMIterables) {\n var Collection = global[COLLECTION_NAME];\n var CollectionPrototype = Collection && Collection.prototype;\n if (CollectionPrototype) {\n // some Chrome versions have non-configurable methods on DOMTokenList\n if (CollectionPrototype[ITERATOR] !== ArrayValues) try {\n createNonEnumerableProperty(CollectionPrototype, ITERATOR, ArrayValues);\n } catch (error) {\n CollectionPrototype[ITERATOR] = ArrayValues;\n }\n if (!CollectionPrototype[TO_STRING_TAG]) {\n createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG, COLLECTION_NAME);\n }\n if (DOMIterables[COLLECTION_NAME]) for (var METHOD_NAME in ArrayIteratorMethods) {\n // some Chrome versions have non-configurable methods on DOMTokenList\n if (CollectionPrototype[METHOD_NAME] !== ArrayIteratorMethods[METHOD_NAME]) try {\n createNonEnumerableProperty(CollectionPrototype, METHOD_NAME, ArrayIteratorMethods[METHOD_NAME]);\n } catch (error) {\n CollectionPrototype[METHOD_NAME] = ArrayIteratorMethods[METHOD_NAME];\n }\n }\n }\n}\n","var $ = require('../internals/export');\nvar global = require('../internals/global');\nvar task = require('../internals/task');\n\nvar FORCED = !global.setImmediate || !global.clearImmediate;\n\n// http://w3c.github.io/setImmediate/\n$({ global: true, bind: true, enumerable: true, forced: FORCED }, {\n // `setImmediate` method\n // http://w3c.github.io/setImmediate/#si-setImmediate\n setImmediate: task.set,\n // `clearImmediate` method\n // http://w3c.github.io/setImmediate/#si-clearImmediate\n clearImmediate: task.clear\n});\n","var $ = require('../internals/export');\nvar global = require('../internals/global');\nvar microtask = require('../internals/microtask');\nvar classof = require('../internals/classof-raw');\n\nvar process = global.process;\nvar isNode = classof(process) == 'process';\n\n// `queueMicrotask` method\n// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-queuemicrotask\n$({ global: true, enumerable: true, noTargetGet: true }, {\n queueMicrotask: function queueMicrotask(fn) {\n var domain = isNode && process.domain;\n microtask(domain ? domain.bind(fn) : fn);\n }\n});\n","'use strict';\n// TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`\nrequire('../modules/es.array.iterator');\nvar $ = require('../internals/export');\nvar getBuiltIn = require('../internals/get-built-in');\nvar USE_NATIVE_URL = require('../internals/native-url');\nvar redefine = require('../internals/redefine');\nvar redefineAll = require('../internals/redefine-all');\nvar setToStringTag = require('../internals/set-to-string-tag');\nvar createIteratorConstructor = require('../internals/create-iterator-constructor');\nvar InternalStateModule = require('../internals/internal-state');\nvar anInstance = require('../internals/an-instance');\nvar hasOwn = require('../internals/has');\nvar bind = require('../internals/function-bind-context');\nvar classof = require('../internals/classof');\nvar anObject = require('../internals/an-object');\nvar isObject = require('../internals/is-object');\nvar create = require('../internals/object-create');\nvar createPropertyDescriptor = require('../internals/create-property-descriptor');\nvar getIterator = require('../internals/get-iterator');\nvar getIteratorMethod = require('../internals/get-iterator-method');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar $fetch = getBuiltIn('fetch');\nvar Headers = getBuiltIn('Headers');\nvar ITERATOR = wellKnownSymbol('iterator');\nvar URL_SEARCH_PARAMS = 'URLSearchParams';\nvar URL_SEARCH_PARAMS_ITERATOR = URL_SEARCH_PARAMS + 'Iterator';\nvar setInternalState = InternalStateModule.set;\nvar getInternalParamsState = InternalStateModule.getterFor(URL_SEARCH_PARAMS);\nvar getInternalIteratorState = InternalStateModule.getterFor(URL_SEARCH_PARAMS_ITERATOR);\n\nvar plus = /\\+/g;\nvar sequences = Array(4);\n\nvar percentSequence = function (bytes) {\n return sequences[bytes - 1] || (sequences[bytes - 1] = RegExp('((?:%[\\\\da-f]{2}){' + bytes + '})', 'gi'));\n};\n\nvar percentDecode = function (sequence) {\n try {\n return decodeURIComponent(sequence);\n } catch (error) {\n return sequence;\n }\n};\n\nvar deserialize = function (it) {\n var result = it.replace(plus, ' ');\n var bytes = 4;\n try {\n return decodeURIComponent(result);\n } catch (error) {\n while (bytes) {\n result = result.replace(percentSequence(bytes--), percentDecode);\n }\n return result;\n }\n};\n\nvar find = /[!'()~]|%20/g;\n\nvar replace = {\n '!': '%21',\n \"'\": '%27',\n '(': '%28',\n ')': '%29',\n '~': '%7E',\n '%20': '+'\n};\n\nvar replacer = function (match) {\n return replace[match];\n};\n\nvar serialize = function (it) {\n return encodeURIComponent(it).replace(find, replacer);\n};\n\nvar parseSearchParams = function (result, query) {\n if (query) {\n var attributes = query.split('&');\n var index = 0;\n var attribute, entry;\n while (index < attributes.length) {\n attribute = attributes[index++];\n if (attribute.length) {\n entry = attribute.split('=');\n result.push({\n key: deserialize(entry.shift()),\n value: deserialize(entry.join('='))\n });\n }\n }\n }\n};\n\nvar updateSearchParams = function (query) {\n this.entries.length = 0;\n parseSearchParams(this.entries, query);\n};\n\nvar validateArgumentsLength = function (passed, required) {\n if (passed < required) throw TypeError('Not enough arguments');\n};\n\nvar URLSearchParamsIterator = createIteratorConstructor(function Iterator(params, kind) {\n setInternalState(this, {\n type: URL_SEARCH_PARAMS_ITERATOR,\n iterator: getIterator(getInternalParamsState(params).entries),\n kind: kind\n });\n}, 'Iterator', function next() {\n var state = getInternalIteratorState(this);\n var kind = state.kind;\n var step = state.iterator.next();\n var entry = step.value;\n if (!step.done) {\n step.value = kind === 'keys' ? entry.key : kind === 'values' ? entry.value : [entry.key, entry.value];\n } return step;\n});\n\n// `URLSearchParams` constructor\n// https://url.spec.whatwg.org/#interface-urlsearchparams\nvar URLSearchParamsConstructor = function URLSearchParams(/* init */) {\n anInstance(this, URLSearchParamsConstructor, URL_SEARCH_PARAMS);\n var init = arguments.length > 0 ? arguments[0] : undefined;\n var that = this;\n var entries = [];\n var iteratorMethod, iterator, next, step, entryIterator, entryNext, first, second, key;\n\n setInternalState(that, {\n type: URL_SEARCH_PARAMS,\n entries: entries,\n updateURL: function () { /* empty */ },\n updateSearchParams: updateSearchParams\n });\n\n if (init !== undefined) {\n if (isObject(init)) {\n iteratorMethod = getIteratorMethod(init);\n if (typeof iteratorMethod === 'function') {\n iterator = iteratorMethod.call(init);\n next = iterator.next;\n while (!(step = next.call(iterator)).done) {\n entryIterator = getIterator(anObject(step.value));\n entryNext = entryIterator.next;\n if (\n (first = entryNext.call(entryIterator)).done ||\n (second = entryNext.call(entryIterator)).done ||\n !entryNext.call(entryIterator).done\n ) throw TypeError('Expected sequence with length 2');\n entries.push({ key: first.value + '', value: second.value + '' });\n }\n } else for (key in init) if (hasOwn(init, key)) entries.push({ key: key, value: init[key] + '' });\n } else {\n parseSearchParams(entries, typeof init === 'string' ? init.charAt(0) === '?' ? init.slice(1) : init : init + '');\n }\n }\n};\n\nvar URLSearchParamsPrototype = URLSearchParamsConstructor.prototype;\n\nredefineAll(URLSearchParamsPrototype, {\n // `URLSearchParams.prototype.appent` method\n // https://url.spec.whatwg.org/#dom-urlsearchparams-append\n append: function append(name, value) {\n validateArgumentsLength(arguments.length, 2);\n var state = getInternalParamsState(this);\n state.entries.push({ key: name + '', value: value + '' });\n state.updateURL();\n },\n // `URLSearchParams.prototype.delete` method\n // https://url.spec.whatwg.org/#dom-urlsearchparams-delete\n 'delete': function (name) {\n validateArgumentsLength(arguments.length, 1);\n var state = getInternalParamsState(this);\n var entries = state.entries;\n var key = name + '';\n var index = 0;\n while (index < entries.length) {\n if (entries[index].key === key) entries.splice(index, 1);\n else index++;\n }\n state.updateURL();\n },\n // `URLSearchParams.prototype.get` method\n // https://url.spec.whatwg.org/#dom-urlsearchparams-get\n get: function get(name) {\n validateArgumentsLength(arguments.length, 1);\n var entries = getInternalParamsState(this).entries;\n var key = name + '';\n var index = 0;\n for (; index < entries.length; index++) {\n if (entries[index].key === key) return entries[index].value;\n }\n return null;\n },\n // `URLSearchParams.prototype.getAll` method\n // https://url.spec.whatwg.org/#dom-urlsearchparams-getall\n getAll: function getAll(name) {\n validateArgumentsLength(arguments.length, 1);\n var entries = getInternalParamsState(this).entries;\n var key = name + '';\n var result = [];\n var index = 0;\n for (; index < entries.length; index++) {\n if (entries[index].key === key) result.push(entries[index].value);\n }\n return result;\n },\n // `URLSearchParams.prototype.has` method\n // https://url.spec.whatwg.org/#dom-urlsearchparams-has\n has: function has(name) {\n validateArgumentsLength(arguments.length, 1);\n var entries = getInternalParamsState(this).entries;\n var key = name + '';\n var index = 0;\n while (index < entries.length) {\n if (entries[index++].key === key) return true;\n }\n return false;\n },\n // `URLSearchParams.prototype.set` method\n // https://url.spec.whatwg.org/#dom-urlsearchparams-set\n set: function set(name, value) {\n validateArgumentsLength(arguments.length, 1);\n var state = getInternalParamsState(this);\n var entries = state.entries;\n var found = false;\n var key = name + '';\n var val = value + '';\n var index = 0;\n var entry;\n for (; index < entries.length; index++) {\n entry = entries[index];\n if (entry.key === key) {\n if (found) entries.splice(index--, 1);\n else {\n found = true;\n entry.value = val;\n }\n }\n }\n if (!found) entries.push({ key: key, value: val });\n state.updateURL();\n },\n // `URLSearchParams.prototype.sort` method\n // https://url.spec.whatwg.org/#dom-urlsearchparams-sort\n sort: function sort() {\n var state = getInternalParamsState(this);\n var entries = state.entries;\n // Array#sort is not stable in some engines\n var slice = entries.slice();\n var entry, entriesIndex, sliceIndex;\n entries.length = 0;\n for (sliceIndex = 0; sliceIndex < slice.length; sliceIndex++) {\n entry = slice[sliceIndex];\n for (entriesIndex = 0; entriesIndex < sliceIndex; entriesIndex++) {\n if (entries[entriesIndex].key > entry.key) {\n entries.splice(entriesIndex, 0, entry);\n break;\n }\n }\n if (entriesIndex === sliceIndex) entries.push(entry);\n }\n state.updateURL();\n },\n // `URLSearchParams.prototype.forEach` method\n forEach: function forEach(callback /* , thisArg */) {\n var entries = getInternalParamsState(this).entries;\n var boundFunction = bind(callback, arguments.length > 1 ? arguments[1] : undefined, 3);\n var index = 0;\n var entry;\n while (index < entries.length) {\n entry = entries[index++];\n boundFunction(entry.value, entry.key, this);\n }\n },\n // `URLSearchParams.prototype.keys` method\n keys: function keys() {\n return new URLSearchParamsIterator(this, 'keys');\n },\n // `URLSearchParams.prototype.values` method\n values: function values() {\n return new URLSearchParamsIterator(this, 'values');\n },\n // `URLSearchParams.prototype.entries` method\n entries: function entries() {\n return new URLSearchParamsIterator(this, 'entries');\n }\n}, { enumerable: true });\n\n// `URLSearchParams.prototype[@@iterator]` method\nredefine(URLSearchParamsPrototype, ITERATOR, URLSearchParamsPrototype.entries);\n\n// `URLSearchParams.prototype.toString` method\n// https://url.spec.whatwg.org/#urlsearchparams-stringification-behavior\nredefine(URLSearchParamsPrototype, 'toString', function toString() {\n var entries = getInternalParamsState(this).entries;\n var result = [];\n var index = 0;\n var entry;\n while (index < entries.length) {\n entry = entries[index++];\n result.push(serialize(entry.key) + '=' + serialize(entry.value));\n } return result.join('&');\n}, { enumerable: true });\n\nsetToStringTag(URLSearchParamsConstructor, URL_SEARCH_PARAMS);\n\n$({ global: true, forced: !USE_NATIVE_URL }, {\n URLSearchParams: URLSearchParamsConstructor\n});\n\n// Wrap `fetch` for correct work with polyfilled `URLSearchParams`\n// https://github.com/zloirock/core-js/issues/674\nif (!USE_NATIVE_URL && typeof $fetch == 'function' && typeof Headers == 'function') {\n $({ global: true, enumerable: true, forced: true }, {\n fetch: function fetch(input /* , init */) {\n var args = [input];\n var init, body, headers;\n if (arguments.length > 1) {\n init = arguments[1];\n if (isObject(init)) {\n body = init.body;\n if (classof(body) === URL_SEARCH_PARAMS) {\n headers = init.headers ? new Headers(init.headers) : new Headers();\n if (!headers.has('content-type')) {\n headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');\n }\n init = create(init, {\n body: createPropertyDescriptor(0, String(body)),\n headers: createPropertyDescriptor(0, headers)\n });\n }\n }\n args.push(init);\n } return $fetch.apply(this, args);\n }\n });\n}\n\nmodule.exports = {\n URLSearchParams: URLSearchParamsConstructor,\n getState: getInternalParamsState\n};\n","'use strict';\n// TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`\nrequire('../modules/es.string.iterator');\nvar $ = require('../internals/export');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar USE_NATIVE_URL = require('../internals/native-url');\nvar global = require('../internals/global');\nvar defineProperties = require('../internals/object-define-properties');\nvar redefine = require('../internals/redefine');\nvar anInstance = require('../internals/an-instance');\nvar has = require('../internals/has');\nvar assign = require('../internals/object-assign');\nvar arrayFrom = require('../internals/array-from');\nvar codeAt = require('../internals/string-multibyte').codeAt;\nvar toASCII = require('../internals/string-punycode-to-ascii');\nvar setToStringTag = require('../internals/set-to-string-tag');\nvar URLSearchParamsModule = require('../modules/web.url-search-params');\nvar InternalStateModule = require('../internals/internal-state');\n\nvar NativeURL = global.URL;\nvar URLSearchParams = URLSearchParamsModule.URLSearchParams;\nvar getInternalSearchParamsState = URLSearchParamsModule.getState;\nvar setInternalState = InternalStateModule.set;\nvar getInternalURLState = InternalStateModule.getterFor('URL');\nvar floor = Math.floor;\nvar pow = Math.pow;\n\nvar INVALID_AUTHORITY = 'Invalid authority';\nvar INVALID_SCHEME = 'Invalid scheme';\nvar INVALID_HOST = 'Invalid host';\nvar INVALID_PORT = 'Invalid port';\n\nvar ALPHA = /[A-Za-z]/;\nvar ALPHANUMERIC = /[\\d+-.A-Za-z]/;\nvar DIGIT = /\\d/;\nvar HEX_START = /^(0x|0X)/;\nvar OCT = /^[0-7]+$/;\nvar DEC = /^\\d+$/;\nvar HEX = /^[\\dA-Fa-f]+$/;\n// eslint-disable-next-line no-control-regex\nvar FORBIDDEN_HOST_CODE_POINT = /[\\u0000\\u0009\\u000A\\u000D #%/:?@[\\\\]]/;\n// eslint-disable-next-line no-control-regex\nvar FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT = /[\\u0000\\u0009\\u000A\\u000D #/:?@[\\\\]]/;\n// eslint-disable-next-line no-control-regex\nvar LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE = /^[\\u0000-\\u001F ]+|[\\u0000-\\u001F ]+$/g;\n// eslint-disable-next-line no-control-regex\nvar TAB_AND_NEW_LINE = /[\\u0009\\u000A\\u000D]/g;\nvar EOF;\n\nvar parseHost = function (url, input) {\n var result, codePoints, index;\n if (input.charAt(0) == '[') {\n if (input.charAt(input.length - 1) != ']') return INVALID_HOST;\n result = parseIPv6(input.slice(1, -1));\n if (!result) return INVALID_HOST;\n url.host = result;\n // opaque host\n } else if (!isSpecial(url)) {\n if (FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT.test(input)) return INVALID_HOST;\n result = '';\n codePoints = arrayFrom(input);\n for (index = 0; index < codePoints.length; index++) {\n result += percentEncode(codePoints[index], C0ControlPercentEncodeSet);\n }\n url.host = result;\n } else {\n input = toASCII(input);\n if (FORBIDDEN_HOST_CODE_POINT.test(input)) return INVALID_HOST;\n result = parseIPv4(input);\n if (result === null) return INVALID_HOST;\n url.host = result;\n }\n};\n\nvar parseIPv4 = function (input) {\n var parts = input.split('.');\n var partsLength, numbers, index, part, radix, number, ipv4;\n if (parts.length && parts[parts.length - 1] == '') {\n parts.pop();\n }\n partsLength = parts.length;\n if (partsLength > 4) return input;\n numbers = [];\n for (index = 0; index < partsLength; index++) {\n part = parts[index];\n if (part == '') return input;\n radix = 10;\n if (part.length > 1 && part.charAt(0) == '0') {\n radix = HEX_START.test(part) ? 16 : 8;\n part = part.slice(radix == 8 ? 1 : 2);\n }\n if (part === '') {\n number = 0;\n } else {\n if (!(radix == 10 ? DEC : radix == 8 ? OCT : HEX).test(part)) return input;\n number = parseInt(part, radix);\n }\n numbers.push(number);\n }\n for (index = 0; index < partsLength; index++) {\n number = numbers[index];\n if (index == partsLength - 1) {\n if (number >= pow(256, 5 - partsLength)) return null;\n } else if (number > 255) return null;\n }\n ipv4 = numbers.pop();\n for (index = 0; index < numbers.length; index++) {\n ipv4 += numbers[index] * pow(256, 3 - index);\n }\n return ipv4;\n};\n\n// eslint-disable-next-line max-statements\nvar parseIPv6 = function (input) {\n var address = [0, 0, 0, 0, 0, 0, 0, 0];\n var pieceIndex = 0;\n var compress = null;\n var pointer = 0;\n var value, length, numbersSeen, ipv4Piece, number, swaps, swap;\n\n var char = function () {\n return input.charAt(pointer);\n };\n\n if (char() == ':') {\n if (input.charAt(1) != ':') return;\n pointer += 2;\n pieceIndex++;\n compress = pieceIndex;\n }\n while (char()) {\n if (pieceIndex == 8) return;\n if (char() == ':') {\n if (compress !== null) return;\n pointer++;\n pieceIndex++;\n compress = pieceIndex;\n continue;\n }\n value = length = 0;\n while (length < 4 && HEX.test(char())) {\n value = value * 16 + parseInt(char(), 16);\n pointer++;\n length++;\n }\n if (char() == '.') {\n if (length == 0) return;\n pointer -= length;\n if (pieceIndex > 6) return;\n numbersSeen = 0;\n while (char()) {\n ipv4Piece = null;\n if (numbersSeen > 0) {\n if (char() == '.' && numbersSeen < 4) pointer++;\n else return;\n }\n if (!DIGIT.test(char())) return;\n while (DIGIT.test(char())) {\n number = parseInt(char(), 10);\n if (ipv4Piece === null) ipv4Piece = number;\n else if (ipv4Piece == 0) return;\n else ipv4Piece = ipv4Piece * 10 + number;\n if (ipv4Piece > 255) return;\n pointer++;\n }\n address[pieceIndex] = address[pieceIndex] * 256 + ipv4Piece;\n numbersSeen++;\n if (numbersSeen == 2 || numbersSeen == 4) pieceIndex++;\n }\n if (numbersSeen != 4) return;\n break;\n } else if (char() == ':') {\n pointer++;\n if (!char()) return;\n } else if (char()) return;\n address[pieceIndex++] = value;\n }\n if (compress !== null) {\n swaps = pieceIndex - compress;\n pieceIndex = 7;\n while (pieceIndex != 0 && swaps > 0) {\n swap = address[pieceIndex];\n address[pieceIndex--] = address[compress + swaps - 1];\n address[compress + --swaps] = swap;\n }\n } else if (pieceIndex != 8) return;\n return address;\n};\n\nvar findLongestZeroSequence = function (ipv6) {\n var maxIndex = null;\n var maxLength = 1;\n var currStart = null;\n var currLength = 0;\n var index = 0;\n for (; index < 8; index++) {\n if (ipv6[index] !== 0) {\n if (currLength > maxLength) {\n maxIndex = currStart;\n maxLength = currLength;\n }\n currStart = null;\n currLength = 0;\n } else {\n if (currStart === null) currStart = index;\n ++currLength;\n }\n }\n if (currLength > maxLength) {\n maxIndex = currStart;\n maxLength = currLength;\n }\n return maxIndex;\n};\n\nvar serializeHost = function (host) {\n var result, index, compress, ignore0;\n // ipv4\n if (typeof host == 'number') {\n result = [];\n for (index = 0; index < 4; index++) {\n result.unshift(host % 256);\n host = floor(host / 256);\n } return result.join('.');\n // ipv6\n } else if (typeof host == 'object') {\n result = '';\n compress = findLongestZeroSequence(host);\n for (index = 0; index < 8; index++) {\n if (ignore0 && host[index] === 0) continue;\n if (ignore0) ignore0 = false;\n if (compress === index) {\n result += index ? ':' : '::';\n ignore0 = true;\n } else {\n result += host[index].toString(16);\n if (index < 7) result += ':';\n }\n }\n return '[' + result + ']';\n } return host;\n};\n\nvar C0ControlPercentEncodeSet = {};\nvar fragmentPercentEncodeSet = assign({}, C0ControlPercentEncodeSet, {\n ' ': 1, '\"': 1, '<': 1, '>': 1, '`': 1\n});\nvar pathPercentEncodeSet = assign({}, fragmentPercentEncodeSet, {\n '#': 1, '?': 1, '{': 1, '}': 1\n});\nvar userinfoPercentEncodeSet = assign({}, pathPercentEncodeSet, {\n '/': 1, ':': 1, ';': 1, '=': 1, '@': 1, '[': 1, '\\\\': 1, ']': 1, '^': 1, '|': 1\n});\n\nvar percentEncode = function (char, set) {\n var code = codeAt(char, 0);\n return code > 0x20 && code < 0x7F && !has(set, char) ? char : encodeURIComponent(char);\n};\n\nvar specialSchemes = {\n ftp: 21,\n file: null,\n http: 80,\n https: 443,\n ws: 80,\n wss: 443\n};\n\nvar isSpecial = function (url) {\n return has(specialSchemes, url.scheme);\n};\n\nvar includesCredentials = function (url) {\n return url.username != '' || url.password != '';\n};\n\nvar cannotHaveUsernamePasswordPort = function (url) {\n return !url.host || url.cannotBeABaseURL || url.scheme == 'file';\n};\n\nvar isWindowsDriveLetter = function (string, normalized) {\n var second;\n return string.length == 2 && ALPHA.test(string.charAt(0))\n && ((second = string.charAt(1)) == ':' || (!normalized && second == '|'));\n};\n\nvar startsWithWindowsDriveLetter = function (string) {\n var third;\n return string.length > 1 && isWindowsDriveLetter(string.slice(0, 2)) && (\n string.length == 2 ||\n ((third = string.charAt(2)) === '/' || third === '\\\\' || third === '?' || third === '#')\n );\n};\n\nvar shortenURLsPath = function (url) {\n var path = url.path;\n var pathSize = path.length;\n if (pathSize && (url.scheme != 'file' || pathSize != 1 || !isWindowsDriveLetter(path[0], true))) {\n path.pop();\n }\n};\n\nvar isSingleDot = function (segment) {\n return segment === '.' || segment.toLowerCase() === '%2e';\n};\n\nvar isDoubleDot = function (segment) {\n segment = segment.toLowerCase();\n return segment === '..' || segment === '%2e.' || segment === '.%2e' || segment === '%2e%2e';\n};\n\n// States:\nvar SCHEME_START = {};\nvar SCHEME = {};\nvar NO_SCHEME = {};\nvar SPECIAL_RELATIVE_OR_AUTHORITY = {};\nvar PATH_OR_AUTHORITY = {};\nvar RELATIVE = {};\nvar RELATIVE_SLASH = {};\nvar SPECIAL_AUTHORITY_SLASHES = {};\nvar SPECIAL_AUTHORITY_IGNORE_SLASHES = {};\nvar AUTHORITY = {};\nvar HOST = {};\nvar HOSTNAME = {};\nvar PORT = {};\nvar FILE = {};\nvar FILE_SLASH = {};\nvar FILE_HOST = {};\nvar PATH_START = {};\nvar PATH = {};\nvar CANNOT_BE_A_BASE_URL_PATH = {};\nvar QUERY = {};\nvar FRAGMENT = {};\n\n// eslint-disable-next-line max-statements\nvar parseURL = function (url, input, stateOverride, base) {\n var state = stateOverride || SCHEME_START;\n var pointer = 0;\n var buffer = '';\n var seenAt = false;\n var seenBracket = false;\n var seenPasswordToken = false;\n var codePoints, char, bufferCodePoints, failure;\n\n if (!stateOverride) {\n url.scheme = '';\n url.username = '';\n url.password = '';\n url.host = null;\n url.port = null;\n url.path = [];\n url.query = null;\n url.fragment = null;\n url.cannotBeABaseURL = false;\n input = input.replace(LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE, '');\n }\n\n input = input.replace(TAB_AND_NEW_LINE, '');\n\n codePoints = arrayFrom(input);\n\n while (pointer <= codePoints.length) {\n char = codePoints[pointer];\n switch (state) {\n case SCHEME_START:\n if (char && ALPHA.test(char)) {\n buffer += char.toLowerCase();\n state = SCHEME;\n } else if (!stateOverride) {\n state = NO_SCHEME;\n continue;\n } else return INVALID_SCHEME;\n break;\n\n case SCHEME:\n if (char && (ALPHANUMERIC.test(char) || char == '+' || char == '-' || char == '.')) {\n buffer += char.toLowerCase();\n } else if (char == ':') {\n if (stateOverride && (\n (isSpecial(url) != has(specialSchemes, buffer)) ||\n (buffer == 'file' && (includesCredentials(url) || url.port !== null)) ||\n (url.scheme == 'file' && !url.host)\n )) return;\n url.scheme = buffer;\n if (stateOverride) {\n if (isSpecial(url) && specialSchemes[url.scheme] == url.port) url.port = null;\n return;\n }\n buffer = '';\n if (url.scheme == 'file') {\n state = FILE;\n } else if (isSpecial(url) && base && base.scheme == url.scheme) {\n state = SPECIAL_RELATIVE_OR_AUTHORITY;\n } else if (isSpecial(url)) {\n state = SPECIAL_AUTHORITY_SLASHES;\n } else if (codePoints[pointer + 1] == '/') {\n state = PATH_OR_AUTHORITY;\n pointer++;\n } else {\n url.cannotBeABaseURL = true;\n url.path.push('');\n state = CANNOT_BE_A_BASE_URL_PATH;\n }\n } else if (!stateOverride) {\n buffer = '';\n state = NO_SCHEME;\n pointer = 0;\n continue;\n } else return INVALID_SCHEME;\n break;\n\n case NO_SCHEME:\n if (!base || (base.cannotBeABaseURL && char != '#')) return INVALID_SCHEME;\n if (base.cannotBeABaseURL && char == '#') {\n url.scheme = base.scheme;\n url.path = base.path.slice();\n url.query = base.query;\n url.fragment = '';\n url.cannotBeABaseURL = true;\n state = FRAGMENT;\n break;\n }\n state = base.scheme == 'file' ? FILE : RELATIVE;\n continue;\n\n case SPECIAL_RELATIVE_OR_AUTHORITY:\n if (char == '/' && codePoints[pointer + 1] == '/') {\n state = SPECIAL_AUTHORITY_IGNORE_SLASHES;\n pointer++;\n } else {\n state = RELATIVE;\n continue;\n } break;\n\n case PATH_OR_AUTHORITY:\n if (char == '/') {\n state = AUTHORITY;\n break;\n } else {\n state = PATH;\n continue;\n }\n\n case RELATIVE:\n url.scheme = base.scheme;\n if (char == EOF) {\n url.username = base.username;\n url.password = base.password;\n url.host = base.host;\n url.port = base.port;\n url.path = base.path.slice();\n url.query = base.query;\n } else if (char == '/' || (char == '\\\\' && isSpecial(url))) {\n state = RELATIVE_SLASH;\n } else if (char == '?') {\n url.username = base.username;\n url.password = base.password;\n url.host = base.host;\n url.port = base.port;\n url.path = base.path.slice();\n url.query = '';\n state = QUERY;\n } else if (char == '#') {\n url.username = base.username;\n url.password = base.password;\n url.host = base.host;\n url.port = base.port;\n url.path = base.path.slice();\n url.query = base.query;\n url.fragment = '';\n state = FRAGMENT;\n } else {\n url.username = base.username;\n url.password = base.password;\n url.host = base.host;\n url.port = base.port;\n url.path = base.path.slice();\n url.path.pop();\n state = PATH;\n continue;\n } break;\n\n case RELATIVE_SLASH:\n if (isSpecial(url) && (char == '/' || char == '\\\\')) {\n state = SPECIAL_AUTHORITY_IGNORE_SLASHES;\n } else if (char == '/') {\n state = AUTHORITY;\n } else {\n url.username = base.username;\n url.password = base.password;\n url.host = base.host;\n url.port = base.port;\n state = PATH;\n continue;\n } break;\n\n case SPECIAL_AUTHORITY_SLASHES:\n state = SPECIAL_AUTHORITY_IGNORE_SLASHES;\n if (char != '/' || buffer.charAt(pointer + 1) != '/') continue;\n pointer++;\n break;\n\n case SPECIAL_AUTHORITY_IGNORE_SLASHES:\n if (char != '/' && char != '\\\\') {\n state = AUTHORITY;\n continue;\n } break;\n\n case AUTHORITY:\n if (char == '@') {\n if (seenAt) buffer = '%40' + buffer;\n seenAt = true;\n bufferCodePoints = arrayFrom(buffer);\n for (var i = 0; i < bufferCodePoints.length; i++) {\n var codePoint = bufferCodePoints[i];\n if (codePoint == ':' && !seenPasswordToken) {\n seenPasswordToken = true;\n continue;\n }\n var encodedCodePoints = percentEncode(codePoint, userinfoPercentEncodeSet);\n if (seenPasswordToken) url.password += encodedCodePoints;\n else url.username += encodedCodePoints;\n }\n buffer = '';\n } else if (\n char == EOF || char == '/' || char == '?' || char == '#' ||\n (char == '\\\\' && isSpecial(url))\n ) {\n if (seenAt && buffer == '') return INVALID_AUTHORITY;\n pointer -= arrayFrom(buffer).length + 1;\n buffer = '';\n state = HOST;\n } else buffer += char;\n break;\n\n case HOST:\n case HOSTNAME:\n if (stateOverride && url.scheme == 'file') {\n state = FILE_HOST;\n continue;\n } else if (char == ':' && !seenBracket) {\n if (buffer == '') return INVALID_HOST;\n failure = parseHost(url, buffer);\n if (failure) return failure;\n buffer = '';\n state = PORT;\n if (stateOverride == HOSTNAME) return;\n } else if (\n char == EOF || char == '/' || char == '?' || char == '#' ||\n (char == '\\\\' && isSpecial(url))\n ) {\n if (isSpecial(url) && buffer == '') return INVALID_HOST;\n if (stateOverride && buffer == '' && (includesCredentials(url) || url.port !== null)) return;\n failure = parseHost(url, buffer);\n if (failure) return failure;\n buffer = '';\n state = PATH_START;\n if (stateOverride) return;\n continue;\n } else {\n if (char == '[') seenBracket = true;\n else if (char == ']') seenBracket = false;\n buffer += char;\n } break;\n\n case PORT:\n if (DIGIT.test(char)) {\n buffer += char;\n } else if (\n char == EOF || char == '/' || char == '?' || char == '#' ||\n (char == '\\\\' && isSpecial(url)) ||\n stateOverride\n ) {\n if (buffer != '') {\n var port = parseInt(buffer, 10);\n if (port > 0xFFFF) return INVALID_PORT;\n url.port = (isSpecial(url) && port === specialSchemes[url.scheme]) ? null : port;\n buffer = '';\n }\n if (stateOverride) return;\n state = PATH_START;\n continue;\n } else return INVALID_PORT;\n break;\n\n case FILE:\n url.scheme = 'file';\n if (char == '/' || char == '\\\\') state = FILE_SLASH;\n else if (base && base.scheme == 'file') {\n if (char == EOF) {\n url.host = base.host;\n url.path = base.path.slice();\n url.query = base.query;\n } else if (char == '?') {\n url.host = base.host;\n url.path = base.path.slice();\n url.query = '';\n state = QUERY;\n } else if (char == '#') {\n url.host = base.host;\n url.path = base.path.slice();\n url.query = base.query;\n url.fragment = '';\n state = FRAGMENT;\n } else {\n if (!startsWithWindowsDriveLetter(codePoints.slice(pointer).join(''))) {\n url.host = base.host;\n url.path = base.path.slice();\n shortenURLsPath(url);\n }\n state = PATH;\n continue;\n }\n } else {\n state = PATH;\n continue;\n } break;\n\n case FILE_SLASH:\n if (char == '/' || char == '\\\\') {\n state = FILE_HOST;\n break;\n }\n if (base && base.scheme == 'file' && !startsWithWindowsDriveLetter(codePoints.slice(pointer).join(''))) {\n if (isWindowsDriveLetter(base.path[0], true)) url.path.push(base.path[0]);\n else url.host = base.host;\n }\n state = PATH;\n continue;\n\n case FILE_HOST:\n if (char == EOF || char == '/' || char == '\\\\' || char == '?' || char == '#') {\n if (!stateOverride && isWindowsDriveLetter(buffer)) {\n state = PATH;\n } else if (buffer == '') {\n url.host = '';\n if (stateOverride) return;\n state = PATH_START;\n } else {\n failure = parseHost(url, buffer);\n if (failure) return failure;\n if (url.host == 'localhost') url.host = '';\n if (stateOverride) return;\n buffer = '';\n state = PATH_START;\n } continue;\n } else buffer += char;\n break;\n\n case PATH_START:\n if (isSpecial(url)) {\n state = PATH;\n if (char != '/' && char != '\\\\') continue;\n } else if (!stateOverride && char == '?') {\n url.query = '';\n state = QUERY;\n } else if (!stateOverride && char == '#') {\n url.fragment = '';\n state = FRAGMENT;\n } else if (char != EOF) {\n state = PATH;\n if (char != '/') continue;\n } break;\n\n case PATH:\n if (\n char == EOF || char == '/' ||\n (char == '\\\\' && isSpecial(url)) ||\n (!stateOverride && (char == '?' || char == '#'))\n ) {\n if (isDoubleDot(buffer)) {\n shortenURLsPath(url);\n if (char != '/' && !(char == '\\\\' && isSpecial(url))) {\n url.path.push('');\n }\n } else if (isSingleDot(buffer)) {\n if (char != '/' && !(char == '\\\\' && isSpecial(url))) {\n url.path.push('');\n }\n } else {\n if (url.scheme == 'file' && !url.path.length && isWindowsDriveLetter(buffer)) {\n if (url.host) url.host = '';\n buffer = buffer.charAt(0) + ':'; // normalize windows drive letter\n }\n url.path.push(buffer);\n }\n buffer = '';\n if (url.scheme == 'file' && (char == EOF || char == '?' || char == '#')) {\n while (url.path.length > 1 && url.path[0] === '') {\n url.path.shift();\n }\n }\n if (char == '?') {\n url.query = '';\n state = QUERY;\n } else if (char == '#') {\n url.fragment = '';\n state = FRAGMENT;\n }\n } else {\n buffer += percentEncode(char, pathPercentEncodeSet);\n } break;\n\n case CANNOT_BE_A_BASE_URL_PATH:\n if (char == '?') {\n url.query = '';\n state = QUERY;\n } else if (char == '#') {\n url.fragment = '';\n state = FRAGMENT;\n } else if (char != EOF) {\n url.path[0] += percentEncode(char, C0ControlPercentEncodeSet);\n } break;\n\n case QUERY:\n if (!stateOverride && char == '#') {\n url.fragment = '';\n state = FRAGMENT;\n } else if (char != EOF) {\n if (char == \"'\" && isSpecial(url)) url.query += '%27';\n else if (char == '#') url.query += '%23';\n else url.query += percentEncode(char, C0ControlPercentEncodeSet);\n } break;\n\n case FRAGMENT:\n if (char != EOF) url.fragment += percentEncode(char, fragmentPercentEncodeSet);\n break;\n }\n\n pointer++;\n }\n};\n\n// `URL` constructor\n// https://url.spec.whatwg.org/#url-class\nvar URLConstructor = function URL(url /* , base */) {\n var that = anInstance(this, URLConstructor, 'URL');\n var base = arguments.length > 1 ? arguments[1] : undefined;\n var urlString = String(url);\n var state = setInternalState(that, { type: 'URL' });\n var baseState, failure;\n if (base !== undefined) {\n if (base instanceof URLConstructor) baseState = getInternalURLState(base);\n else {\n failure = parseURL(baseState = {}, String(base));\n if (failure) throw TypeError(failure);\n }\n }\n failure = parseURL(state, urlString, null, baseState);\n if (failure) throw TypeError(failure);\n var searchParams = state.searchParams = new URLSearchParams();\n var searchParamsState = getInternalSearchParamsState(searchParams);\n searchParamsState.updateSearchParams(state.query);\n searchParamsState.updateURL = function () {\n state.query = String(searchParams) || null;\n };\n if (!DESCRIPTORS) {\n that.href = serializeURL.call(that);\n that.origin = getOrigin.call(that);\n that.protocol = getProtocol.call(that);\n that.username = getUsername.call(that);\n that.password = getPassword.call(that);\n that.host = getHost.call(that);\n that.hostname = getHostname.call(that);\n that.port = getPort.call(that);\n that.pathname = getPathname.call(that);\n that.search = getSearch.call(that);\n that.searchParams = getSearchParams.call(that);\n that.hash = getHash.call(that);\n }\n};\n\nvar URLPrototype = URLConstructor.prototype;\n\nvar serializeURL = function () {\n var url = getInternalURLState(this);\n var scheme = url.scheme;\n var username = url.username;\n var password = url.password;\n var host = url.host;\n var port = url.port;\n var path = url.path;\n var query = url.query;\n var fragment = url.fragment;\n var output = scheme + ':';\n if (host !== null) {\n output += '//';\n if (includesCredentials(url)) {\n output += username + (password ? ':' + password : '') + '@';\n }\n output += serializeHost(host);\n if (port !== null) output += ':' + port;\n } else if (scheme == 'file') output += '//';\n output += url.cannotBeABaseURL ? path[0] : path.length ? '/' + path.join('/') : '';\n if (query !== null) output += '?' + query;\n if (fragment !== null) output += '#' + fragment;\n return output;\n};\n\nvar getOrigin = function () {\n var url = getInternalURLState(this);\n var scheme = url.scheme;\n var port = url.port;\n if (scheme == 'blob') try {\n return new URL(scheme.path[0]).origin;\n } catch (error) {\n return 'null';\n }\n if (scheme == 'file' || !isSpecial(url)) return 'null';\n return scheme + '://' + serializeHost(url.host) + (port !== null ? ':' + port : '');\n};\n\nvar getProtocol = function () {\n return getInternalURLState(this).scheme + ':';\n};\n\nvar getUsername = function () {\n return getInternalURLState(this).username;\n};\n\nvar getPassword = function () {\n return getInternalURLState(this).password;\n};\n\nvar getHost = function () {\n var url = getInternalURLState(this);\n var host = url.host;\n var port = url.port;\n return host === null ? ''\n : port === null ? serializeHost(host)\n : serializeHost(host) + ':' + port;\n};\n\nvar getHostname = function () {\n var host = getInternalURLState(this).host;\n return host === null ? '' : serializeHost(host);\n};\n\nvar getPort = function () {\n var port = getInternalURLState(this).port;\n return port === null ? '' : String(port);\n};\n\nvar getPathname = function () {\n var url = getInternalURLState(this);\n var path = url.path;\n return url.cannotBeABaseURL ? path[0] : path.length ? '/' + path.join('/') : '';\n};\n\nvar getSearch = function () {\n var query = getInternalURLState(this).query;\n return query ? '?' + query : '';\n};\n\nvar getSearchParams = function () {\n return getInternalURLState(this).searchParams;\n};\n\nvar getHash = function () {\n var fragment = getInternalURLState(this).fragment;\n return fragment ? '#' + fragment : '';\n};\n\nvar accessorDescriptor = function (getter, setter) {\n return { get: getter, set: setter, configurable: true, enumerable: true };\n};\n\nif (DESCRIPTORS) {\n defineProperties(URLPrototype, {\n // `URL.prototype.href` accessors pair\n // https://url.spec.whatwg.org/#dom-url-href\n href: accessorDescriptor(serializeURL, function (href) {\n var url = getInternalURLState(this);\n var urlString = String(href);\n var failure = parseURL(url, urlString);\n if (failure) throw TypeError(failure);\n getInternalSearchParamsState(url.searchParams).updateSearchParams(url.query);\n }),\n // `URL.prototype.origin` getter\n // https://url.spec.whatwg.org/#dom-url-origin\n origin: accessorDescriptor(getOrigin),\n // `URL.prototype.protocol` accessors pair\n // https://url.spec.whatwg.org/#dom-url-protocol\n protocol: accessorDescriptor(getProtocol, function (protocol) {\n var url = getInternalURLState(this);\n parseURL(url, String(protocol) + ':', SCHEME_START);\n }),\n // `URL.prototype.username` accessors pair\n // https://url.spec.whatwg.org/#dom-url-username\n username: accessorDescriptor(getUsername, function (username) {\n var url = getInternalURLState(this);\n var codePoints = arrayFrom(String(username));\n if (cannotHaveUsernamePasswordPort(url)) return;\n url.username = '';\n for (var i = 0; i < codePoints.length; i++) {\n url.username += percentEncode(codePoints[i], userinfoPercentEncodeSet);\n }\n }),\n // `URL.prototype.password` accessors pair\n // https://url.spec.whatwg.org/#dom-url-password\n password: accessorDescriptor(getPassword, function (password) {\n var url = getInternalURLState(this);\n var codePoints = arrayFrom(String(password));\n if (cannotHaveUsernamePasswordPort(url)) return;\n url.password = '';\n for (var i = 0; i < codePoints.length; i++) {\n url.password += percentEncode(codePoints[i], userinfoPercentEncodeSet);\n }\n }),\n // `URL.prototype.host` accessors pair\n // https://url.spec.whatwg.org/#dom-url-host\n host: accessorDescriptor(getHost, function (host) {\n var url = getInternalURLState(this);\n if (url.cannotBeABaseURL) return;\n parseURL(url, String(host), HOST);\n }),\n // `URL.prototype.hostname` accessors pair\n // https://url.spec.whatwg.org/#dom-url-hostname\n hostname: accessorDescriptor(getHostname, function (hostname) {\n var url = getInternalURLState(this);\n if (url.cannotBeABaseURL) return;\n parseURL(url, String(hostname), HOSTNAME);\n }),\n // `URL.prototype.port` accessors pair\n // https://url.spec.whatwg.org/#dom-url-port\n port: accessorDescriptor(getPort, function (port) {\n var url = getInternalURLState(this);\n if (cannotHaveUsernamePasswordPort(url)) return;\n port = String(port);\n if (port == '') url.port = null;\n else parseURL(url, port, PORT);\n }),\n // `URL.prototype.pathname` accessors pair\n // https://url.spec.whatwg.org/#dom-url-pathname\n pathname: accessorDescriptor(getPathname, function (pathname) {\n var url = getInternalURLState(this);\n if (url.cannotBeABaseURL) return;\n url.path = [];\n parseURL(url, pathname + '', PATH_START);\n }),\n // `URL.prototype.search` accessors pair\n // https://url.spec.whatwg.org/#dom-url-search\n search: accessorDescriptor(getSearch, function (search) {\n var url = getInternalURLState(this);\n search = String(search);\n if (search == '') {\n url.query = null;\n } else {\n if ('?' == search.charAt(0)) search = search.slice(1);\n url.query = '';\n parseURL(url, search, QUERY);\n }\n getInternalSearchParamsState(url.searchParams).updateSearchParams(url.query);\n }),\n // `URL.prototype.searchParams` getter\n // https://url.spec.whatwg.org/#dom-url-searchparams\n searchParams: accessorDescriptor(getSearchParams),\n // `URL.prototype.hash` accessors pair\n // https://url.spec.whatwg.org/#dom-url-hash\n hash: accessorDescriptor(getHash, function (hash) {\n var url = getInternalURLState(this);\n hash = String(hash);\n if (hash == '') {\n url.fragment = null;\n return;\n }\n if ('#' == hash.charAt(0)) hash = hash.slice(1);\n url.fragment = '';\n parseURL(url, hash, FRAGMENT);\n })\n });\n}\n\n// `URL.prototype.toJSON` method\n// https://url.spec.whatwg.org/#dom-url-tojson\nredefine(URLPrototype, 'toJSON', function toJSON() {\n return serializeURL.call(this);\n}, { enumerable: true });\n\n// `URL.prototype.toString` method\n// https://url.spec.whatwg.org/#URL-stringification-behavior\nredefine(URLPrototype, 'toString', function toString() {\n return serializeURL.call(this);\n}, { enumerable: true });\n\nif (NativeURL) {\n var nativeCreateObjectURL = NativeURL.createObjectURL;\n var nativeRevokeObjectURL = NativeURL.revokeObjectURL;\n // `URL.createObjectURL` method\n // https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL\n // eslint-disable-next-line no-unused-vars\n if (nativeCreateObjectURL) redefine(URLConstructor, 'createObjectURL', function createObjectURL(blob) {\n return nativeCreateObjectURL.apply(NativeURL, arguments);\n });\n // `URL.revokeObjectURL` method\n // https://developer.mozilla.org/en-US/docs/Web/API/URL/revokeObjectURL\n // eslint-disable-next-line no-unused-vars\n if (nativeRevokeObjectURL) redefine(URLConstructor, 'revokeObjectURL', function revokeObjectURL(url) {\n return nativeRevokeObjectURL.apply(NativeURL, arguments);\n });\n}\n\nsetToStringTag(URLConstructor, 'URL');\n\n$({ global: true, forced: !USE_NATIVE_URL, sham: !DESCRIPTORS }, {\n URL: URLConstructor\n});\n","'use strict';\nvar $ = require('../internals/export');\n\n// `URL.prototype.toJSON` method\n// https://url.spec.whatwg.org/#dom-url-tojson\n$({ target: 'URL', proto: true, enumerable: true }, {\n toJSON: function toJSON() {\n return URL.prototype.toString.call(this);\n }\n});\n","// Top level file is just a mixin of submodules & constants\n'use strict';\n\nvar assign = require('./lib/utils/common').assign;\n\nvar deflate = require('./lib/deflate');\nvar inflate = require('./lib/inflate');\nvar constants = require('./lib/zlib/constants');\n\nvar pako = {};\n\nassign(pako, deflate, inflate, constants);\n\nmodule.exports = pako;\n","'use strict';\n\n\nvar zlib_deflate = require('./zlib/deflate');\nvar utils = require('./utils/common');\nvar strings = require('./utils/strings');\nvar msg = require('./zlib/messages');\nvar ZStream = require('./zlib/zstream');\n\nvar toString = Object.prototype.toString;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\nvar Z_NO_FLUSH = 0;\nvar Z_FINISH = 4;\n\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_SYNC_FLUSH = 2;\n\nvar Z_DEFAULT_COMPRESSION = -1;\n\nvar Z_DEFAULT_STRATEGY = 0;\n\nvar Z_DEFLATED = 8;\n\n/* ===========================================================================*/\n\n\n/**\n * class Deflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[deflate]],\n * [[deflateRaw]] and [[gzip]].\n **/\n\n/* internal\n * Deflate.chunks -> Array\n *\n * Chunks of output data, if [[Deflate#onData]] not overridden.\n **/\n\n/**\n * Deflate.result -> Uint8Array|Array\n *\n * Compressed result, generated by default [[Deflate#onData]]\n * and [[Deflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Deflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Deflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Deflate.err -> Number\n *\n * Error code after deflate finished. 0 (Z_OK) on success.\n * You will not need it in real life, because deflate errors\n * are possible only on wrong options or bad `onData` / `onEnd`\n * custom handlers.\n **/\n\n/**\n * Deflate.msg -> String\n *\n * Error message, if [[Deflate.err]] != 0\n **/\n\n\n/**\n * new Deflate(options)\n * - options (Object): zlib deflate options.\n *\n * Creates new deflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `level`\n * - `windowBits`\n * - `memLevel`\n * - `strategy`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw deflate\n * - `gzip` (Boolean) - create gzip wrapper\n * - `to` (String) - if equal to 'string', then result will be \"binary string\"\n * (each char code [0..255])\n * - `header` (Object) - custom header for gzip\n * - `text` (Boolean) - true if compressed data believed to be text\n * - `time` (Number) - modification time, unix timestamp\n * - `os` (Number) - operation system code\n * - `extra` (Array) - array of bytes with extra data (max 65536)\n * - `name` (String) - file name (binary string)\n * - `comment` (String) - comment (binary string)\n * - `hcrc` (Boolean) - true if header crc should be added\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var deflate = new pako.Deflate({ level: 3});\n *\n * deflate.push(chunk1, false);\n * deflate.push(chunk2, true); // true -> last chunk\n *\n * if (deflate.err) { throw new Error(deflate.err); }\n *\n * console.log(deflate.result);\n * ```\n **/\nfunction Deflate(options) {\n if (!(this instanceof Deflate)) return new Deflate(options);\n\n this.options = utils.assign({\n level: Z_DEFAULT_COMPRESSION,\n method: Z_DEFLATED,\n chunkSize: 16384,\n windowBits: 15,\n memLevel: 8,\n strategy: Z_DEFAULT_STRATEGY,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n if (opt.raw && (opt.windowBits > 0)) {\n opt.windowBits = -opt.windowBits;\n }\n\n else if (opt.gzip && (opt.windowBits > 0) && (opt.windowBits < 16)) {\n opt.windowBits += 16;\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = zlib_deflate.deflateInit2(\n this.strm,\n opt.level,\n opt.method,\n opt.windowBits,\n opt.memLevel,\n opt.strategy\n );\n\n if (status !== Z_OK) {\n throw new Error(msg[status]);\n }\n\n if (opt.header) {\n zlib_deflate.deflateSetHeader(this.strm, opt.header);\n }\n\n if (opt.dictionary) {\n var dict;\n // Convert data if needed\n if (typeof opt.dictionary === 'string') {\n // If we need to compress text, change encoding to utf8.\n dict = strings.string2buf(opt.dictionary);\n } else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {\n dict = new Uint8Array(opt.dictionary);\n } else {\n dict = opt.dictionary;\n }\n\n status = zlib_deflate.deflateSetDictionary(this.strm, dict);\n\n if (status !== Z_OK) {\n throw new Error(msg[status]);\n }\n\n this._dict_set = true;\n }\n}\n\n/**\n * Deflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data. Strings will be\n * converted to utf8 byte sequence.\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` means Z_FINISH.\n *\n * Sends input data to deflate pipe, generating [[Deflate#onData]] calls with\n * new compressed chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Deflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the compression context.\n *\n * On fail call [[Deflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * array format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nDeflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var status, _mode;\n\n if (this.ended) { return false; }\n\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? Z_FINISH : Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // If we need to compress text, change encoding to utf8.\n strm.input = strings.string2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new utils.Buf8(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n status = zlib_deflate.deflate(strm, _mode); /* no bad return value */\n\n if (status !== Z_STREAM_END && status !== Z_OK) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n if (strm.avail_out === 0 || (strm.avail_in === 0 && (_mode === Z_FINISH || _mode === Z_SYNC_FLUSH))) {\n if (this.options.to === 'string') {\n this.onData(strings.buf2binstring(utils.shrinkBuf(strm.output, strm.next_out)));\n } else {\n this.onData(utils.shrinkBuf(strm.output, strm.next_out));\n }\n }\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END);\n\n // Finalize on the last chunk.\n if (_mode === Z_FINISH) {\n status = zlib_deflate.deflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === Z_OK;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === Z_SYNC_FLUSH) {\n this.onEnd(Z_OK);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Deflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): output data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nDeflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Deflate#onEnd(status) -> Void\n * - status (Number): deflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called once after you tell deflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nDeflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === Z_OK) {\n if (this.options.to === 'string') {\n this.result = this.chunks.join('');\n } else {\n this.result = utils.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * deflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * Compress `data` with deflate algorithm and `options`.\n *\n * Supported options are:\n *\n * - level\n * - windowBits\n * - memLevel\n * - strategy\n * - dictionary\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be \"binary string\"\n * (each char code [0..255])\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , data = Uint8Array([1,2,3,4,5,6,7,8,9]);\n *\n * console.log(pako.deflate(data));\n * ```\n **/\nfunction deflate(input, options) {\n var deflator = new Deflate(options);\n\n deflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (deflator.err) { throw deflator.msg || msg[deflator.err]; }\n\n return deflator.result;\n}\n\n\n/**\n * deflateRaw(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * The same as [[deflate]], but creates raw data, without wrapper\n * (header and adler32 crc).\n **/\nfunction deflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return deflate(input, options);\n}\n\n\n/**\n * gzip(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * The same as [[deflate]], but create gzip wrapper instead of\n * deflate one.\n **/\nfunction gzip(input, options) {\n options = options || {};\n options.gzip = true;\n return deflate(input, options);\n}\n\n\nexports.Deflate = Deflate;\nexports.deflate = deflate;\nexports.deflateRaw = deflateRaw;\nexports.gzip = gzip;\n","'use strict';\n\n\nvar zlib_inflate = require('./zlib/inflate');\nvar utils = require('./utils/common');\nvar strings = require('./utils/strings');\nvar c = require('./zlib/constants');\nvar msg = require('./zlib/messages');\nvar ZStream = require('./zlib/zstream');\nvar GZheader = require('./zlib/gzheader');\n\nvar toString = Object.prototype.toString;\n\n/**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n/* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overridden.\n **/\n\n/**\n * Inflate.result -> Uint8Array|Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Inflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n/**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n\n/**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true); // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\nfunction Inflate(options) {\n if (!(this instanceof Inflate)) return new Inflate(options);\n\n this.options = utils.assign({\n chunkSize: 16384,\n windowBits: 0,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n // Force window size for `raw` data, if not set directly,\n // because we have no header for autodetect.\n if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) { opt.windowBits = -15; }\n }\n\n // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n\n // Gzip header has no info about windows size, we can do autodetect only\n // for deflate. So, if window size not set, force it to max when gzip possible\n if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n // bit 3 (16) -> gzipped data\n // bit 4 (32) -> autodetect gzip/deflate\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = zlib_inflate.inflateInit2(\n this.strm,\n opt.windowBits\n );\n\n if (status !== c.Z_OK) {\n throw new Error(msg[status]);\n }\n\n this.header = new GZheader();\n\n zlib_inflate.inflateGetHeader(this.strm, this.header);\n\n // Setup dictionary\n if (opt.dictionary) {\n // Convert data if needed\n if (typeof opt.dictionary === 'string') {\n opt.dictionary = strings.string2buf(opt.dictionary);\n } else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {\n opt.dictionary = new Uint8Array(opt.dictionary);\n }\n if (opt.raw) { //In raw mode we need to set the dictionary early\n status = zlib_inflate.inflateSetDictionary(this.strm, opt.dictionary);\n if (status !== c.Z_OK) {\n throw new Error(msg[status]);\n }\n }\n }\n}\n\n/**\n * Inflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` means Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the decompression context.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nInflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var dictionary = this.options.dictionary;\n var status, _mode;\n var next_out_utf8, tail, utf8str;\n\n // Flag to properly process Z_BUF_ERROR on testing inflate call\n // when we check that all output data was flushed.\n var allowBufError = false;\n\n if (this.ended) { return false; }\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? c.Z_FINISH : c.Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // Only binary strings can be decompressed on practice\n strm.input = strings.binstring2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new utils.Buf8(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n\n status = zlib_inflate.inflate(strm, c.Z_NO_FLUSH); /* no bad return value */\n\n if (status === c.Z_NEED_DICT && dictionary) {\n status = zlib_inflate.inflateSetDictionary(this.strm, dictionary);\n }\n\n if (status === c.Z_BUF_ERROR && allowBufError === true) {\n status = c.Z_OK;\n allowBufError = false;\n }\n\n if (status !== c.Z_STREAM_END && status !== c.Z_OK) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === c.Z_STREAM_END || (strm.avail_in === 0 && (_mode === c.Z_FINISH || _mode === c.Z_SYNC_FLUSH))) {\n\n if (this.options.to === 'string') {\n\n next_out_utf8 = strings.utf8border(strm.output, strm.next_out);\n\n tail = strm.next_out - next_out_utf8;\n utf8str = strings.buf2string(strm.output, next_out_utf8);\n\n // move tail\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) { utils.arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }\n\n this.onData(utf8str);\n\n } else {\n this.onData(utils.shrinkBuf(strm.output, strm.next_out));\n }\n }\n }\n\n // When no more input data, we should check that internal inflate buffers\n // are flushed. The only way to do it when avail_out = 0 - run one more\n // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.\n // Here we set flag to process this error properly.\n //\n // NOTE. Deflate does not return error in this case and does not needs such\n // logic.\n if (strm.avail_in === 0 && strm.avail_out === 0) {\n allowBufError = true;\n }\n\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c.Z_STREAM_END);\n\n if (status === c.Z_STREAM_END) {\n _mode = c.Z_FINISH;\n }\n\n // Finalize on the last chunk.\n if (_mode === c.Z_FINISH) {\n status = zlib_inflate.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === c.Z_OK;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === c.Z_SYNC_FLUSH) {\n this.onEnd(c.Z_OK);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): output data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nInflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nInflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === c.Z_OK) {\n if (this.options.to === 'string') {\n // Glue & convert here, until we teach pako to send\n // utf8 aligned strings to onData\n this.result = this.chunks.join('');\n } else {\n this.result = utils.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * inflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , input = pako.deflate([1,2,3,4,5,6,7,8,9])\n * , output;\n *\n * try {\n * output = pako.inflate(input);\n * } catch (err)\n * console.log(err);\n * }\n * ```\n **/\nfunction inflate(input, options) {\n var inflator = new Inflate(options);\n\n inflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (inflator.err) { throw inflator.msg || msg[inflator.err]; }\n\n return inflator.result;\n}\n\n\n/**\n * inflateRaw(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * The same as [[inflate]], but creates raw data, without wrapper\n * (header and adler32 crc).\n **/\nfunction inflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return inflate(input, options);\n}\n\n\n/**\n * ungzip(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Just shortcut to [[inflate]], because it autodetects format\n * by header.content. Done for convenience.\n **/\n\n\nexports.Inflate = Inflate;\nexports.inflate = inflate;\nexports.inflateRaw = inflateRaw;\nexports.ungzip = inflate;\n","'use strict';\n\n\nvar TYPED_OK = (typeof Uint8Array !== 'undefined') &&\n (typeof Uint16Array !== 'undefined') &&\n (typeof Int32Array !== 'undefined');\n\nfunction _has(obj, key) {\n return Object.prototype.hasOwnProperty.call(obj, key);\n}\n\nexports.assign = function (obj /*from1, from2, from3, ...*/) {\n var sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n var source = sources.shift();\n if (!source) { continue; }\n\n if (typeof source !== 'object') {\n throw new TypeError(source + 'must be non-object');\n }\n\n for (var p in source) {\n if (_has(source, p)) {\n obj[p] = source[p];\n }\n }\n }\n\n return obj;\n};\n\n\n// reduce buffer size, avoiding mem copy\nexports.shrinkBuf = function (buf, size) {\n if (buf.length === size) { return buf; }\n if (buf.subarray) { return buf.subarray(0, size); }\n buf.length = size;\n return buf;\n};\n\n\nvar fnTyped = {\n arraySet: function (dest, src, src_offs, len, dest_offs) {\n if (src.subarray && dest.subarray) {\n dest.set(src.subarray(src_offs, src_offs + len), dest_offs);\n return;\n }\n // Fallback to ordinary array\n for (var i = 0; i < len; i++) {\n dest[dest_offs + i] = src[src_offs + i];\n }\n },\n // Join array of chunks to single array.\n flattenChunks: function (chunks) {\n var i, l, len, pos, chunk, result;\n\n // calculate data length\n len = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n\n // join chunks\n result = new Uint8Array(len);\n pos = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n\n return result;\n }\n};\n\nvar fnUntyped = {\n arraySet: function (dest, src, src_offs, len, dest_offs) {\n for (var i = 0; i < len; i++) {\n dest[dest_offs + i] = src[src_offs + i];\n }\n },\n // Join array of chunks to single array.\n flattenChunks: function (chunks) {\n return [].concat.apply([], chunks);\n }\n};\n\n\n// Enable/Disable typed arrays use, for testing\n//\nexports.setTyped = function (on) {\n if (on) {\n exports.Buf8 = Uint8Array;\n exports.Buf16 = Uint16Array;\n exports.Buf32 = Int32Array;\n exports.assign(exports, fnTyped);\n } else {\n exports.Buf8 = Array;\n exports.Buf16 = Array;\n exports.Buf32 = Array;\n exports.assign(exports, fnUntyped);\n }\n};\n\nexports.setTyped(TYPED_OK);\n","// String encode/decode helpers\n'use strict';\n\n\nvar utils = require('./common');\n\n\n// Quick check if we can use fast array to bin string conversion\n//\n// - apply(Array) can fail on Android 2.2\n// - apply(Uint8Array) can fail on iOS 5.1 Safari\n//\nvar STR_APPLY_OK = true;\nvar STR_APPLY_UIA_OK = true;\n\ntry { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }\ntry { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n// Table with utf8 lengths (calculated by first byte of sequence)\n// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n// because max possible codepoint is 0x10ffff\nvar _utf8len = new utils.Buf8(256);\nfor (var q = 0; q < 256; q++) {\n _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n}\n_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n// convert string to array (typed, when possible)\nexports.string2buf = function (str) {\n var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n }\n\n // allocate buffer\n buf = new utils.Buf8(buf_len);\n\n // convert\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c;\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xC0 | (c >>> 6);\n buf[i++] = 0x80 | (c & 0x3f);\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xE0 | (c >>> 12);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18);\n buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n }\n }\n\n return buf;\n};\n\n// Helper (used in 2 places)\nfunction buf2binstring(buf, len) {\n // On Chrome, the arguments in a function call that are allowed is `65534`.\n // If the length of the buffer is smaller than that, we can use this optimization,\n // otherwise we will take a slower path.\n if (len < 65534) {\n if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) {\n return String.fromCharCode.apply(null, utils.shrinkBuf(buf, len));\n }\n }\n\n var result = '';\n for (var i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n}\n\n\n// Convert byte array to binary string\nexports.buf2binstring = function (buf) {\n return buf2binstring(buf, buf.length);\n};\n\n\n// Convert binary string (typed, when possible)\nexports.binstring2buf = function (str) {\n var buf = new utils.Buf8(str.length);\n for (var i = 0, len = buf.length; i < len; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n};\n\n\n// convert array to string\nexports.buf2string = function (buf, max) {\n var i, out, c, c_len;\n var len = max || buf.length;\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n var utf16buf = new Array(len * 2);\n\n for (out = 0, i = 0; i < len;) {\n c = buf[i++];\n // quick process ascii\n if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n c_len = _utf8len[c];\n // skip 5 & 6 byte codes\n if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f);\n c_len--;\n }\n\n // terminated by end of string?\n if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n if (c < 0x10000) {\n utf16buf[out++] = c;\n } else {\n c -= 0x10000;\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n }\n }\n\n return buf2binstring(utf16buf, out);\n};\n\n\n// Calculate max possible position in utf8 buffer,\n// that will not break sequence. If that's not possible\n// - (very small limits) return max size as is.\n//\n// buf[] - utf8 bytes array\n// max - length limit (mandatory);\nexports.utf8border = function (buf, max) {\n var pos;\n\n max = max || buf.length;\n if (max > buf.length) { max = buf.length; }\n\n // go back from last position, until start of sequence found\n pos = max - 1;\n while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n // Very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) { return max; }\n\n // If we came to start of buffer - that means buffer is too small,\n // return max too.\n if (pos === 0) { return max; }\n\n return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n};\n","'use strict';\n\n// Note: adler32 takes 12% for level 0 and 2% for level 6.\n// It isn't worth it to make additional optimizations as in original.\n// Small size is preferable.\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nfunction adler32(adler, buf, len, pos) {\n var s1 = (adler & 0xffff) |0,\n s2 = ((adler >>> 16) & 0xffff) |0,\n n = 0;\n\n while (len !== 0) {\n // Set limit ~ twice less than 5552, to keep\n // s2 in 31-bits, because we force signed ints.\n // in other case %= will fail.\n n = len > 2000 ? 2000 : len;\n len -= n;\n\n do {\n s1 = (s1 + buf[pos++]) |0;\n s2 = (s2 + s1) |0;\n } while (--n);\n\n s1 %= 65521;\n s2 %= 65521;\n }\n\n return (s1 | (s2 << 16)) |0;\n}\n\n\nmodule.exports = adler32;\n","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nmodule.exports = {\n\n /* Allowed flush values; see deflate() and inflate() below for details */\n Z_NO_FLUSH: 0,\n Z_PARTIAL_FLUSH: 1,\n Z_SYNC_FLUSH: 2,\n Z_FULL_FLUSH: 3,\n Z_FINISH: 4,\n Z_BLOCK: 5,\n Z_TREES: 6,\n\n /* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n Z_OK: 0,\n Z_STREAM_END: 1,\n Z_NEED_DICT: 2,\n Z_ERRNO: -1,\n Z_STREAM_ERROR: -2,\n Z_DATA_ERROR: -3,\n //Z_MEM_ERROR: -4,\n Z_BUF_ERROR: -5,\n //Z_VERSION_ERROR: -6,\n\n /* compression levels */\n Z_NO_COMPRESSION: 0,\n Z_BEST_SPEED: 1,\n Z_BEST_COMPRESSION: 9,\n Z_DEFAULT_COMPRESSION: -1,\n\n\n Z_FILTERED: 1,\n Z_HUFFMAN_ONLY: 2,\n Z_RLE: 3,\n Z_FIXED: 4,\n Z_DEFAULT_STRATEGY: 0,\n\n /* Possible values of the data_type field (though see inflate()) */\n Z_BINARY: 0,\n Z_TEXT: 1,\n //Z_ASCII: 1, // = Z_TEXT (deprecated)\n Z_UNKNOWN: 2,\n\n /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n};\n","'use strict';\n\n// Note: we can't get significant speed boost here.\n// So write code to minimize size - no pregenerated tables\n// and array tools dependencies.\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\n// Use ordinary array, since untyped makes no boost here\nfunction makeTable() {\n var c, table = [];\n\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n }\n table[n] = c;\n }\n\n return table;\n}\n\n// Create table on load. Just 255 signed longs. Not a problem.\nvar crcTable = makeTable();\n\n\nfunction crc32(crc, buf, len, pos) {\n var t = crcTable,\n end = pos + len;\n\n crc ^= -1;\n\n for (var i = pos; i < end; i++) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n}\n\n\nmodule.exports = crc32;\n","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar utils = require('../utils/common');\nvar trees = require('./trees');\nvar adler32 = require('./adler32');\nvar crc32 = require('./crc32');\nvar msg = require('./messages');\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\nvar Z_NO_FLUSH = 0;\nvar Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\nvar Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\n//var Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\n//var Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\n//var Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n\n/* compression levels */\n//var Z_NO_COMPRESSION = 0;\n//var Z_BEST_SPEED = 1;\n//var Z_BEST_COMPRESSION = 9;\nvar Z_DEFAULT_COMPRESSION = -1;\n\n\nvar Z_FILTERED = 1;\nvar Z_HUFFMAN_ONLY = 2;\nvar Z_RLE = 3;\nvar Z_FIXED = 4;\nvar Z_DEFAULT_STRATEGY = 0;\n\n/* Possible values of the data_type field (though see inflate()) */\n//var Z_BINARY = 0;\n//var Z_TEXT = 1;\n//var Z_ASCII = 1; // = Z_TEXT\nvar Z_UNKNOWN = 2;\n\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n/*============================================================================*/\n\n\nvar MAX_MEM_LEVEL = 9;\n/* Maximum value for memLevel in deflateInit2 */\nvar MAX_WBITS = 15;\n/* 32K LZ77 window */\nvar DEF_MEM_LEVEL = 8;\n\n\nvar LENGTH_CODES = 29;\n/* number of length codes, not counting the special END_BLOCK code */\nvar LITERALS = 256;\n/* number of literal bytes 0..255 */\nvar L_CODES = LITERALS + 1 + LENGTH_CODES;\n/* number of Literal or Length codes, including the END_BLOCK code */\nvar D_CODES = 30;\n/* number of distance codes */\nvar BL_CODES = 19;\n/* number of codes used to transfer the bit lengths */\nvar HEAP_SIZE = 2 * L_CODES + 1;\n/* maximum heap size */\nvar MAX_BITS = 15;\n/* All codes must not exceed MAX_BITS bits */\n\nvar MIN_MATCH = 3;\nvar MAX_MATCH = 258;\nvar MIN_LOOKAHEAD = (MAX_MATCH + MIN_MATCH + 1);\n\nvar PRESET_DICT = 0x20;\n\nvar INIT_STATE = 42;\nvar EXTRA_STATE = 69;\nvar NAME_STATE = 73;\nvar COMMENT_STATE = 91;\nvar HCRC_STATE = 103;\nvar BUSY_STATE = 113;\nvar FINISH_STATE = 666;\n\nvar BS_NEED_MORE = 1; /* block not completed, need more input or more output */\nvar BS_BLOCK_DONE = 2; /* block flush performed */\nvar BS_FINISH_STARTED = 3; /* finish started, need only more output at next deflate */\nvar BS_FINISH_DONE = 4; /* finish done, accept no more input or output */\n\nvar OS_CODE = 0x03; // Unix :) . Don't detect, use this default.\n\nfunction err(strm, errorCode) {\n strm.msg = msg[errorCode];\n return errorCode;\n}\n\nfunction rank(f) {\n return ((f) << 1) - ((f) > 4 ? 9 : 0);\n}\n\nfunction zero(buf) { var len = buf.length; while (--len >= 0) { buf[len] = 0; } }\n\n\n/* =========================================================================\n * Flush as much pending output as possible. All deflate() output goes\n * through this function so some applications may wish to modify it\n * to avoid allocating a large strm->output buffer and copying into it.\n * (See also read_buf()).\n */\nfunction flush_pending(strm) {\n var s = strm.state;\n\n //_tr_flush_bits(s);\n var len = s.pending;\n if (len > strm.avail_out) {\n len = strm.avail_out;\n }\n if (len === 0) { return; }\n\n utils.arraySet(strm.output, s.pending_buf, s.pending_out, len, strm.next_out);\n strm.next_out += len;\n s.pending_out += len;\n strm.total_out += len;\n strm.avail_out -= len;\n s.pending -= len;\n if (s.pending === 0) {\n s.pending_out = 0;\n }\n}\n\n\nfunction flush_block_only(s, last) {\n trees._tr_flush_block(s, (s.block_start >= 0 ? s.block_start : -1), s.strstart - s.block_start, last);\n s.block_start = s.strstart;\n flush_pending(s.strm);\n}\n\n\nfunction put_byte(s, b) {\n s.pending_buf[s.pending++] = b;\n}\n\n\n/* =========================================================================\n * Put a short in the pending buffer. The 16-bit value is put in MSB order.\n * IN assertion: the stream state is correct and there is enough room in\n * pending_buf.\n */\nfunction putShortMSB(s, b) {\n// put_byte(s, (Byte)(b >> 8));\n// put_byte(s, (Byte)(b & 0xff));\n s.pending_buf[s.pending++] = (b >>> 8) & 0xff;\n s.pending_buf[s.pending++] = b & 0xff;\n}\n\n\n/* ===========================================================================\n * Read a new buffer from the current input stream, update the adler32\n * and total number of bytes read. All deflate() input goes through\n * this function so some applications may wish to modify it to avoid\n * allocating a large strm->input buffer and copying from it.\n * (See also flush_pending()).\n */\nfunction read_buf(strm, buf, start, size) {\n var len = strm.avail_in;\n\n if (len > size) { len = size; }\n if (len === 0) { return 0; }\n\n strm.avail_in -= len;\n\n // zmemcpy(buf, strm->next_in, len);\n utils.arraySet(buf, strm.input, strm.next_in, len, start);\n if (strm.state.wrap === 1) {\n strm.adler = adler32(strm.adler, buf, len, start);\n }\n\n else if (strm.state.wrap === 2) {\n strm.adler = crc32(strm.adler, buf, len, start);\n }\n\n strm.next_in += len;\n strm.total_in += len;\n\n return len;\n}\n\n\n/* ===========================================================================\n * Set match_start to the longest match starting at the given string and\n * return its length. Matches shorter or equal to prev_length are discarded,\n * in which case the result is equal to prev_length and match_start is\n * garbage.\n * IN assertions: cur_match is the head of the hash chain for the current\n * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1\n * OUT assertion: the match length is not greater than s->lookahead.\n */\nfunction longest_match(s, cur_match) {\n var chain_length = s.max_chain_length; /* max hash chain length */\n var scan = s.strstart; /* current string */\n var match; /* matched string */\n var len; /* length of current match */\n var best_len = s.prev_length; /* best match length so far */\n var nice_match = s.nice_match; /* stop if match long enough */\n var limit = (s.strstart > (s.w_size - MIN_LOOKAHEAD)) ?\n s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0/*NIL*/;\n\n var _win = s.window; // shortcut\n\n var wmask = s.w_mask;\n var prev = s.prev;\n\n /* Stop when cur_match becomes <= limit. To simplify the code,\n * we prevent matches with the string of window index 0.\n */\n\n var strend = s.strstart + MAX_MATCH;\n var scan_end1 = _win[scan + best_len - 1];\n var scan_end = _win[scan + best_len];\n\n /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.\n * It is easy to get rid of this optimization if necessary.\n */\n // Assert(s->hash_bits >= 8 && MAX_MATCH == 258, \"Code too clever\");\n\n /* Do not waste too much time if we already have a good match: */\n if (s.prev_length >= s.good_match) {\n chain_length >>= 2;\n }\n /* Do not look for matches beyond the end of the input. This is necessary\n * to make deflate deterministic.\n */\n if (nice_match > s.lookahead) { nice_match = s.lookahead; }\n\n // Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, \"need lookahead\");\n\n do {\n // Assert(cur_match < s->strstart, \"no future\");\n match = cur_match;\n\n /* Skip to next match if the match length cannot increase\n * or if the match length is less than 2. Note that the checks below\n * for insufficient lookahead only occur occasionally for performance\n * reasons. Therefore uninitialized memory will be accessed, and\n * conditional jumps will be made that depend on those values.\n * However the length of the match is limited to the lookahead, so\n * the output of deflate is not affected by the uninitialized values.\n */\n\n if (_win[match + best_len] !== scan_end ||\n _win[match + best_len - 1] !== scan_end1 ||\n _win[match] !== _win[scan] ||\n _win[++match] !== _win[scan + 1]) {\n continue;\n }\n\n /* The check at best_len-1 can be removed because it will be made\n * again later. (This heuristic is not always a win.)\n * It is not necessary to compare scan[2] and match[2] since they\n * are always equal when the other bytes match, given that\n * the hash keys are equal and that HASH_BITS >= 8.\n */\n scan += 2;\n match++;\n // Assert(*scan == *match, \"match[2]?\");\n\n /* We check for insufficient lookahead only every 8th comparison;\n * the 256th check will be made at strstart+258.\n */\n do {\n /*jshint noempty:false*/\n } while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n scan < strend);\n\n // Assert(scan <= s->window+(unsigned)(s->window_size-1), \"wild scan\");\n\n len = MAX_MATCH - (strend - scan);\n scan = strend - MAX_MATCH;\n\n if (len > best_len) {\n s.match_start = cur_match;\n best_len = len;\n if (len >= nice_match) {\n break;\n }\n scan_end1 = _win[scan + best_len - 1];\n scan_end = _win[scan + best_len];\n }\n } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0);\n\n if (best_len <= s.lookahead) {\n return best_len;\n }\n return s.lookahead;\n}\n\n\n/* ===========================================================================\n * Fill the window when the lookahead becomes insufficient.\n * Updates strstart and lookahead.\n *\n * IN assertion: lookahead < MIN_LOOKAHEAD\n * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD\n * At least one byte has been read, or avail_in == 0; reads are\n * performed for at least two bytes (required for the zip translate_eol\n * option -- not supported here).\n */\nfunction fill_window(s) {\n var _w_size = s.w_size;\n var p, n, m, more, str;\n\n //Assert(s->lookahead < MIN_LOOKAHEAD, \"already enough lookahead\");\n\n do {\n more = s.window_size - s.lookahead - s.strstart;\n\n // JS ints have 32 bit, block below not needed\n /* Deal with !@#$% 64K limit: */\n //if (sizeof(int) <= 2) {\n // if (more == 0 && s->strstart == 0 && s->lookahead == 0) {\n // more = wsize;\n //\n // } else if (more == (unsigned)(-1)) {\n // /* Very unlikely, but possible on 16 bit machine if\n // * strstart == 0 && lookahead == 1 (input done a byte at time)\n // */\n // more--;\n // }\n //}\n\n\n /* If the window is almost full and there is insufficient lookahead,\n * move the upper half to the lower one to make room in the upper half.\n */\n if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {\n\n utils.arraySet(s.window, s.window, _w_size, _w_size, 0);\n s.match_start -= _w_size;\n s.strstart -= _w_size;\n /* we now have strstart >= MAX_DIST */\n s.block_start -= _w_size;\n\n /* Slide the hash table (could be avoided with 32 bit values\n at the expense of memory usage). We slide even when level == 0\n to keep the hash table consistent if we switch back to level > 0\n later. (Using level 0 permanently is not an optimal usage of\n zlib, so we don't care about this pathological case.)\n */\n\n n = s.hash_size;\n p = n;\n do {\n m = s.head[--p];\n s.head[p] = (m >= _w_size ? m - _w_size : 0);\n } while (--n);\n\n n = _w_size;\n p = n;\n do {\n m = s.prev[--p];\n s.prev[p] = (m >= _w_size ? m - _w_size : 0);\n /* If n is not on any hash chain, prev[n] is garbage but\n * its value will never be used.\n */\n } while (--n);\n\n more += _w_size;\n }\n if (s.strm.avail_in === 0) {\n break;\n }\n\n /* If there was no sliding:\n * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&\n * more == window_size - lookahead - strstart\n * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)\n * => more >= window_size - 2*WSIZE + 2\n * In the BIG_MEM or MMAP case (not yet supported),\n * window_size == input_size + MIN_LOOKAHEAD &&\n * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.\n * Otherwise, window_size == 2*WSIZE so more >= 2.\n * If there was sliding, more >= WSIZE. So in all cases, more >= 2.\n */\n //Assert(more >= 2, \"more < 2\");\n n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);\n s.lookahead += n;\n\n /* Initialize the hash value now that we have some input: */\n if (s.lookahead + s.insert >= MIN_MATCH) {\n str = s.strstart - s.insert;\n s.ins_h = s.window[str];\n\n /* UPDATE_HASH(s, s->ins_h, s->window[str + 1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + 1]) & s.hash_mask;\n//#if MIN_MATCH != 3\n// Call update_hash() MIN_MATCH-3 more times\n//#endif\n while (s.insert) {\n /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;\n\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = str;\n str++;\n s.insert--;\n if (s.lookahead + s.insert < MIN_MATCH) {\n break;\n }\n }\n }\n /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,\n * but this is not important since only literal bytes will be emitted.\n */\n\n } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0);\n\n /* If the WIN_INIT bytes after the end of the current data have never been\n * written, then zero those bytes in order to avoid memory check reports of\n * the use of uninitialized (or uninitialised as Julian writes) bytes by\n * the longest match routines. Update the high water mark for the next\n * time through here. WIN_INIT is set to MAX_MATCH since the longest match\n * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.\n */\n// if (s.high_water < s.window_size) {\n// var curr = s.strstart + s.lookahead;\n// var init = 0;\n//\n// if (s.high_water < curr) {\n// /* Previous high water mark below current data -- zero WIN_INIT\n// * bytes or up to end of window, whichever is less.\n// */\n// init = s.window_size - curr;\n// if (init > WIN_INIT)\n// init = WIN_INIT;\n// zmemzero(s->window + curr, (unsigned)init);\n// s->high_water = curr + init;\n// }\n// else if (s->high_water < (ulg)curr + WIN_INIT) {\n// /* High water mark at or above current data, but below current data\n// * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up\n// * to end of window, whichever is less.\n// */\n// init = (ulg)curr + WIN_INIT - s->high_water;\n// if (init > s->window_size - s->high_water)\n// init = s->window_size - s->high_water;\n// zmemzero(s->window + s->high_water, (unsigned)init);\n// s->high_water += init;\n// }\n// }\n//\n// Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,\n// \"not enough room for search\");\n}\n\n/* ===========================================================================\n * Copy without compression as much as possible from the input stream, return\n * the current block state.\n * This function does not insert new strings in the dictionary since\n * uncompressible data is probably not useful. This function is used\n * only for the level=0 compression option.\n * NOTE: this function should be optimized to avoid extra copying from\n * window to pending_buf.\n */\nfunction deflate_stored(s, flush) {\n /* Stored blocks are limited to 0xffff bytes, pending_buf is limited\n * to pending_buf_size, and each stored block has a 5 byte header:\n */\n var max_block_size = 0xffff;\n\n if (max_block_size > s.pending_buf_size - 5) {\n max_block_size = s.pending_buf_size - 5;\n }\n\n /* Copy as much as possible from input to output: */\n for (;;) {\n /* Fill the window as much as possible: */\n if (s.lookahead <= 1) {\n\n //Assert(s->strstart < s->w_size+MAX_DIST(s) ||\n // s->block_start >= (long)s->w_size, \"slide too late\");\n// if (!(s.strstart < s.w_size + (s.w_size - MIN_LOOKAHEAD) ||\n// s.block_start >= s.w_size)) {\n// throw new Error(\"slide too late\");\n// }\n\n fill_window(s);\n if (s.lookahead === 0 && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n\n if (s.lookahead === 0) {\n break;\n }\n /* flush the current block */\n }\n //Assert(s->block_start >= 0L, \"block gone\");\n// if (s.block_start < 0) throw new Error(\"block gone\");\n\n s.strstart += s.lookahead;\n s.lookahead = 0;\n\n /* Emit a stored block if pending_buf will be full: */\n var max_start = s.block_start + max_block_size;\n\n if (s.strstart === 0 || s.strstart >= max_start) {\n /* strstart == 0 is possible when wraparound on 16-bit machine */\n s.lookahead = s.strstart - max_start;\n s.strstart = max_start;\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n\n\n }\n /* Flush if we may have to slide, otherwise block_start may become\n * negative and the data will be gone:\n */\n if (s.strstart - s.block_start >= (s.w_size - MIN_LOOKAHEAD)) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n\n s.insert = 0;\n\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n\n if (s.strstart > s.block_start) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n\n return BS_NEED_MORE;\n}\n\n/* ===========================================================================\n * Compress as much as possible from the input stream, return the current\n * block state.\n * This function does not perform lazy evaluation of matches and inserts\n * new strings in the dictionary only for unmatched strings or for short\n * matches. It is used only for the fast compression options.\n */\nfunction deflate_fast(s, flush) {\n var hash_head; /* head of the hash chain */\n var bflush; /* set if current block must be flushed */\n\n for (;;) {\n /* Make sure that we always have enough lookahead, except\n * at the end of the input file. We need MAX_MATCH bytes\n * for the next match, plus MIN_MATCH bytes to insert the\n * string following the next match.\n */\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break; /* flush the current block */\n }\n }\n\n /* Insert the string window[strstart .. strstart+2] in the\n * dictionary, and set hash_head to the head of the hash chain:\n */\n hash_head = 0/*NIL*/;\n if (s.lookahead >= MIN_MATCH) {\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n }\n\n /* Find the longest match, discarding those <= prev_length.\n * At this point we have always match_length < MIN_MATCH\n */\n if (hash_head !== 0/*NIL*/ && ((s.strstart - hash_head) <= (s.w_size - MIN_LOOKAHEAD))) {\n /* To simplify the code, we prevent matches with the string\n * of window index 0 (in particular we have to avoid a match\n * of the string with itself at the start of the input file).\n */\n s.match_length = longest_match(s, hash_head);\n /* longest_match() sets match_start */\n }\n if (s.match_length >= MIN_MATCH) {\n // check_match(s, s.strstart, s.match_start, s.match_length); // for debug only\n\n /*** _tr_tally_dist(s, s.strstart - s.match_start,\n s.match_length - MIN_MATCH, bflush); ***/\n bflush = trees._tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH);\n\n s.lookahead -= s.match_length;\n\n /* Insert new strings in the hash table only if the match length\n * is not too large. This saves time but degrades compression.\n */\n if (s.match_length <= s.max_lazy_match/*max_insert_length*/ && s.lookahead >= MIN_MATCH) {\n s.match_length--; /* string at strstart already in table */\n do {\n s.strstart++;\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n /* strstart never exceeds WSIZE-MAX_MATCH, so there are\n * always MIN_MATCH bytes ahead.\n */\n } while (--s.match_length !== 0);\n s.strstart++;\n } else\n {\n s.strstart += s.match_length;\n s.match_length = 0;\n s.ins_h = s.window[s.strstart];\n /* UPDATE_HASH(s, s.ins_h, s.window[s.strstart+1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + 1]) & s.hash_mask;\n\n//#if MIN_MATCH != 3\n// Call UPDATE_HASH() MIN_MATCH-3 more times\n//#endif\n /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not\n * matter since it will be recomputed at next deflate call.\n */\n }\n } else {\n /* No match, output a literal byte */\n //Tracevv((stderr,\"%c\", s.window[s.strstart]));\n /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart]);\n\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n s.insert = ((s.strstart < (MIN_MATCH - 1)) ? s.strstart : MIN_MATCH - 1);\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n return BS_BLOCK_DONE;\n}\n\n/* ===========================================================================\n * Same as above, but achieves better compression. We use a lazy\n * evaluation for matches: a match is finally adopted only if there is\n * no better match at the next window position.\n */\nfunction deflate_slow(s, flush) {\n var hash_head; /* head of hash chain */\n var bflush; /* set if current block must be flushed */\n\n var max_insert;\n\n /* Process the input block. */\n for (;;) {\n /* Make sure that we always have enough lookahead, except\n * at the end of the input file. We need MAX_MATCH bytes\n * for the next match, plus MIN_MATCH bytes to insert the\n * string following the next match.\n */\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) { break; } /* flush the current block */\n }\n\n /* Insert the string window[strstart .. strstart+2] in the\n * dictionary, and set hash_head to the head of the hash chain:\n */\n hash_head = 0/*NIL*/;\n if (s.lookahead >= MIN_MATCH) {\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n }\n\n /* Find the longest match, discarding those <= prev_length.\n */\n s.prev_length = s.match_length;\n s.prev_match = s.match_start;\n s.match_length = MIN_MATCH - 1;\n\n if (hash_head !== 0/*NIL*/ && s.prev_length < s.max_lazy_match &&\n s.strstart - hash_head <= (s.w_size - MIN_LOOKAHEAD)/*MAX_DIST(s)*/) {\n /* To simplify the code, we prevent matches with the string\n * of window index 0 (in particular we have to avoid a match\n * of the string with itself at the start of the input file).\n */\n s.match_length = longest_match(s, hash_head);\n /* longest_match() sets match_start */\n\n if (s.match_length <= 5 &&\n (s.strategy === Z_FILTERED || (s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096/*TOO_FAR*/))) {\n\n /* If prev_match is also MIN_MATCH, match_start is garbage\n * but we will ignore the current match anyway.\n */\n s.match_length = MIN_MATCH - 1;\n }\n }\n /* If there was a match at the previous step and the current\n * match is not better, output the previous match:\n */\n if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) {\n max_insert = s.strstart + s.lookahead - MIN_MATCH;\n /* Do not insert strings in hash table beyond this. */\n\n //check_match(s, s.strstart-1, s.prev_match, s.prev_length);\n\n /***_tr_tally_dist(s, s.strstart - 1 - s.prev_match,\n s.prev_length - MIN_MATCH, bflush);***/\n bflush = trees._tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH);\n /* Insert in hash table all strings up to the end of the match.\n * strstart-1 and strstart are already inserted. If there is not\n * enough lookahead, the last two strings are not inserted in\n * the hash table.\n */\n s.lookahead -= s.prev_length - 1;\n s.prev_length -= 2;\n do {\n if (++s.strstart <= max_insert) {\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n }\n } while (--s.prev_length !== 0);\n s.match_available = 0;\n s.match_length = MIN_MATCH - 1;\n s.strstart++;\n\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n\n } else if (s.match_available) {\n /* If there was no match at the previous position, output a\n * single literal. If there was a match but the current match\n * is longer, truncate the previous match to a single literal.\n */\n //Tracevv((stderr,\"%c\", s->window[s->strstart-1]));\n /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);\n\n if (bflush) {\n /*** FLUSH_BLOCK_ONLY(s, 0) ***/\n flush_block_only(s, false);\n /***/\n }\n s.strstart++;\n s.lookahead--;\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n } else {\n /* There is no previous match to compare with, wait for\n * the next step to decide.\n */\n s.match_available = 1;\n s.strstart++;\n s.lookahead--;\n }\n }\n //Assert (flush != Z_NO_FLUSH, \"no flush?\");\n if (s.match_available) {\n //Tracevv((stderr,\"%c\", s->window[s->strstart-1]));\n /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);\n\n s.match_available = 0;\n }\n s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n\n return BS_BLOCK_DONE;\n}\n\n\n/* ===========================================================================\n * For Z_RLE, simply look for runs of bytes, generate matches only of distance\n * one. Do not maintain a hash table. (It will be regenerated if this run of\n * deflate switches away from Z_RLE.)\n */\nfunction deflate_rle(s, flush) {\n var bflush; /* set if current block must be flushed */\n var prev; /* byte at distance one to match */\n var scan, strend; /* scan goes up to strend for length of run */\n\n var _win = s.window;\n\n for (;;) {\n /* Make sure that we always have enough lookahead, except\n * at the end of the input file. We need MAX_MATCH bytes\n * for the longest run, plus one for the unrolled loop.\n */\n if (s.lookahead <= MAX_MATCH) {\n fill_window(s);\n if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) { break; } /* flush the current block */\n }\n\n /* See how many times the previous byte repeats */\n s.match_length = 0;\n if (s.lookahead >= MIN_MATCH && s.strstart > 0) {\n scan = s.strstart - 1;\n prev = _win[scan];\n if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) {\n strend = s.strstart + MAX_MATCH;\n do {\n /*jshint noempty:false*/\n } while (prev === _win[++scan] && prev === _win[++scan] &&\n prev === _win[++scan] && prev === _win[++scan] &&\n prev === _win[++scan] && prev === _win[++scan] &&\n prev === _win[++scan] && prev === _win[++scan] &&\n scan < strend);\n s.match_length = MAX_MATCH - (strend - scan);\n if (s.match_length > s.lookahead) {\n s.match_length = s.lookahead;\n }\n }\n //Assert(scan <= s->window+(uInt)(s->window_size-1), \"wild scan\");\n }\n\n /* Emit match if have run of MIN_MATCH or longer, else emit literal */\n if (s.match_length >= MIN_MATCH) {\n //check_match(s, s.strstart, s.strstart - 1, s.match_length);\n\n /*** _tr_tally_dist(s, 1, s.match_length - MIN_MATCH, bflush); ***/\n bflush = trees._tr_tally(s, 1, s.match_length - MIN_MATCH);\n\n s.lookahead -= s.match_length;\n s.strstart += s.match_length;\n s.match_length = 0;\n } else {\n /* No match, output a literal byte */\n //Tracevv((stderr,\"%c\", s->window[s->strstart]));\n /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart]);\n\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n return BS_BLOCK_DONE;\n}\n\n/* ===========================================================================\n * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table.\n * (It will be regenerated if this run of deflate switches away from Huffman.)\n */\nfunction deflate_huff(s, flush) {\n var bflush; /* set if current block must be flushed */\n\n for (;;) {\n /* Make sure that we have a literal to write. */\n if (s.lookahead === 0) {\n fill_window(s);\n if (s.lookahead === 0) {\n if (flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n break; /* flush the current block */\n }\n }\n\n /* Output a literal byte */\n s.match_length = 0;\n //Tracevv((stderr,\"%c\", s->window[s->strstart]));\n /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n return BS_BLOCK_DONE;\n}\n\n/* Values for max_lazy_match, good_match and max_chain_length, depending on\n * the desired pack level (0..9). The values given below have been tuned to\n * exclude worst case performance for pathological files. Better values may be\n * found for specific files.\n */\nfunction Config(good_length, max_lazy, nice_length, max_chain, func) {\n this.good_length = good_length;\n this.max_lazy = max_lazy;\n this.nice_length = nice_length;\n this.max_chain = max_chain;\n this.func = func;\n}\n\nvar configuration_table;\n\nconfiguration_table = [\n /* good lazy nice chain */\n new Config(0, 0, 0, 0, deflate_stored), /* 0 store only */\n new Config(4, 4, 8, 4, deflate_fast), /* 1 max speed, no lazy matches */\n new Config(4, 5, 16, 8, deflate_fast), /* 2 */\n new Config(4, 6, 32, 32, deflate_fast), /* 3 */\n\n new Config(4, 4, 16, 16, deflate_slow), /* 4 lazy matches */\n new Config(8, 16, 32, 32, deflate_slow), /* 5 */\n new Config(8, 16, 128, 128, deflate_slow), /* 6 */\n new Config(8, 32, 128, 256, deflate_slow), /* 7 */\n new Config(32, 128, 258, 1024, deflate_slow), /* 8 */\n new Config(32, 258, 258, 4096, deflate_slow) /* 9 max compression */\n];\n\n\n/* ===========================================================================\n * Initialize the \"longest match\" routines for a new zlib stream\n */\nfunction lm_init(s) {\n s.window_size = 2 * s.w_size;\n\n /*** CLEAR_HASH(s); ***/\n zero(s.head); // Fill with NIL (= 0);\n\n /* Set the default configuration parameters:\n */\n s.max_lazy_match = configuration_table[s.level].max_lazy;\n s.good_match = configuration_table[s.level].good_length;\n s.nice_match = configuration_table[s.level].nice_length;\n s.max_chain_length = configuration_table[s.level].max_chain;\n\n s.strstart = 0;\n s.block_start = 0;\n s.lookahead = 0;\n s.insert = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n s.ins_h = 0;\n}\n\n\nfunction DeflateState() {\n this.strm = null; /* pointer back to this zlib stream */\n this.status = 0; /* as the name implies */\n this.pending_buf = null; /* output still pending */\n this.pending_buf_size = 0; /* size of pending_buf */\n this.pending_out = 0; /* next pending byte to output to the stream */\n this.pending = 0; /* nb of bytes in the pending buffer */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.gzhead = null; /* gzip header information to write */\n this.gzindex = 0; /* where in extra, name, or comment */\n this.method = Z_DEFLATED; /* can only be DEFLATED */\n this.last_flush = -1; /* value of flush param for previous deflate call */\n\n this.w_size = 0; /* LZ77 window size (32K by default) */\n this.w_bits = 0; /* log2(w_size) (8..16) */\n this.w_mask = 0; /* w_size - 1 */\n\n this.window = null;\n /* Sliding window. Input bytes are read into the second half of the window,\n * and move to the first half later to keep a dictionary of at least wSize\n * bytes. With this organization, matches are limited to a distance of\n * wSize-MAX_MATCH bytes, but this ensures that IO is always\n * performed with a length multiple of the block size.\n */\n\n this.window_size = 0;\n /* Actual size of window: 2*wSize, except when the user input buffer\n * is directly used as sliding window.\n */\n\n this.prev = null;\n /* Link to older string with same hash index. To limit the size of this\n * array to 64K, this link is maintained only for the last 32K strings.\n * An index in this array is thus a window index modulo 32K.\n */\n\n this.head = null; /* Heads of the hash chains or NIL. */\n\n this.ins_h = 0; /* hash index of string to be inserted */\n this.hash_size = 0; /* number of elements in hash table */\n this.hash_bits = 0; /* log2(hash_size) */\n this.hash_mask = 0; /* hash_size-1 */\n\n this.hash_shift = 0;\n /* Number of bits by which ins_h must be shifted at each input\n * step. It must be such that after MIN_MATCH steps, the oldest\n * byte no longer takes part in the hash key, that is:\n * hash_shift * MIN_MATCH >= hash_bits\n */\n\n this.block_start = 0;\n /* Window position at the beginning of the current output block. Gets\n * negative when the window is moved backwards.\n */\n\n this.match_length = 0; /* length of best match */\n this.prev_match = 0; /* previous match */\n this.match_available = 0; /* set if previous match exists */\n this.strstart = 0; /* start of string to insert */\n this.match_start = 0; /* start of matching string */\n this.lookahead = 0; /* number of valid bytes ahead in window */\n\n this.prev_length = 0;\n /* Length of the best match at previous step. Matches not greater than this\n * are discarded. This is used in the lazy match evaluation.\n */\n\n this.max_chain_length = 0;\n /* To speed up deflation, hash chains are never searched beyond this\n * length. A higher limit improves compression ratio but degrades the\n * speed.\n */\n\n this.max_lazy_match = 0;\n /* Attempt to find a better match only when the current match is strictly\n * smaller than this value. This mechanism is used only for compression\n * levels >= 4.\n */\n // That's alias to max_lazy_match, don't use directly\n //this.max_insert_length = 0;\n /* Insert new strings in the hash table only if the match length is not\n * greater than this length. This saves time but degrades compression.\n * max_insert_length is used only for compression levels <= 3.\n */\n\n this.level = 0; /* compression level (1..9) */\n this.strategy = 0; /* favor or force Huffman coding*/\n\n this.good_match = 0;\n /* Use a faster search when the previous match is longer than this */\n\n this.nice_match = 0; /* Stop searching when current match exceeds this */\n\n /* used by trees.c: */\n\n /* Didn't use ct_data typedef below to suppress compiler warning */\n\n // struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */\n // struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */\n // struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */\n\n // Use flat array of DOUBLE size, with interleaved fata,\n // because JS does not support effective\n this.dyn_ltree = new utils.Buf16(HEAP_SIZE * 2);\n this.dyn_dtree = new utils.Buf16((2 * D_CODES + 1) * 2);\n this.bl_tree = new utils.Buf16((2 * BL_CODES + 1) * 2);\n zero(this.dyn_ltree);\n zero(this.dyn_dtree);\n zero(this.bl_tree);\n\n this.l_desc = null; /* desc. for literal tree */\n this.d_desc = null; /* desc. for distance tree */\n this.bl_desc = null; /* desc. for bit length tree */\n\n //ush bl_count[MAX_BITS+1];\n this.bl_count = new utils.Buf16(MAX_BITS + 1);\n /* number of codes at each bit length for an optimal tree */\n\n //int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */\n this.heap = new utils.Buf16(2 * L_CODES + 1); /* heap used to build the Huffman trees */\n zero(this.heap);\n\n this.heap_len = 0; /* number of elements in the heap */\n this.heap_max = 0; /* element of largest frequency */\n /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.\n * The same heap array is used to build all trees.\n */\n\n this.depth = new utils.Buf16(2 * L_CODES + 1); //uch depth[2*L_CODES+1];\n zero(this.depth);\n /* Depth of each subtree used as tie breaker for trees of equal frequency\n */\n\n this.l_buf = 0; /* buffer index for literals or lengths */\n\n this.lit_bufsize = 0;\n /* Size of match buffer for literals/lengths. There are 4 reasons for\n * limiting lit_bufsize to 64K:\n * - frequencies can be kept in 16 bit counters\n * - if compression is not successful for the first block, all input\n * data is still in the window so we can still emit a stored block even\n * when input comes from standard input. (This can also be done for\n * all blocks if lit_bufsize is not greater than 32K.)\n * - if compression is not successful for a file smaller than 64K, we can\n * even emit a stored file instead of a stored block (saving 5 bytes).\n * This is applicable only for zip (not gzip or zlib).\n * - creating new Huffman trees less frequently may not provide fast\n * adaptation to changes in the input data statistics. (Take for\n * example a binary file with poorly compressible code followed by\n * a highly compressible string table.) Smaller buffer sizes give\n * fast adaptation but have of course the overhead of transmitting\n * trees more frequently.\n * - I can't count above 4\n */\n\n this.last_lit = 0; /* running index in l_buf */\n\n this.d_buf = 0;\n /* Buffer index for distances. To simplify the code, d_buf and l_buf have\n * the same number of elements. To use different lengths, an extra flag\n * array would be necessary.\n */\n\n this.opt_len = 0; /* bit length of current block with optimal trees */\n this.static_len = 0; /* bit length of current block with static trees */\n this.matches = 0; /* number of string matches in current block */\n this.insert = 0; /* bytes at end of window left to insert */\n\n\n this.bi_buf = 0;\n /* Output buffer. bits are inserted starting at the bottom (least\n * significant bits).\n */\n this.bi_valid = 0;\n /* Number of valid bits in bi_buf. All bits above the last valid bit\n * are always zero.\n */\n\n // Used for window memory init. We safely ignore it for JS. That makes\n // sense only for pointers and memory check tools.\n //this.high_water = 0;\n /* High water mark offset in window for initialized bytes -- bytes above\n * this are set to zero in order to avoid memory check warnings when\n * longest match routines access bytes past the input. This is then\n * updated to the new high water mark.\n */\n}\n\n\nfunction deflateResetKeep(strm) {\n var s;\n\n if (!strm || !strm.state) {\n return err(strm, Z_STREAM_ERROR);\n }\n\n strm.total_in = strm.total_out = 0;\n strm.data_type = Z_UNKNOWN;\n\n s = strm.state;\n s.pending = 0;\n s.pending_out = 0;\n\n if (s.wrap < 0) {\n s.wrap = -s.wrap;\n /* was made negative by deflate(..., Z_FINISH); */\n }\n s.status = (s.wrap ? INIT_STATE : BUSY_STATE);\n strm.adler = (s.wrap === 2) ?\n 0 // crc32(0, Z_NULL, 0)\n :\n 1; // adler32(0, Z_NULL, 0)\n s.last_flush = Z_NO_FLUSH;\n trees._tr_init(s);\n return Z_OK;\n}\n\n\nfunction deflateReset(strm) {\n var ret = deflateResetKeep(strm);\n if (ret === Z_OK) {\n lm_init(strm.state);\n }\n return ret;\n}\n\n\nfunction deflateSetHeader(strm, head) {\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n if (strm.state.wrap !== 2) { return Z_STREAM_ERROR; }\n strm.state.gzhead = head;\n return Z_OK;\n}\n\n\nfunction deflateInit2(strm, level, method, windowBits, memLevel, strategy) {\n if (!strm) { // === Z_NULL\n return Z_STREAM_ERROR;\n }\n var wrap = 1;\n\n if (level === Z_DEFAULT_COMPRESSION) {\n level = 6;\n }\n\n if (windowBits < 0) { /* suppress zlib wrapper */\n wrap = 0;\n windowBits = -windowBits;\n }\n\n else if (windowBits > 15) {\n wrap = 2; /* write gzip wrapper instead */\n windowBits -= 16;\n }\n\n\n if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED ||\n windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||\n strategy < 0 || strategy > Z_FIXED) {\n return err(strm, Z_STREAM_ERROR);\n }\n\n\n if (windowBits === 8) {\n windowBits = 9;\n }\n /* until 256-byte window bug fixed */\n\n var s = new DeflateState();\n\n strm.state = s;\n s.strm = strm;\n\n s.wrap = wrap;\n s.gzhead = null;\n s.w_bits = windowBits;\n s.w_size = 1 << s.w_bits;\n s.w_mask = s.w_size - 1;\n\n s.hash_bits = memLevel + 7;\n s.hash_size = 1 << s.hash_bits;\n s.hash_mask = s.hash_size - 1;\n s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH);\n\n s.window = new utils.Buf8(s.w_size * 2);\n s.head = new utils.Buf16(s.hash_size);\n s.prev = new utils.Buf16(s.w_size);\n\n // Don't need mem init magic for JS.\n //s.high_water = 0; /* nothing written to s->window yet */\n\n s.lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */\n\n s.pending_buf_size = s.lit_bufsize * 4;\n\n //overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);\n //s->pending_buf = (uchf *) overlay;\n s.pending_buf = new utils.Buf8(s.pending_buf_size);\n\n // It is offset from `s.pending_buf` (size is `s.lit_bufsize * 2`)\n //s->d_buf = overlay + s->lit_bufsize/sizeof(ush);\n s.d_buf = 1 * s.lit_bufsize;\n\n //s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;\n s.l_buf = (1 + 2) * s.lit_bufsize;\n\n s.level = level;\n s.strategy = strategy;\n s.method = method;\n\n return deflateReset(strm);\n}\n\nfunction deflateInit(strm, level) {\n return deflateInit2(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);\n}\n\n\nfunction deflate(strm, flush) {\n var old_flush, s;\n var beg, val; // for gzip header write only\n\n if (!strm || !strm.state ||\n flush > Z_BLOCK || flush < 0) {\n return strm ? err(strm, Z_STREAM_ERROR) : Z_STREAM_ERROR;\n }\n\n s = strm.state;\n\n if (!strm.output ||\n (!strm.input && strm.avail_in !== 0) ||\n (s.status === FINISH_STATE && flush !== Z_FINISH)) {\n return err(strm, (strm.avail_out === 0) ? Z_BUF_ERROR : Z_STREAM_ERROR);\n }\n\n s.strm = strm; /* just in case */\n old_flush = s.last_flush;\n s.last_flush = flush;\n\n /* Write the header */\n if (s.status === INIT_STATE) {\n\n if (s.wrap === 2) { // GZIP header\n strm.adler = 0; //crc32(0L, Z_NULL, 0);\n put_byte(s, 31);\n put_byte(s, 139);\n put_byte(s, 8);\n if (!s.gzhead) { // s->gzhead == Z_NULL\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, s.level === 9 ? 2 :\n (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?\n 4 : 0));\n put_byte(s, OS_CODE);\n s.status = BUSY_STATE;\n }\n else {\n put_byte(s, (s.gzhead.text ? 1 : 0) +\n (s.gzhead.hcrc ? 2 : 0) +\n (!s.gzhead.extra ? 0 : 4) +\n (!s.gzhead.name ? 0 : 8) +\n (!s.gzhead.comment ? 0 : 16)\n );\n put_byte(s, s.gzhead.time & 0xff);\n put_byte(s, (s.gzhead.time >> 8) & 0xff);\n put_byte(s, (s.gzhead.time >> 16) & 0xff);\n put_byte(s, (s.gzhead.time >> 24) & 0xff);\n put_byte(s, s.level === 9 ? 2 :\n (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?\n 4 : 0));\n put_byte(s, s.gzhead.os & 0xff);\n if (s.gzhead.extra && s.gzhead.extra.length) {\n put_byte(s, s.gzhead.extra.length & 0xff);\n put_byte(s, (s.gzhead.extra.length >> 8) & 0xff);\n }\n if (s.gzhead.hcrc) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending, 0);\n }\n s.gzindex = 0;\n s.status = EXTRA_STATE;\n }\n }\n else // DEFLATE header\n {\n var header = (Z_DEFLATED + ((s.w_bits - 8) << 4)) << 8;\n var level_flags = -1;\n\n if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) {\n level_flags = 0;\n } else if (s.level < 6) {\n level_flags = 1;\n } else if (s.level === 6) {\n level_flags = 2;\n } else {\n level_flags = 3;\n }\n header |= (level_flags << 6);\n if (s.strstart !== 0) { header |= PRESET_DICT; }\n header += 31 - (header % 31);\n\n s.status = BUSY_STATE;\n putShortMSB(s, header);\n\n /* Save the adler32 of the preset dictionary: */\n if (s.strstart !== 0) {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 0xffff);\n }\n strm.adler = 1; // adler32(0L, Z_NULL, 0);\n }\n }\n\n//#ifdef GZIP\n if (s.status === EXTRA_STATE) {\n if (s.gzhead.extra/* != Z_NULL*/) {\n beg = s.pending; /* start of bytes to update crc */\n\n while (s.gzindex < (s.gzhead.extra.length & 0xffff)) {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n beg = s.pending;\n if (s.pending === s.pending_buf_size) {\n break;\n }\n }\n put_byte(s, s.gzhead.extra[s.gzindex] & 0xff);\n s.gzindex++;\n }\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n if (s.gzindex === s.gzhead.extra.length) {\n s.gzindex = 0;\n s.status = NAME_STATE;\n }\n }\n else {\n s.status = NAME_STATE;\n }\n }\n if (s.status === NAME_STATE) {\n if (s.gzhead.name/* != Z_NULL*/) {\n beg = s.pending; /* start of bytes to update crc */\n //int val;\n\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n beg = s.pending;\n if (s.pending === s.pending_buf_size) {\n val = 1;\n break;\n }\n }\n // JS specific: little magic to add zero terminator to end of string\n if (s.gzindex < s.gzhead.name.length) {\n val = s.gzhead.name.charCodeAt(s.gzindex++) & 0xff;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n if (val === 0) {\n s.gzindex = 0;\n s.status = COMMENT_STATE;\n }\n }\n else {\n s.status = COMMENT_STATE;\n }\n }\n if (s.status === COMMENT_STATE) {\n if (s.gzhead.comment/* != Z_NULL*/) {\n beg = s.pending; /* start of bytes to update crc */\n //int val;\n\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n beg = s.pending;\n if (s.pending === s.pending_buf_size) {\n val = 1;\n break;\n }\n }\n // JS specific: little magic to add zero terminator to end of string\n if (s.gzindex < s.gzhead.comment.length) {\n val = s.gzhead.comment.charCodeAt(s.gzindex++) & 0xff;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n if (val === 0) {\n s.status = HCRC_STATE;\n }\n }\n else {\n s.status = HCRC_STATE;\n }\n }\n if (s.status === HCRC_STATE) {\n if (s.gzhead.hcrc) {\n if (s.pending + 2 > s.pending_buf_size) {\n flush_pending(strm);\n }\n if (s.pending + 2 <= s.pending_buf_size) {\n put_byte(s, strm.adler & 0xff);\n put_byte(s, (strm.adler >> 8) & 0xff);\n strm.adler = 0; //crc32(0L, Z_NULL, 0);\n s.status = BUSY_STATE;\n }\n }\n else {\n s.status = BUSY_STATE;\n }\n }\n//#endif\n\n /* Flush as much pending output as possible */\n if (s.pending !== 0) {\n flush_pending(strm);\n if (strm.avail_out === 0) {\n /* Since avail_out is 0, deflate will be called again with\n * more output space, but possibly with both pending and\n * avail_in equal to zero. There won't be anything to do,\n * but this is not an error situation so make sure we\n * return OK instead of BUF_ERROR at next call of deflate:\n */\n s.last_flush = -1;\n return Z_OK;\n }\n\n /* Make sure there is something to do and avoid duplicate consecutive\n * flushes. For repeated and useless calls with Z_FINISH, we keep\n * returning Z_STREAM_END instead of Z_BUF_ERROR.\n */\n } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) &&\n flush !== Z_FINISH) {\n return err(strm, Z_BUF_ERROR);\n }\n\n /* User must not provide more input after the first FINISH: */\n if (s.status === FINISH_STATE && strm.avail_in !== 0) {\n return err(strm, Z_BUF_ERROR);\n }\n\n /* Start a new block or continue the current one.\n */\n if (strm.avail_in !== 0 || s.lookahead !== 0 ||\n (flush !== Z_NO_FLUSH && s.status !== FINISH_STATE)) {\n var bstate = (s.strategy === Z_HUFFMAN_ONLY) ? deflate_huff(s, flush) :\n (s.strategy === Z_RLE ? deflate_rle(s, flush) :\n configuration_table[s.level].func(s, flush));\n\n if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) {\n s.status = FINISH_STATE;\n }\n if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) {\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n /* avoid BUF_ERROR next call, see above */\n }\n return Z_OK;\n /* If flush != Z_NO_FLUSH && avail_out == 0, the next call\n * of deflate should use the same flush parameter to make sure\n * that the flush is complete. So we don't have to output an\n * empty block here, this will be done at next call. This also\n * ensures that for a very small output buffer, we emit at most\n * one empty block.\n */\n }\n if (bstate === BS_BLOCK_DONE) {\n if (flush === Z_PARTIAL_FLUSH) {\n trees._tr_align(s);\n }\n else if (flush !== Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */\n\n trees._tr_stored_block(s, 0, 0, false);\n /* For a full flush, this empty block will be recognized\n * as a special marker by inflate_sync().\n */\n if (flush === Z_FULL_FLUSH) {\n /*** CLEAR_HASH(s); ***/ /* forget history */\n zero(s.head); // Fill with NIL (= 0);\n\n if (s.lookahead === 0) {\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n }\n }\n flush_pending(strm);\n if (strm.avail_out === 0) {\n s.last_flush = -1; /* avoid BUF_ERROR at next call, see above */\n return Z_OK;\n }\n }\n }\n //Assert(strm->avail_out > 0, \"bug2\");\n //if (strm.avail_out <= 0) { throw new Error(\"bug2\");}\n\n if (flush !== Z_FINISH) { return Z_OK; }\n if (s.wrap <= 0) { return Z_STREAM_END; }\n\n /* Write the trailer */\n if (s.wrap === 2) {\n put_byte(s, strm.adler & 0xff);\n put_byte(s, (strm.adler >> 8) & 0xff);\n put_byte(s, (strm.adler >> 16) & 0xff);\n put_byte(s, (strm.adler >> 24) & 0xff);\n put_byte(s, strm.total_in & 0xff);\n put_byte(s, (strm.total_in >> 8) & 0xff);\n put_byte(s, (strm.total_in >> 16) & 0xff);\n put_byte(s, (strm.total_in >> 24) & 0xff);\n }\n else\n {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 0xffff);\n }\n\n flush_pending(strm);\n /* If avail_out is zero, the application will call deflate again\n * to flush the rest.\n */\n if (s.wrap > 0) { s.wrap = -s.wrap; }\n /* write the trailer only once! */\n return s.pending !== 0 ? Z_OK : Z_STREAM_END;\n}\n\nfunction deflateEnd(strm) {\n var status;\n\n if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) {\n return Z_STREAM_ERROR;\n }\n\n status = strm.state.status;\n if (status !== INIT_STATE &&\n status !== EXTRA_STATE &&\n status !== NAME_STATE &&\n status !== COMMENT_STATE &&\n status !== HCRC_STATE &&\n status !== BUSY_STATE &&\n status !== FINISH_STATE\n ) {\n return err(strm, Z_STREAM_ERROR);\n }\n\n strm.state = null;\n\n return status === BUSY_STATE ? err(strm, Z_DATA_ERROR) : Z_OK;\n}\n\n\n/* =========================================================================\n * Initializes the compression dictionary from the given byte\n * sequence without producing any compressed output.\n */\nfunction deflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var s;\n var str, n;\n var wrap;\n var avail;\n var next;\n var input;\n var tmpDict;\n\n if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) {\n return Z_STREAM_ERROR;\n }\n\n s = strm.state;\n wrap = s.wrap;\n\n if (wrap === 2 || (wrap === 1 && s.status !== INIT_STATE) || s.lookahead) {\n return Z_STREAM_ERROR;\n }\n\n /* when using zlib wrappers, compute Adler-32 for provided dictionary */\n if (wrap === 1) {\n /* adler32(strm->adler, dictionary, dictLength); */\n strm.adler = adler32(strm.adler, dictionary, dictLength, 0);\n }\n\n s.wrap = 0; /* avoid computing Adler-32 in read_buf */\n\n /* if dictionary would fill window, just replace the history */\n if (dictLength >= s.w_size) {\n if (wrap === 0) { /* already empty otherwise */\n /*** CLEAR_HASH(s); ***/\n zero(s.head); // Fill with NIL (= 0);\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n /* use the tail */\n // dictionary = dictionary.slice(dictLength - s.w_size);\n tmpDict = new utils.Buf8(s.w_size);\n utils.arraySet(tmpDict, dictionary, dictLength - s.w_size, s.w_size, 0);\n dictionary = tmpDict;\n dictLength = s.w_size;\n }\n /* insert dictionary into window and hash */\n avail = strm.avail_in;\n next = strm.next_in;\n input = strm.input;\n strm.avail_in = dictLength;\n strm.next_in = 0;\n strm.input = dictionary;\n fill_window(s);\n while (s.lookahead >= MIN_MATCH) {\n str = s.strstart;\n n = s.lookahead - (MIN_MATCH - 1);\n do {\n /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;\n\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n\n s.head[s.ins_h] = str;\n str++;\n } while (--n);\n s.strstart = str;\n s.lookahead = MIN_MATCH - 1;\n fill_window(s);\n }\n s.strstart += s.lookahead;\n s.block_start = s.strstart;\n s.insert = s.lookahead;\n s.lookahead = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n strm.next_in = next;\n strm.input = input;\n strm.avail_in = avail;\n s.wrap = wrap;\n return Z_OK;\n}\n\n\nexports.deflateInit = deflateInit;\nexports.deflateInit2 = deflateInit2;\nexports.deflateReset = deflateReset;\nexports.deflateResetKeep = deflateResetKeep;\nexports.deflateSetHeader = deflateSetHeader;\nexports.deflate = deflate;\nexports.deflateEnd = deflateEnd;\nexports.deflateSetDictionary = deflateSetDictionary;\nexports.deflateInfo = 'pako deflate (from Nodeca project)';\n\n/* Not implemented\nexports.deflateBound = deflateBound;\nexports.deflateCopy = deflateCopy;\nexports.deflateParams = deflateParams;\nexports.deflatePending = deflatePending;\nexports.deflatePrime = deflatePrime;\nexports.deflateTune = deflateTune;\n*/\n","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nfunction GZheader() {\n /* true if compressed data believed to be text */\n this.text = 0;\n /* modification time */\n this.time = 0;\n /* extra flags (not used when writing a gzip file) */\n this.xflags = 0;\n /* operating system */\n this.os = 0;\n /* pointer to extra field or Z_NULL if none */\n this.extra = null;\n /* extra field length (valid if extra != Z_NULL) */\n this.extra_len = 0; // Actually, we don't need it in JS,\n // but leave for few code modifications\n\n //\n // Setup limits is not necessary because in js we should not preallocate memory\n // for inflate use constant limit in 65536 bytes\n //\n\n /* space at extra (only when reading header) */\n // this.extra_max = 0;\n /* pointer to zero-terminated file name or Z_NULL */\n this.name = '';\n /* space at name (only when reading header) */\n // this.name_max = 0;\n /* pointer to zero-terminated comment or Z_NULL */\n this.comment = '';\n /* space at comment (only when reading header) */\n // this.comm_max = 0;\n /* true if there was or will be a header crc */\n this.hcrc = 0;\n /* true when done reading gzip header (not used when writing a gzip file) */\n this.done = false;\n}\n\nmodule.exports = GZheader;\n","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\n// See state defs from inflate.js\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\n\n/*\n Decode literal, length, and distance codes and write out the resulting\n literal and match bytes until either not enough input or output is\n available, an end-of-block is encountered, or a data error is encountered.\n When large enough input and output buffers are supplied to inflate(), for\n example, a 16K input buffer and a 64K output buffer, more than 95% of the\n inflate execution time is spent in this routine.\n\n Entry assumptions:\n\n state.mode === LEN\n strm.avail_in >= 6\n strm.avail_out >= 258\n start >= strm.avail_out\n state.bits < 8\n\n On return, state.mode is one of:\n\n LEN -- ran out of enough output space or enough available input\n TYPE -- reached end of block code, inflate() to interpret next block\n BAD -- error in block data\n\n Notes:\n\n - The maximum input bits used by a length/distance pair is 15 bits for the\n length code, 5 bits for the length extra, 15 bits for the distance code,\n and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n Therefore if strm.avail_in >= 6, then there is enough input to avoid\n checking for available input while decoding.\n\n - The maximum bytes that a single length/distance pair can output is 258\n bytes, which is the maximum length that can be coded. inflate_fast()\n requires strm.avail_out >= 258 for each loop to avoid checking for\n output space.\n */\nmodule.exports = function inflate_fast(strm, start) {\n var state;\n var _in; /* local strm.input */\n var last; /* have enough input while in < last */\n var _out; /* local strm.output */\n var beg; /* inflate()'s initial strm.output */\n var end; /* while out < end, enough space available */\n//#ifdef INFLATE_STRICT\n var dmax; /* maximum distance from zlib header */\n//#endif\n var wsize; /* window size or zero if not using window */\n var whave; /* valid bytes in the window */\n var wnext; /* window write index */\n // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n var s_window; /* allocated sliding window, if wsize != 0 */\n var hold; /* local strm.hold */\n var bits; /* local strm.bits */\n var lcode; /* local strm.lencode */\n var dcode; /* local strm.distcode */\n var lmask; /* mask for first level of length codes */\n var dmask; /* mask for first level of distance codes */\n var here; /* retrieved table entry */\n var op; /* code bits, operation, extra bits, or */\n /* window position, window bytes to copy */\n var len; /* match length, unused bytes */\n var dist; /* match distance */\n var from; /* where to copy match from */\n var from_source;\n\n\n var input, output; // JS specific, because we have no pointers\n\n /* copy state to local variables */\n state = strm.state;\n //here = state.here;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n//#ifdef INFLATE_STRICT\n dmax = state.dmax;\n//#endif\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n\n\n /* decode literals and length/distances until end-of-block or not enough\n input data or output space */\n\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n\n here = lcode[hold & lmask];\n\n dolen:\n for (;;) { // Goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n if (op === 0) { /* literal */\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n output[_out++] = here & 0xffff/*here.val*/;\n }\n else if (op & 16) { /* length base */\n len = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & ((1 << op) - 1);\n hold >>>= op;\n bits -= op;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", len));\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n\n dodist:\n for (;;) { // goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n\n if (op & 16) { /* distance base */\n dist = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & ((1 << op) - 1);\n//#ifdef INFLATE_STRICT\n if (dist > dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break top;\n }\n//#endif\n hold >>>= op;\n bits -= op;\n //Tracevv((stderr, \"inflate: distance %u\\n\", dist));\n op = _out - beg; /* max distance in output */\n if (dist > op) { /* see if copy from window */\n op = dist - op; /* distance back in window */\n if (op > whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break top;\n }\n\n// (!) This block is disabled in zlib defaults,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// if (len <= op - whave) {\n// do {\n// output[_out++] = 0;\n// } while (--len);\n// continue top;\n// }\n// len -= op - whave;\n// do {\n// output[_out++] = 0;\n// } while (--op > whave);\n// if (op === 0) {\n// from = _out - dist;\n// do {\n// output[_out++] = output[from++];\n// } while (--len);\n// continue top;\n// }\n//#endif\n }\n from = 0; // window index\n from_source = s_window;\n if (wnext === 0) { /* very common case */\n from += wsize - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n else if (wnext < op) { /* wrap around window */\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) { /* some from end of window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) { /* some from start of window */\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n }\n else { /* contiguous in window */\n from += wnext - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n }\n else {\n from = _out - dist; /* copy direct from output */\n do { /* minimum length is three */\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n }\n else if ((op & 64) === 0) { /* 2nd level distance code */\n here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dodist;\n }\n else {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n }\n else if ((op & 64) === 0) { /* 2nd level length code */\n here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dolen;\n }\n else if (op & 32) { /* end-of-block */\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.mode = TYPE;\n break top;\n }\n else {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n } while (_in < last && _out < end);\n\n /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n\n /* update state and return */\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n state.hold = hold;\n state.bits = bits;\n return;\n};\n","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar utils = require('../utils/common');\nvar adler32 = require('./adler32');\nvar crc32 = require('./crc32');\nvar inflate_fast = require('./inffast');\nvar inflate_table = require('./inftrees');\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\n//var Z_NO_FLUSH = 0;\n//var Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\n//var Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\nvar Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\nvar Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n\n/* STATES ====================================================================*/\n/* ===========================================================================*/\n\n\nvar HEAD = 1; /* i: waiting for magic header */\nvar FLAGS = 2; /* i: waiting for method and flags (gzip) */\nvar TIME = 3; /* i: waiting for modification time (gzip) */\nvar OS = 4; /* i: waiting for extra flags and operating system (gzip) */\nvar EXLEN = 5; /* i: waiting for extra length (gzip) */\nvar EXTRA = 6; /* i: waiting for extra bytes (gzip) */\nvar NAME = 7; /* i: waiting for end of file name (gzip) */\nvar COMMENT = 8; /* i: waiting for end of comment (gzip) */\nvar HCRC = 9; /* i: waiting for header crc (gzip) */\nvar DICTID = 10; /* i: waiting for dictionary check value */\nvar DICT = 11; /* waiting for inflateSetDictionary() call */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\nvar TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */\nvar STORED = 14; /* i: waiting for stored size (length and complement) */\nvar COPY_ = 15; /* i/o: same as COPY below, but only first time in */\nvar COPY = 16; /* i/o: waiting for input or output to copy stored block */\nvar TABLE = 17; /* i: waiting for dynamic block table lengths */\nvar LENLENS = 18; /* i: waiting for code length code lengths */\nvar CODELENS = 19; /* i: waiting for length/lit and distance code lengths */\nvar LEN_ = 20; /* i: same as LEN below, but only first time in */\nvar LEN = 21; /* i: waiting for length/lit/eob code */\nvar LENEXT = 22; /* i: waiting for length extra bits */\nvar DIST = 23; /* i: waiting for distance code */\nvar DISTEXT = 24; /* i: waiting for distance extra bits */\nvar MATCH = 25; /* o: waiting for output space to copy string */\nvar LIT = 26; /* o: waiting for output space to write literal */\nvar CHECK = 27; /* i: waiting for 32-bit check value */\nvar LENGTH = 28; /* i: waiting for 32-bit length (gzip) */\nvar DONE = 29; /* finished check, done -- remain here until reset */\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar MEM = 31; /* got an inflate() memory error -- remain here until reset */\nvar SYNC = 32; /* looking for synchronization bytes to restart inflate() */\n\n/* ===========================================================================*/\n\n\n\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar MAX_WBITS = 15;\n/* 32K LZ77 window */\nvar DEF_WBITS = MAX_WBITS;\n\n\nfunction zswap32(q) {\n return (((q >>> 24) & 0xff) +\n ((q >>> 8) & 0xff00) +\n ((q & 0xff00) << 8) +\n ((q & 0xff) << 24));\n}\n\n\nfunction InflateState() {\n this.mode = 0; /* current inflate mode */\n this.last = false; /* true if processing last block */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.havedict = false; /* true if dictionary provided */\n this.flags = 0; /* gzip header method and flags (0 if zlib) */\n this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */\n this.check = 0; /* protected copy of check value */\n this.total = 0; /* protected copy of output count */\n // TODO: may be {}\n this.head = null; /* where to save gzip header information */\n\n /* sliding window */\n this.wbits = 0; /* log base 2 of requested window size */\n this.wsize = 0; /* window size or zero if not using window */\n this.whave = 0; /* valid bytes in the window */\n this.wnext = 0; /* window write index */\n this.window = null; /* allocated sliding window, if needed */\n\n /* bit accumulator */\n this.hold = 0; /* input bit accumulator */\n this.bits = 0; /* number of bits in \"in\" */\n\n /* for string and stored block copying */\n this.length = 0; /* literal or length of data to copy */\n this.offset = 0; /* distance back to copy string from */\n\n /* for table and code decoding */\n this.extra = 0; /* extra bits needed */\n\n /* fixed and dynamic code tables */\n this.lencode = null; /* starting table for length/literal codes */\n this.distcode = null; /* starting table for distance codes */\n this.lenbits = 0; /* index bits for lencode */\n this.distbits = 0; /* index bits for distcode */\n\n /* dynamic table building */\n this.ncode = 0; /* number of code length code lengths */\n this.nlen = 0; /* number of length code lengths */\n this.ndist = 0; /* number of distance code lengths */\n this.have = 0; /* number of code lengths in lens[] */\n this.next = null; /* next available space in codes[] */\n\n this.lens = new utils.Buf16(320); /* temporary storage for code lengths */\n this.work = new utils.Buf16(288); /* work area for code table building */\n\n /*\n because we don't have pointers in js, we use lencode and distcode directly\n as buffers so we don't need codes\n */\n //this.codes = new utils.Buf32(ENOUGH); /* space for code tables */\n this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */\n this.distdyn = null; /* dynamic table for distance codes (JS specific) */\n this.sane = 0; /* if false, allow invalid distance too far */\n this.back = 0; /* bits back of last unprocessed length/lit */\n this.was = 0; /* initial length of match */\n}\n\nfunction inflateResetKeep(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = ''; /*Z_NULL*/\n if (state.wrap) { /* to support ill-conceived Java test suite */\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.dmax = 32768;\n state.head = null/*Z_NULL*/;\n state.hold = 0;\n state.bits = 0;\n //state.lencode = state.distcode = state.next = state.codes;\n state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS);\n state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS);\n\n state.sane = 1;\n state.back = -1;\n //Tracev((stderr, \"inflate: reset\\n\"));\n return Z_OK;\n}\n\nfunction inflateReset(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n\n}\n\nfunction inflateReset2(strm, windowBits) {\n var wrap;\n var state;\n\n /* get the state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n /* extract wrap request from windowBits parameter */\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n }\n else {\n wrap = (windowBits >> 4) + 1;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n\n /* set number of window bits, free window if different */\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n\n /* update state and reset the rest of it */\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n}\n\nfunction inflateInit2(strm, windowBits) {\n var ret;\n var state;\n\n if (!strm) { return Z_STREAM_ERROR; }\n //strm.msg = Z_NULL; /* in case we return an error */\n\n state = new InflateState();\n\n //if (state === Z_NULL) return Z_MEM_ERROR;\n //Tracev((stderr, \"inflate: allocated\\n\"));\n strm.state = state;\n state.window = null/*Z_NULL*/;\n ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK) {\n strm.state = null/*Z_NULL*/;\n }\n return ret;\n}\n\nfunction inflateInit(strm) {\n return inflateInit2(strm, DEF_WBITS);\n}\n\n\n/*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding. Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter. This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time. However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\nvar virgin = true;\n\nvar lenfix, distfix; // We have no pointers in JS, so keep tables separate\n\nfunction fixedtables(state) {\n /* build fixed huffman tables if first call (may not be thread safe) */\n if (virgin) {\n var sym;\n\n lenfix = new utils.Buf32(512);\n distfix = new utils.Buf32(32);\n\n /* literal/length table */\n sym = 0;\n while (sym < 144) { state.lens[sym++] = 8; }\n while (sym < 256) { state.lens[sym++] = 9; }\n while (sym < 280) { state.lens[sym++] = 7; }\n while (sym < 288) { state.lens[sym++] = 8; }\n\n inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n\n /* distance table */\n sym = 0;\n while (sym < 32) { state.lens[sym++] = 5; }\n\n inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n\n /* do this just once */\n virgin = false;\n }\n\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n}\n\n\n/*\n Update the window with the last wsize (normally 32K) bytes written before\n returning. If window does not exist yet, create it. This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\nfunction updatewindow(strm, src, end, copy) {\n var dist;\n var state = strm.state;\n\n /* if it hasn't been done already, allocate space for the window */\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n\n state.window = new utils.Buf8(state.wsize);\n }\n\n /* copy state->wsize or less output bytes into the circular window */\n if (copy >= state.wsize) {\n utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0);\n state.wnext = 0;\n state.whave = state.wsize;\n }\n else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n //zmemcpy(state->window + state->wnext, end - copy, dist);\n utils.arraySet(state.window, src, end - copy, dist, state.wnext);\n copy -= dist;\n if (copy) {\n //zmemcpy(state->window, end - copy, copy);\n utils.arraySet(state.window, src, end - copy, copy, 0);\n state.wnext = copy;\n state.whave = state.wsize;\n }\n else {\n state.wnext += dist;\n if (state.wnext === state.wsize) { state.wnext = 0; }\n if (state.whave < state.wsize) { state.whave += dist; }\n }\n }\n return 0;\n}\n\nfunction inflate(strm, flush) {\n var state;\n var input, output; // input/output buffers\n var next; /* next input INDEX */\n var put; /* next output INDEX */\n var have, left; /* available input and output */\n var hold; /* bit buffer */\n var bits; /* bits in bit buffer */\n var _in, _out; /* save starting available input and output */\n var copy; /* number of stored or match bytes to copy */\n var from; /* where to copy match bytes from */\n var from_source;\n var here = 0; /* current decoding table entry */\n var here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n //var last; /* parent table entry */\n var last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n var len; /* length to copy for repeats, bits to drop */\n var ret; /* return code */\n var hbuf = new utils.Buf8(4); /* buffer for gzip header crc calculation */\n var opts;\n\n var n; // temporary var for NEED_BITS\n\n var order = /* permutation of code lengths */\n [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];\n\n\n if (!strm || !strm.state || !strm.output ||\n (!strm.input && strm.avail_in !== 0)) {\n return Z_STREAM_ERROR;\n }\n\n state = strm.state;\n if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */\n\n\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n _in = have;\n _out = left;\n ret = Z_OK;\n\n inf_leave: // goto emulation\n for (;;) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n //=== NEEDBITS(16);\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */\n state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = FLAGS;\n break;\n }\n state.flags = 0; /* expect zlib header */\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n strm.msg = 'incorrect header check';\n state.mode = BAD;\n break;\n }\n if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n len = (hold & 0x0f)/*BITS(4)*/ + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n else if (len > state.wbits) {\n strm.msg = 'invalid window size';\n state.mode = BAD;\n break;\n }\n state.dmax = 1 << len;\n //Tracev((stderr, \"inflate: zlib header ok\\n\"));\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = hold & 0x200 ? DICTID : TYPE;\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n break;\n case FLAGS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.flags = hold;\n if ((state.flags & 0xff) !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n if (state.flags & 0xe000) {\n strm.msg = 'unknown header flags set';\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = ((hold >> 8) & 1);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = TIME;\n /* falls through */\n case TIME:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC4(state.check, hold)\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n hbuf[2] = (hold >>> 16) & 0xff;\n hbuf[3] = (hold >>> 24) & 0xff;\n state.check = crc32(state.check, hbuf, 4, 0);\n //===\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = OS;\n /* falls through */\n case OS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.xflags = (hold & 0xff);\n state.head.os = (hold >> 8);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 0x0400) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n else if (state.head) {\n state.head.extra = null/*Z_NULL*/;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 0x0400) {\n copy = state.length;\n if (copy > have) { copy = have; }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n // Use untyped array for more convenient processing later\n state.head.extra = new Array(state.head.extra_len);\n }\n utils.arraySet(\n state.head.extra,\n input,\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n copy,\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n //zmemcpy(state.head.extra + len, next,\n // len + copy > state.head.extra_max ?\n // state.head.extra_max - len : copy);\n }\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) { break inf_leave; }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 0x0800) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n // TODO: 2 or 1 bytes?\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.name_max*/)) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 0x1000) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.comm_max*/)) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 0x0200) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.check & 0xffff)) {\n strm.msg = 'header crc mismatch';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n if (state.head) {\n state.head.hcrc = ((state.flags >> 9) & 1);\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n strm.adler = state.check = zswap32(hold);\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n return Z_NEED_DICT;\n }\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n //--- BYTEBITS() ---//\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n state.mode = CHECK;\n break;\n }\n //=== NEEDBITS(3); */\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.last = (hold & 0x01)/*BITS(1)*/;\n //--- DROPBITS(1) ---//\n hold >>>= 1;\n bits -= 1;\n //---//\n\n switch ((hold & 0x03)/*BITS(2)*/) {\n case 0: /* stored block */\n //Tracev((stderr, \"inflate: stored block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = STORED;\n break;\n case 1: /* fixed block */\n fixedtables(state);\n //Tracev((stderr, \"inflate: fixed codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = LEN_; /* decode codes */\n if (flush === Z_TREES) {\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break inf_leave;\n }\n break;\n case 2: /* dynamic block */\n //Tracev((stderr, \"inflate: dynamic codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = 'invalid block type';\n state.mode = BAD;\n }\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break;\n case STORED:\n //--- BYTEBITS() ---// /* go to byte boundary */\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n strm.msg = 'invalid stored block lengths';\n state.mode = BAD;\n break;\n }\n state.length = hold & 0xffff;\n //Tracev((stderr, \"inflate: stored length %u\\n\",\n // state.length));\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = COPY_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) { copy = have; }\n if (copy > left) { copy = left; }\n if (copy === 0) { break inf_leave; }\n //--- zmemcpy(put, next, copy); ---\n utils.arraySet(output, input, next, copy, put);\n //---//\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n //Tracev((stderr, \"inflate: stored end\\n\"));\n state.mode = TYPE;\n break;\n case TABLE:\n //=== NEEDBITS(14); */\n while (bits < 14) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n//#ifndef PKZIP_BUG_WORKAROUND\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = 'too many length or distance symbols';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracev((stderr, \"inflate: table sizes ok\\n\"));\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n //=== NEEDBITS(3);\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n // We have separate tables & no pointers. 2 commented lines below not needed.\n //state.next = state.codes;\n //state.lencode = state.next;\n // Switch to use dynamic table\n state.lencode = state.lendyn;\n state.lenbits = 7;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n\n if (ret) {\n strm.msg = 'invalid code lengths set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, \"inflate: code lengths ok\\n\"));\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_val < 16) {\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.lens[state.have++] = here_val;\n }\n else {\n if (here_val === 16) {\n //=== NEEDBITS(here.bits + 2);\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n if (state.have === 0) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 0x03);//BITS(2);\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n }\n else if (here_val === 17) {\n //=== NEEDBITS(here.bits + 3);\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 3 + (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n else {\n //=== NEEDBITS(here.bits + 7);\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 11 + (hold & 0x7f);//BITS(7);\n //--- DROPBITS(7) ---//\n hold >>>= 7;\n bits -= 7;\n //---//\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n\n /* handle error breaks in while */\n if (state.mode === BAD) { break; }\n\n /* check for end-of-block code (better have one) */\n if (state.lens[256] === 0) {\n strm.msg = 'invalid code -- missing end-of-block';\n state.mode = BAD;\n break;\n }\n\n /* build code tables -- note: do not change the lenbits or distbits\n values here (9 and 6) without reading the comments in inftrees.h\n concerning the ENOUGH constants, which depend on those values */\n state.lenbits = 9;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.lenbits = opts.bits;\n // state.lencode = state.next;\n\n if (ret) {\n strm.msg = 'invalid literal/lengths set';\n state.mode = BAD;\n break;\n }\n\n state.distbits = 6;\n //state.distcode.copy(state.codes);\n // Switch to use dynamic table\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.distbits = opts.bits;\n // state.distcode = state.next;\n\n if (ret) {\n strm.msg = 'invalid distances set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, 'inflate: codes ok\\n'));\n state.mode = LEN_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n inflate_fast(strm, _out);\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if (here_bits <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_op && (here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.lencode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", state.length));\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (;;) {\n here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if ((here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.distcode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = (here_op) & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n//#ifdef INFLATE_STRICT\n if (state.offset > state.dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracevv((stderr, \"inflate: distance %u\\n\", state.offset));\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) { break inf_leave; }\n copy = _out - left;\n if (state.offset > copy) { /* copy from window */\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n// (!) This block is disabled in zlib defaults,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// Trace((stderr, \"inflate.c too far\\n\"));\n// copy -= state.whave;\n// if (copy > state.length) { copy = state.length; }\n// if (copy > left) { copy = left; }\n// left -= copy;\n// state.length -= copy;\n// do {\n// output[put++] = 0;\n// } while (--copy);\n// if (state.length === 0) { state.mode = LEN; }\n// break;\n//#endif\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n }\n else {\n from = state.wnext - copy;\n }\n if (copy > state.length) { copy = state.length; }\n from_source = state.window;\n }\n else { /* copy from output */\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) { copy = left; }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) { state.mode = LEN; }\n break;\n case LIT:\n if (left === 0) { break inf_leave; }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n // Use '|' instead of '+' to make sure that result is signed\n hold |= input[next++] << bits;\n bits += 8;\n }\n //===//\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (_out) {\n strm.adler = state.check =\n /*UPDATE(state.check, put - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));\n\n }\n _out = left;\n // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = 'incorrect data check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: check matches trailer\\n\"));\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.total & 0xffffffff)) {\n strm.msg = 'incorrect length check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: length matches trailer\\n\"));\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR;\n }\n }\n\n // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n /*\n Return from inflate(), updating the total counts and the check value.\n If there was no progress during the inflate() call, return a buffer\n error. Call updatewindow() to create and/or update the window state.\n Note: a memory error from inflate() is non-recoverable.\n */\n\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n\n if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n (state.mode < CHECK || flush !== Z_FINISH))) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap && _out) {\n strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) +\n (state.mode === TYPE ? 128 : 0) +\n (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n}\n\nfunction inflateEnd(strm) {\n\n if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n return Z_STREAM_ERROR;\n }\n\n var state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK;\n}\n\nfunction inflateGetHeader(strm, head) {\n var state;\n\n /* check state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; }\n\n /* save header structure */\n state.head = head;\n head.done = false;\n return Z_OK;\n}\n\nfunction inflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var state;\n var dictid;\n var ret;\n\n /* check state */\n if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR;\n }\n\n /* check for correct dictionary identifier */\n if (state.mode === DICT) {\n dictid = 1; /* adler32(0, null, 0)*/\n /* dictid = adler32(dictid, dictionary, dictLength); */\n dictid = adler32(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR;\n }\n }\n /* copy dictionary to window using updatewindow(), which will amend the\n existing dictionary if appropriate */\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n state.havedict = 1;\n // Tracev((stderr, \"inflate: dictionary set\\n\"));\n return Z_OK;\n}\n\nexports.inflateReset = inflateReset;\nexports.inflateReset2 = inflateReset2;\nexports.inflateResetKeep = inflateResetKeep;\nexports.inflateInit = inflateInit;\nexports.inflateInit2 = inflateInit2;\nexports.inflate = inflate;\nexports.inflateEnd = inflateEnd;\nexports.inflateGetHeader = inflateGetHeader;\nexports.inflateSetDictionary = inflateSetDictionary;\nexports.inflateInfo = 'pako inflate (from Nodeca project)';\n\n/* Not implemented\nexports.inflateCopy = inflateCopy;\nexports.inflateGetDictionary = inflateGetDictionary;\nexports.inflateMark = inflateMark;\nexports.inflatePrime = inflatePrime;\nexports.inflateSync = inflateSync;\nexports.inflateSyncPoint = inflateSyncPoint;\nexports.inflateUndermine = inflateUndermine;\n*/\n","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar utils = require('../utils/common');\n\nvar MAXBITS = 15;\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\nvar lbase = [ /* Length codes 257..285 base */\n 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n];\n\nvar lext = [ /* Length codes 257..285 extra */\n 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n];\n\nvar dbase = [ /* Distance codes 0..29 base */\n 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n 8193, 12289, 16385, 24577, 0, 0\n];\n\nvar dext = [ /* Distance codes 0..29 extra */\n 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n 28, 28, 29, 29, 64, 64\n];\n\nmodule.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts)\n{\n var bits = opts.bits;\n //here = opts.here; /* table entry for duplication */\n\n var len = 0; /* a code's length in bits */\n var sym = 0; /* index of code symbols */\n var min = 0, max = 0; /* minimum and maximum code lengths */\n var root = 0; /* number of index bits for root table */\n var curr = 0; /* number of index bits for current table */\n var drop = 0; /* code bits to drop for sub-table */\n var left = 0; /* number of prefix codes available */\n var used = 0; /* code entries in table used */\n var huff = 0; /* Huffman code */\n var incr; /* for incrementing code, index */\n var fill; /* index for replicating entries */\n var low; /* low bits for current root entry */\n var mask; /* mask for low root bits */\n var next; /* next available space in table */\n var base = null; /* base value table to use */\n var base_index = 0;\n// var shoextra; /* extra bits table to use */\n var end; /* use base and extra for symbol > end */\n var count = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */\n var offs = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */\n var extra = null;\n var extra_index = 0;\n\n var here_bits, here_op, here_val;\n\n /*\n Process a set of code lengths to create a canonical Huffman code. The\n code lengths are lens[0..codes-1]. Each length corresponds to the\n symbols 0..codes-1. The Huffman code is generated by first sorting the\n symbols by length from short to long, and retaining the symbol order\n for codes with equal lengths. Then the code starts with all zero bits\n for the first code of the shortest length, and the codes are integer\n increments for the same length, and zeros are appended as the length\n increases. For the deflate format, these bits are stored backwards\n from their more natural integer increment ordering, and so when the\n decoding tables are built in the large loop below, the integer codes\n are incremented backwards.\n\n This routine assumes, but does not check, that all of the entries in\n lens[] are in the range 0..MAXBITS. The caller must assure this.\n 1..MAXBITS is interpreted as that code length. zero means that that\n symbol does not occur in this code.\n\n The codes are sorted by computing a count of codes for each length,\n creating from that a table of starting indices for each length in the\n sorted table, and then entering the symbols in order in the sorted\n table. The sorted table is work[], with that space being provided by\n the caller.\n\n The length counts are used for other purposes as well, i.e. finding\n the minimum and maximum length codes, determining if there are any\n codes at all, checking for a valid set of lengths, and looking ahead\n at length counts to determine sub-table sizes when building the\n decoding tables.\n */\n\n /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n\n /* bound code lengths, force root to be within code lengths */\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) { break; }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) { /* no symbols to code at all */\n //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n //table.op[opts.table_index] = 64;\n //table.bits[opts.table_index] = 1;\n //table.val[opts.table_index++] = 0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n opts.bits = 1;\n return 0; /* no symbols, but wait for decoding to report error */\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) { break; }\n }\n if (root < min) {\n root = min;\n }\n\n /* check for an over-subscribed or incomplete set of lengths */\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n } /* over-subscribed */\n }\n if (left > 0 && (type === CODES || max !== 1)) {\n return -1; /* incomplete set */\n }\n\n /* generate offsets into symbol table for each length for sorting */\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n\n /* sort symbols by length, by symbol order within each length */\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n\n /*\n Create and fill in decoding tables. In this loop, the table being\n filled is at next and has curr index bits. The code being used is huff\n with length len. That code is converted to an index by dropping drop\n bits off of the bottom. For codes where len is less than drop + curr,\n those top drop + curr - len bits are incremented through all values to\n fill the table with replicated entries.\n\n root is the number of index bits for the root table. When len exceeds\n root, sub-tables are created pointed to by the root entry with an index\n of the low root bits of huff. This is saved in low to check for when a\n new sub-table should be started. drop is zero when the root table is\n being filled, and drop is root when sub-tables are being filled.\n\n When a new sub-table is needed, it is necessary to look ahead in the\n code lengths to determine what size sub-table is needed. The length\n counts are used for this, and so count[] is decremented as codes are\n entered in the tables.\n\n used keeps track of how many table entries have been allocated from the\n provided *table space. It is checked for LENS and DIST tables against\n the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n the initial root table size constants. See the comments in inftrees.h\n for more information.\n\n sym increments through all symbols, and the loop terminates when\n all codes of length max, i.e. all codes, have been processed. This\n routine permits incomplete codes, so another loop after this one fills\n in the rest of the decoding tables with invalid code markers.\n */\n\n /* set up for code type */\n // poor man optimization - use if-else instead of switch,\n // to avoid deopts in old v8\n if (type === CODES) {\n base = extra = work; /* dummy value--not used */\n end = 19;\n\n } else if (type === LENS) {\n base = lbase;\n base_index -= 257;\n extra = lext;\n extra_index -= 257;\n end = 256;\n\n } else { /* DISTS */\n base = dbase;\n extra = dext;\n end = -1;\n }\n\n /* initialize opts for loop */\n huff = 0; /* starting code */\n sym = 0; /* starting code symbol */\n len = min; /* starting code length */\n next = table_index; /* current table to fill in */\n curr = root; /* current table index bits */\n drop = 0; /* current bits to drop from code for index */\n low = -1; /* trigger new sub-table when len > root */\n used = 1 << root; /* use root table entries */\n mask = used - 1; /* mask for comparing low */\n\n /* check available table space */\n if ((type === LENS && used > ENOUGH_LENS) ||\n (type === DISTS && used > ENOUGH_DISTS)) {\n return 1;\n }\n\n /* process all codes and make table entries */\n for (;;) {\n /* create table entry */\n here_bits = len - drop;\n if (work[sym] < end) {\n here_op = 0;\n here_val = work[sym];\n }\n else if (work[sym] > end) {\n here_op = extra[extra_index + work[sym]];\n here_val = base[base_index + work[sym]];\n }\n else {\n here_op = 32 + 64; /* end of block */\n here_val = 0;\n }\n\n /* replicate for those indices with low len bits equal to huff */\n incr = 1 << (len - drop);\n fill = 1 << curr;\n min = fill; /* save offset to next table */\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n } while (fill !== 0);\n\n /* backwards increment the len-bit code huff */\n incr = 1 << (len - 1);\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n\n /* go to next symbol, update count, len */\n sym++;\n if (--count[len] === 0) {\n if (len === max) { break; }\n len = lens[lens_index + work[sym]];\n }\n\n /* create new sub-table if needed */\n if (len > root && (huff & mask) !== low) {\n /* if first time, transition to sub-tables */\n if (drop === 0) {\n drop = root;\n }\n\n /* increment past last table */\n next += min; /* here min is 1 << curr */\n\n /* determine length of next table */\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) { break; }\n curr++;\n left <<= 1;\n }\n\n /* check for enough space */\n used += 1 << curr;\n if ((type === LENS && used > ENOUGH_LENS) ||\n (type === DISTS && used > ENOUGH_DISTS)) {\n return 1;\n }\n\n /* point entry in root table to sub-table */\n low = huff & mask;\n /*table.op[low] = curr;\n table.bits[low] = root;\n table.val[low] = next - opts.table_index;*/\n table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n }\n }\n\n /* fill in remaining table entry if code is incomplete (guaranteed to have\n at most one remaining entry, since if the code is incomplete, the\n maximum code length that was allowed to get this far is one bit) */\n if (huff !== 0) {\n //table.op[next + huff] = 64; /* invalid code marker */\n //table.bits[next + huff] = len - drop;\n //table.val[next + huff] = 0;\n table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n }\n\n /* set return parameters */\n //opts.table_index += used;\n opts.bits = root;\n return 0;\n};\n","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nmodule.exports = {\n 2: 'need dictionary', /* Z_NEED_DICT 2 */\n 1: 'stream end', /* Z_STREAM_END 1 */\n 0: '', /* Z_OK 0 */\n '-1': 'file error', /* Z_ERRNO (-1) */\n '-2': 'stream error', /* Z_STREAM_ERROR (-2) */\n '-3': 'data error', /* Z_DATA_ERROR (-3) */\n '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */\n '-5': 'buffer error', /* Z_BUF_ERROR (-5) */\n '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */\n};\n","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\n/* eslint-disable space-unary-ops */\n\nvar utils = require('../utils/common');\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n//var Z_FILTERED = 1;\n//var Z_HUFFMAN_ONLY = 2;\n//var Z_RLE = 3;\nvar Z_FIXED = 4;\n//var Z_DEFAULT_STRATEGY = 0;\n\n/* Possible values of the data_type field (though see inflate()) */\nvar Z_BINARY = 0;\nvar Z_TEXT = 1;\n//var Z_ASCII = 1; // = Z_TEXT\nvar Z_UNKNOWN = 2;\n\n/*============================================================================*/\n\n\nfunction zero(buf) { var len = buf.length; while (--len >= 0) { buf[len] = 0; } }\n\n// From zutil.h\n\nvar STORED_BLOCK = 0;\nvar STATIC_TREES = 1;\nvar DYN_TREES = 2;\n/* The three kinds of block type */\n\nvar MIN_MATCH = 3;\nvar MAX_MATCH = 258;\n/* The minimum and maximum match lengths */\n\n// From deflate.h\n/* ===========================================================================\n * Internal compression state.\n */\n\nvar LENGTH_CODES = 29;\n/* number of length codes, not counting the special END_BLOCK code */\n\nvar LITERALS = 256;\n/* number of literal bytes 0..255 */\n\nvar L_CODES = LITERALS + 1 + LENGTH_CODES;\n/* number of Literal or Length codes, including the END_BLOCK code */\n\nvar D_CODES = 30;\n/* number of distance codes */\n\nvar BL_CODES = 19;\n/* number of codes used to transfer the bit lengths */\n\nvar HEAP_SIZE = 2 * L_CODES + 1;\n/* maximum heap size */\n\nvar MAX_BITS = 15;\n/* All codes must not exceed MAX_BITS bits */\n\nvar Buf_size = 16;\n/* size of bit buffer in bi_buf */\n\n\n/* ===========================================================================\n * Constants\n */\n\nvar MAX_BL_BITS = 7;\n/* Bit length codes must not exceed MAX_BL_BITS bits */\n\nvar END_BLOCK = 256;\n/* end of block literal code */\n\nvar REP_3_6 = 16;\n/* repeat previous bit length 3-6 times (2 bits of repeat count) */\n\nvar REPZ_3_10 = 17;\n/* repeat a zero length 3-10 times (3 bits of repeat count) */\n\nvar REPZ_11_138 = 18;\n/* repeat a zero length 11-138 times (7 bits of repeat count) */\n\n/* eslint-disable comma-spacing,array-bracket-spacing */\nvar extra_lbits = /* extra bits for each length code */\n [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];\n\nvar extra_dbits = /* extra bits for each distance code */\n [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];\n\nvar extra_blbits = /* extra bits for each bit length code */\n [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7];\n\nvar bl_order =\n [16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];\n/* eslint-enable comma-spacing,array-bracket-spacing */\n\n/* The lengths of the bit length codes are sent in order of decreasing\n * probability, to avoid transmitting the lengths for unused bit length codes.\n */\n\n/* ===========================================================================\n * Local data. These are initialized only once.\n */\n\n// We pre-fill arrays with 0 to avoid uninitialized gaps\n\nvar DIST_CODE_LEN = 512; /* see definition of array dist_code below */\n\n// !!!! Use flat array instead of structure, Freq = i*2, Len = i*2+1\nvar static_ltree = new Array((L_CODES + 2) * 2);\nzero(static_ltree);\n/* The static literal tree. Since the bit lengths are imposed, there is no\n * need for the L_CODES extra codes used during heap construction. However\n * The codes 286 and 287 are needed to build a canonical tree (see _tr_init\n * below).\n */\n\nvar static_dtree = new Array(D_CODES * 2);\nzero(static_dtree);\n/* The static distance tree. (Actually a trivial tree since all codes use\n * 5 bits.)\n */\n\nvar _dist_code = new Array(DIST_CODE_LEN);\nzero(_dist_code);\n/* Distance codes. The first 256 values correspond to the distances\n * 3 .. 258, the last 256 values correspond to the top 8 bits of\n * the 15 bit distances.\n */\n\nvar _length_code = new Array(MAX_MATCH - MIN_MATCH + 1);\nzero(_length_code);\n/* length code for each normalized match length (0 == MIN_MATCH) */\n\nvar base_length = new Array(LENGTH_CODES);\nzero(base_length);\n/* First normalized length for each code (0 = MIN_MATCH) */\n\nvar base_dist = new Array(D_CODES);\nzero(base_dist);\n/* First normalized distance for each code (0 = distance of 1) */\n\n\nfunction StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) {\n\n this.static_tree = static_tree; /* static tree or NULL */\n this.extra_bits = extra_bits; /* extra bits for each code or NULL */\n this.extra_base = extra_base; /* base index for extra_bits */\n this.elems = elems; /* max number of elements in the tree */\n this.max_length = max_length; /* max bit length for the codes */\n\n // show if `static_tree` has data or dummy - needed for monomorphic objects\n this.has_stree = static_tree && static_tree.length;\n}\n\n\nvar static_l_desc;\nvar static_d_desc;\nvar static_bl_desc;\n\n\nfunction TreeDesc(dyn_tree, stat_desc) {\n this.dyn_tree = dyn_tree; /* the dynamic tree */\n this.max_code = 0; /* largest code with non zero frequency */\n this.stat_desc = stat_desc; /* the corresponding static tree */\n}\n\n\n\nfunction d_code(dist) {\n return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)];\n}\n\n\n/* ===========================================================================\n * Output a short LSB first on the stream.\n * IN assertion: there is enough room in pendingBuf.\n */\nfunction put_short(s, w) {\n// put_byte(s, (uch)((w) & 0xff));\n// put_byte(s, (uch)((ush)(w) >> 8));\n s.pending_buf[s.pending++] = (w) & 0xff;\n s.pending_buf[s.pending++] = (w >>> 8) & 0xff;\n}\n\n\n/* ===========================================================================\n * Send a value on a given number of bits.\n * IN assertion: length <= 16 and value fits in length bits.\n */\nfunction send_bits(s, value, length) {\n if (s.bi_valid > (Buf_size - length)) {\n s.bi_buf |= (value << s.bi_valid) & 0xffff;\n put_short(s, s.bi_buf);\n s.bi_buf = value >> (Buf_size - s.bi_valid);\n s.bi_valid += length - Buf_size;\n } else {\n s.bi_buf |= (value << s.bi_valid) & 0xffff;\n s.bi_valid += length;\n }\n}\n\n\nfunction send_code(s, c, tree) {\n send_bits(s, tree[c * 2]/*.Code*/, tree[c * 2 + 1]/*.Len*/);\n}\n\n\n/* ===========================================================================\n * Reverse the first len bits of a code, using straightforward code (a faster\n * method would use a table)\n * IN assertion: 1 <= len <= 15\n */\nfunction bi_reverse(code, len) {\n var res = 0;\n do {\n res |= code & 1;\n code >>>= 1;\n res <<= 1;\n } while (--len > 0);\n return res >>> 1;\n}\n\n\n/* ===========================================================================\n * Flush the bit buffer, keeping at most 7 bits in it.\n */\nfunction bi_flush(s) {\n if (s.bi_valid === 16) {\n put_short(s, s.bi_buf);\n s.bi_buf = 0;\n s.bi_valid = 0;\n\n } else if (s.bi_valid >= 8) {\n s.pending_buf[s.pending++] = s.bi_buf & 0xff;\n s.bi_buf >>= 8;\n s.bi_valid -= 8;\n }\n}\n\n\n/* ===========================================================================\n * Compute the optimal bit lengths for a tree and update the total bit length\n * for the current block.\n * IN assertion: the fields freq and dad are set, heap[heap_max] and\n * above are the tree nodes sorted by increasing frequency.\n * OUT assertions: the field len is set to the optimal bit length, the\n * array bl_count contains the frequencies for each bit length.\n * The length opt_len is updated; static_len is also updated if stree is\n * not null.\n */\nfunction gen_bitlen(s, desc)\n// deflate_state *s;\n// tree_desc *desc; /* the tree descriptor */\n{\n var tree = desc.dyn_tree;\n var max_code = desc.max_code;\n var stree = desc.stat_desc.static_tree;\n var has_stree = desc.stat_desc.has_stree;\n var extra = desc.stat_desc.extra_bits;\n var base = desc.stat_desc.extra_base;\n var max_length = desc.stat_desc.max_length;\n var h; /* heap index */\n var n, m; /* iterate over the tree elements */\n var bits; /* bit length */\n var xbits; /* extra bits */\n var f; /* frequency */\n var overflow = 0; /* number of elements with bit length too large */\n\n for (bits = 0; bits <= MAX_BITS; bits++) {\n s.bl_count[bits] = 0;\n }\n\n /* In a first pass, compute the optimal bit lengths (which may\n * overflow in the case of the bit length tree).\n */\n tree[s.heap[s.heap_max] * 2 + 1]/*.Len*/ = 0; /* root of the heap */\n\n for (h = s.heap_max + 1; h < HEAP_SIZE; h++) {\n n = s.heap[h];\n bits = tree[tree[n * 2 + 1]/*.Dad*/ * 2 + 1]/*.Len*/ + 1;\n if (bits > max_length) {\n bits = max_length;\n overflow++;\n }\n tree[n * 2 + 1]/*.Len*/ = bits;\n /* We overwrite tree[n].Dad which is no longer needed */\n\n if (n > max_code) { continue; } /* not a leaf node */\n\n s.bl_count[bits]++;\n xbits = 0;\n if (n >= base) {\n xbits = extra[n - base];\n }\n f = tree[n * 2]/*.Freq*/;\n s.opt_len += f * (bits + xbits);\n if (has_stree) {\n s.static_len += f * (stree[n * 2 + 1]/*.Len*/ + xbits);\n }\n }\n if (overflow === 0) { return; }\n\n // Trace((stderr,\"\\nbit length overflow\\n\"));\n /* This happens for example on obj2 and pic of the Calgary corpus */\n\n /* Find the first bit length which could increase: */\n do {\n bits = max_length - 1;\n while (s.bl_count[bits] === 0) { bits--; }\n s.bl_count[bits]--; /* move one leaf down the tree */\n s.bl_count[bits + 1] += 2; /* move one overflow item as its brother */\n s.bl_count[max_length]--;\n /* The brother of the overflow item also moves one step up,\n * but this does not affect bl_count[max_length]\n */\n overflow -= 2;\n } while (overflow > 0);\n\n /* Now recompute all bit lengths, scanning in increasing frequency.\n * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all\n * lengths instead of fixing only the wrong ones. This idea is taken\n * from 'ar' written by Haruhiko Okumura.)\n */\n for (bits = max_length; bits !== 0; bits--) {\n n = s.bl_count[bits];\n while (n !== 0) {\n m = s.heap[--h];\n if (m > max_code) { continue; }\n if (tree[m * 2 + 1]/*.Len*/ !== bits) {\n // Trace((stderr,\"code %d bits %d->%d\\n\", m, tree[m].Len, bits));\n s.opt_len += (bits - tree[m * 2 + 1]/*.Len*/) * tree[m * 2]/*.Freq*/;\n tree[m * 2 + 1]/*.Len*/ = bits;\n }\n n--;\n }\n }\n}\n\n\n/* ===========================================================================\n * Generate the codes for a given tree and bit counts (which need not be\n * optimal).\n * IN assertion: the array bl_count contains the bit length statistics for\n * the given tree and the field len is set for all tree elements.\n * OUT assertion: the field code is set for all tree elements of non\n * zero code length.\n */\nfunction gen_codes(tree, max_code, bl_count)\n// ct_data *tree; /* the tree to decorate */\n// int max_code; /* largest code with non zero frequency */\n// ushf *bl_count; /* number of codes at each bit length */\n{\n var next_code = new Array(MAX_BITS + 1); /* next code value for each bit length */\n var code = 0; /* running code value */\n var bits; /* bit index */\n var n; /* code index */\n\n /* The distribution counts are first used to generate the code values\n * without bit reversal.\n */\n for (bits = 1; bits <= MAX_BITS; bits++) {\n next_code[bits] = code = (code + bl_count[bits - 1]) << 1;\n }\n /* Check that the bit counts in bl_count are consistent. The last code\n * must be all ones.\n */\n //Assert (code + bl_count[MAX_BITS]-1 == (1< length code (0..28) */\n length = 0;\n for (code = 0; code < LENGTH_CODES - 1; code++) {\n base_length[code] = length;\n for (n = 0; n < (1 << extra_lbits[code]); n++) {\n _length_code[length++] = code;\n }\n }\n //Assert (length == 256, \"tr_static_init: length != 256\");\n /* Note that the length 255 (match length 258) can be represented\n * in two different ways: code 284 + 5 bits or code 285, so we\n * overwrite length_code[255] to use the best encoding:\n */\n _length_code[length - 1] = code;\n\n /* Initialize the mapping dist (0..32K) -> dist code (0..29) */\n dist = 0;\n for (code = 0; code < 16; code++) {\n base_dist[code] = dist;\n for (n = 0; n < (1 << extra_dbits[code]); n++) {\n _dist_code[dist++] = code;\n }\n }\n //Assert (dist == 256, \"tr_static_init: dist != 256\");\n dist >>= 7; /* from now on, all distances are divided by 128 */\n for (; code < D_CODES; code++) {\n base_dist[code] = dist << 7;\n for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) {\n _dist_code[256 + dist++] = code;\n }\n }\n //Assert (dist == 256, \"tr_static_init: 256+dist != 512\");\n\n /* Construct the codes of the static literal tree */\n for (bits = 0; bits <= MAX_BITS; bits++) {\n bl_count[bits] = 0;\n }\n\n n = 0;\n while (n <= 143) {\n static_ltree[n * 2 + 1]/*.Len*/ = 8;\n n++;\n bl_count[8]++;\n }\n while (n <= 255) {\n static_ltree[n * 2 + 1]/*.Len*/ = 9;\n n++;\n bl_count[9]++;\n }\n while (n <= 279) {\n static_ltree[n * 2 + 1]/*.Len*/ = 7;\n n++;\n bl_count[7]++;\n }\n while (n <= 287) {\n static_ltree[n * 2 + 1]/*.Len*/ = 8;\n n++;\n bl_count[8]++;\n }\n /* Codes 286 and 287 do not exist, but we must include them in the\n * tree construction to get a canonical Huffman tree (longest code\n * all ones)\n */\n gen_codes(static_ltree, L_CODES + 1, bl_count);\n\n /* The static distance tree is trivial: */\n for (n = 0; n < D_CODES; n++) {\n static_dtree[n * 2 + 1]/*.Len*/ = 5;\n static_dtree[n * 2]/*.Code*/ = bi_reverse(n, 5);\n }\n\n // Now data ready and we can init static trees\n static_l_desc = new StaticTreeDesc(static_ltree, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS);\n static_d_desc = new StaticTreeDesc(static_dtree, extra_dbits, 0, D_CODES, MAX_BITS);\n static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS);\n\n //static_init_done = true;\n}\n\n\n/* ===========================================================================\n * Initialize a new block.\n */\nfunction init_block(s) {\n var n; /* iterates over tree elements */\n\n /* Initialize the trees. */\n for (n = 0; n < L_CODES; n++) { s.dyn_ltree[n * 2]/*.Freq*/ = 0; }\n for (n = 0; n < D_CODES; n++) { s.dyn_dtree[n * 2]/*.Freq*/ = 0; }\n for (n = 0; n < BL_CODES; n++) { s.bl_tree[n * 2]/*.Freq*/ = 0; }\n\n s.dyn_ltree[END_BLOCK * 2]/*.Freq*/ = 1;\n s.opt_len = s.static_len = 0;\n s.last_lit = s.matches = 0;\n}\n\n\n/* ===========================================================================\n * Flush the bit buffer and align the output on a byte boundary\n */\nfunction bi_windup(s)\n{\n if (s.bi_valid > 8) {\n put_short(s, s.bi_buf);\n } else if (s.bi_valid > 0) {\n //put_byte(s, (Byte)s->bi_buf);\n s.pending_buf[s.pending++] = s.bi_buf;\n }\n s.bi_buf = 0;\n s.bi_valid = 0;\n}\n\n/* ===========================================================================\n * Copy a stored block, storing first the length and its\n * one's complement if requested.\n */\nfunction copy_block(s, buf, len, header)\n//DeflateState *s;\n//charf *buf; /* the input data */\n//unsigned len; /* its length */\n//int header; /* true if block header must be written */\n{\n bi_windup(s); /* align on byte boundary */\n\n if (header) {\n put_short(s, len);\n put_short(s, ~len);\n }\n// while (len--) {\n// put_byte(s, *buf++);\n// }\n utils.arraySet(s.pending_buf, s.window, buf, len, s.pending);\n s.pending += len;\n}\n\n/* ===========================================================================\n * Compares to subtrees, using the tree depth as tie breaker when\n * the subtrees have equal frequency. This minimizes the worst case length.\n */\nfunction smaller(tree, n, m, depth) {\n var _n2 = n * 2;\n var _m2 = m * 2;\n return (tree[_n2]/*.Freq*/ < tree[_m2]/*.Freq*/ ||\n (tree[_n2]/*.Freq*/ === tree[_m2]/*.Freq*/ && depth[n] <= depth[m]));\n}\n\n/* ===========================================================================\n * Restore the heap property by moving down the tree starting at node k,\n * exchanging a node with the smallest of its two sons if necessary, stopping\n * when the heap property is re-established (each father smaller than its\n * two sons).\n */\nfunction pqdownheap(s, tree, k)\n// deflate_state *s;\n// ct_data *tree; /* the tree to restore */\n// int k; /* node to move down */\n{\n var v = s.heap[k];\n var j = k << 1; /* left son of k */\n while (j <= s.heap_len) {\n /* Set j to the smallest of the two sons: */\n if (j < s.heap_len &&\n smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) {\n j++;\n }\n /* Exit if v is smaller than both sons */\n if (smaller(tree, v, s.heap[j], s.depth)) { break; }\n\n /* Exchange v with the smallest son */\n s.heap[k] = s.heap[j];\n k = j;\n\n /* And continue down the tree, setting j to the left son of k */\n j <<= 1;\n }\n s.heap[k] = v;\n}\n\n\n// inlined manually\n// var SMALLEST = 1;\n\n/* ===========================================================================\n * Send the block data compressed using the given Huffman trees\n */\nfunction compress_block(s, ltree, dtree)\n// deflate_state *s;\n// const ct_data *ltree; /* literal tree */\n// const ct_data *dtree; /* distance tree */\n{\n var dist; /* distance of matched string */\n var lc; /* match length or unmatched char (if dist == 0) */\n var lx = 0; /* running index in l_buf */\n var code; /* the code to send */\n var extra; /* number of extra bits to send */\n\n if (s.last_lit !== 0) {\n do {\n dist = (s.pending_buf[s.d_buf + lx * 2] << 8) | (s.pending_buf[s.d_buf + lx * 2 + 1]);\n lc = s.pending_buf[s.l_buf + lx];\n lx++;\n\n if (dist === 0) {\n send_code(s, lc, ltree); /* send a literal byte */\n //Tracecv(isgraph(lc), (stderr,\" '%c' \", lc));\n } else {\n /* Here, lc is the match length - MIN_MATCH */\n code = _length_code[lc];\n send_code(s, code + LITERALS + 1, ltree); /* send the length code */\n extra = extra_lbits[code];\n if (extra !== 0) {\n lc -= base_length[code];\n send_bits(s, lc, extra); /* send the extra length bits */\n }\n dist--; /* dist is now the match distance - 1 */\n code = d_code(dist);\n //Assert (code < D_CODES, \"bad d_code\");\n\n send_code(s, code, dtree); /* send the distance code */\n extra = extra_dbits[code];\n if (extra !== 0) {\n dist -= base_dist[code];\n send_bits(s, dist, extra); /* send the extra distance bits */\n }\n } /* literal or match pair ? */\n\n /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */\n //Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,\n // \"pendingBuf overflow\");\n\n } while (lx < s.last_lit);\n }\n\n send_code(s, END_BLOCK, ltree);\n}\n\n\n/* ===========================================================================\n * Construct one Huffman tree and assigns the code bit strings and lengths.\n * Update the total bit length for the current block.\n * IN assertion: the field freq is set for all tree elements.\n * OUT assertions: the fields len and code are set to the optimal bit length\n * and corresponding code. The length opt_len is updated; static_len is\n * also updated if stree is not null. The field max_code is set.\n */\nfunction build_tree(s, desc)\n// deflate_state *s;\n// tree_desc *desc; /* the tree descriptor */\n{\n var tree = desc.dyn_tree;\n var stree = desc.stat_desc.static_tree;\n var has_stree = desc.stat_desc.has_stree;\n var elems = desc.stat_desc.elems;\n var n, m; /* iterate over heap elements */\n var max_code = -1; /* largest code with non zero frequency */\n var node; /* new node being created */\n\n /* Construct the initial heap, with least frequent element in\n * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].\n * heap[0] is not used.\n */\n s.heap_len = 0;\n s.heap_max = HEAP_SIZE;\n\n for (n = 0; n < elems; n++) {\n if (tree[n * 2]/*.Freq*/ !== 0) {\n s.heap[++s.heap_len] = max_code = n;\n s.depth[n] = 0;\n\n } else {\n tree[n * 2 + 1]/*.Len*/ = 0;\n }\n }\n\n /* The pkzip format requires that at least one distance code exists,\n * and that at least one bit should be sent even if there is only one\n * possible code. So to avoid special checks later on we force at least\n * two codes of non zero frequency.\n */\n while (s.heap_len < 2) {\n node = s.heap[++s.heap_len] = (max_code < 2 ? ++max_code : 0);\n tree[node * 2]/*.Freq*/ = 1;\n s.depth[node] = 0;\n s.opt_len--;\n\n if (has_stree) {\n s.static_len -= stree[node * 2 + 1]/*.Len*/;\n }\n /* node is 0 or 1 so it does not have extra bits */\n }\n desc.max_code = max_code;\n\n /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,\n * establish sub-heaps of increasing lengths:\n */\n for (n = (s.heap_len >> 1/*int /2*/); n >= 1; n--) { pqdownheap(s, tree, n); }\n\n /* Construct the Huffman tree by repeatedly combining the least two\n * frequent nodes.\n */\n node = elems; /* next internal node of the tree */\n do {\n //pqremove(s, tree, n); /* n = node of least frequency */\n /*** pqremove ***/\n n = s.heap[1/*SMALLEST*/];\n s.heap[1/*SMALLEST*/] = s.heap[s.heap_len--];\n pqdownheap(s, tree, 1/*SMALLEST*/);\n /***/\n\n m = s.heap[1/*SMALLEST*/]; /* m = node of next least frequency */\n\n s.heap[--s.heap_max] = n; /* keep the nodes sorted by frequency */\n s.heap[--s.heap_max] = m;\n\n /* Create a new node father of n and m */\n tree[node * 2]/*.Freq*/ = tree[n * 2]/*.Freq*/ + tree[m * 2]/*.Freq*/;\n s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1;\n tree[n * 2 + 1]/*.Dad*/ = tree[m * 2 + 1]/*.Dad*/ = node;\n\n /* and insert the new node in the heap */\n s.heap[1/*SMALLEST*/] = node++;\n pqdownheap(s, tree, 1/*SMALLEST*/);\n\n } while (s.heap_len >= 2);\n\n s.heap[--s.heap_max] = s.heap[1/*SMALLEST*/];\n\n /* At this point, the fields freq and dad are set. We can now\n * generate the bit lengths.\n */\n gen_bitlen(s, desc);\n\n /* The field len is now set, we can generate the bit codes */\n gen_codes(tree, max_code, s.bl_count);\n}\n\n\n/* ===========================================================================\n * Scan a literal or distance tree to determine the frequencies of the codes\n * in the bit length tree.\n */\nfunction scan_tree(s, tree, max_code)\n// deflate_state *s;\n// ct_data *tree; /* the tree to be scanned */\n// int max_code; /* and its largest code of non zero frequency */\n{\n var n; /* iterates over all tree elements */\n var prevlen = -1; /* last emitted length */\n var curlen; /* length of current code */\n\n var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */\n\n var count = 0; /* repeat count of the current code */\n var max_count = 7; /* max repeat count */\n var min_count = 4; /* min repeat count */\n\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n tree[(max_code + 1) * 2 + 1]/*.Len*/ = 0xffff; /* guard */\n\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1]/*.Len*/;\n\n if (++count < max_count && curlen === nextlen) {\n continue;\n\n } else if (count < min_count) {\n s.bl_tree[curlen * 2]/*.Freq*/ += count;\n\n } else if (curlen !== 0) {\n\n if (curlen !== prevlen) { s.bl_tree[curlen * 2]/*.Freq*/++; }\n s.bl_tree[REP_3_6 * 2]/*.Freq*/++;\n\n } else if (count <= 10) {\n s.bl_tree[REPZ_3_10 * 2]/*.Freq*/++;\n\n } else {\n s.bl_tree[REPZ_11_138 * 2]/*.Freq*/++;\n }\n\n count = 0;\n prevlen = curlen;\n\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n}\n\n\n/* ===========================================================================\n * Send a literal or distance tree in compressed form, using the codes in\n * bl_tree.\n */\nfunction send_tree(s, tree, max_code)\n// deflate_state *s;\n// ct_data *tree; /* the tree to be scanned */\n// int max_code; /* and its largest code of non zero frequency */\n{\n var n; /* iterates over all tree elements */\n var prevlen = -1; /* last emitted length */\n var curlen; /* length of current code */\n\n var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */\n\n var count = 0; /* repeat count of the current code */\n var max_count = 7; /* max repeat count */\n var min_count = 4; /* min repeat count */\n\n /* tree[max_code+1].Len = -1; */ /* guard already set */\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1]/*.Len*/;\n\n if (++count < max_count && curlen === nextlen) {\n continue;\n\n } else if (count < min_count) {\n do { send_code(s, curlen, s.bl_tree); } while (--count !== 0);\n\n } else if (curlen !== 0) {\n if (curlen !== prevlen) {\n send_code(s, curlen, s.bl_tree);\n count--;\n }\n //Assert(count >= 3 && count <= 6, \" 3_6?\");\n send_code(s, REP_3_6, s.bl_tree);\n send_bits(s, count - 3, 2);\n\n } else if (count <= 10) {\n send_code(s, REPZ_3_10, s.bl_tree);\n send_bits(s, count - 3, 3);\n\n } else {\n send_code(s, REPZ_11_138, s.bl_tree);\n send_bits(s, count - 11, 7);\n }\n\n count = 0;\n prevlen = curlen;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n}\n\n\n/* ===========================================================================\n * Construct the Huffman tree for the bit lengths and return the index in\n * bl_order of the last bit length code to send.\n */\nfunction build_bl_tree(s) {\n var max_blindex; /* index of last bit length code of non zero freq */\n\n /* Determine the bit length frequencies for literal and distance trees */\n scan_tree(s, s.dyn_ltree, s.l_desc.max_code);\n scan_tree(s, s.dyn_dtree, s.d_desc.max_code);\n\n /* Build the bit length tree: */\n build_tree(s, s.bl_desc);\n /* opt_len now includes the length of the tree representations, except\n * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.\n */\n\n /* Determine the number of bit length codes to send. The pkzip format\n * requires that at least 4 bit length codes be sent. (appnote.txt says\n * 3 but the actual value used is 4.)\n */\n for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) {\n if (s.bl_tree[bl_order[max_blindex] * 2 + 1]/*.Len*/ !== 0) {\n break;\n }\n }\n /* Update opt_len to include the bit length tree and counts */\n s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4;\n //Tracev((stderr, \"\\ndyn trees: dyn %ld, stat %ld\",\n // s->opt_len, s->static_len));\n\n return max_blindex;\n}\n\n\n/* ===========================================================================\n * Send the header for a block using dynamic Huffman trees: the counts, the\n * lengths of the bit length codes, the literal tree and the distance tree.\n * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.\n */\nfunction send_all_trees(s, lcodes, dcodes, blcodes)\n// deflate_state *s;\n// int lcodes, dcodes, blcodes; /* number of codes for each tree */\n{\n var rank; /* index in bl_order */\n\n //Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, \"not enough codes\");\n //Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,\n // \"too many codes\");\n //Tracev((stderr, \"\\nbl counts: \"));\n send_bits(s, lcodes - 257, 5); /* not +255 as stated in appnote.txt */\n send_bits(s, dcodes - 1, 5);\n send_bits(s, blcodes - 4, 4); /* not -3 as stated in appnote.txt */\n for (rank = 0; rank < blcodes; rank++) {\n //Tracev((stderr, \"\\nbl code %2d \", bl_order[rank]));\n send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1]/*.Len*/, 3);\n }\n //Tracev((stderr, \"\\nbl tree: sent %ld\", s->bits_sent));\n\n send_tree(s, s.dyn_ltree, lcodes - 1); /* literal tree */\n //Tracev((stderr, \"\\nlit tree: sent %ld\", s->bits_sent));\n\n send_tree(s, s.dyn_dtree, dcodes - 1); /* distance tree */\n //Tracev((stderr, \"\\ndist tree: sent %ld\", s->bits_sent));\n}\n\n\n/* ===========================================================================\n * Check if the data type is TEXT or BINARY, using the following algorithm:\n * - TEXT if the two conditions below are satisfied:\n * a) There are no non-portable control characters belonging to the\n * \"black list\" (0..6, 14..25, 28..31).\n * b) There is at least one printable character belonging to the\n * \"white list\" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).\n * - BINARY otherwise.\n * - The following partially-portable control characters form a\n * \"gray list\" that is ignored in this detection algorithm:\n * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).\n * IN assertion: the fields Freq of dyn_ltree are set.\n */\nfunction detect_data_type(s) {\n /* black_mask is the bit mask of black-listed bytes\n * set bits 0..6, 14..25, and 28..31\n * 0xf3ffc07f = binary 11110011111111111100000001111111\n */\n var black_mask = 0xf3ffc07f;\n var n;\n\n /* Check for non-textual (\"black-listed\") bytes. */\n for (n = 0; n <= 31; n++, black_mask >>>= 1) {\n if ((black_mask & 1) && (s.dyn_ltree[n * 2]/*.Freq*/ !== 0)) {\n return Z_BINARY;\n }\n }\n\n /* Check for textual (\"white-listed\") bytes. */\n if (s.dyn_ltree[9 * 2]/*.Freq*/ !== 0 || s.dyn_ltree[10 * 2]/*.Freq*/ !== 0 ||\n s.dyn_ltree[13 * 2]/*.Freq*/ !== 0) {\n return Z_TEXT;\n }\n for (n = 32; n < LITERALS; n++) {\n if (s.dyn_ltree[n * 2]/*.Freq*/ !== 0) {\n return Z_TEXT;\n }\n }\n\n /* There are no \"black-listed\" or \"white-listed\" bytes:\n * this stream either is empty or has tolerated (\"gray-listed\") bytes only.\n */\n return Z_BINARY;\n}\n\n\nvar static_init_done = false;\n\n/* ===========================================================================\n * Initialize the tree data structures for a new zlib stream.\n */\nfunction _tr_init(s)\n{\n\n if (!static_init_done) {\n tr_static_init();\n static_init_done = true;\n }\n\n s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc);\n s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc);\n s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc);\n\n s.bi_buf = 0;\n s.bi_valid = 0;\n\n /* Initialize the first block of the first file: */\n init_block(s);\n}\n\n\n/* ===========================================================================\n * Send a stored block\n */\nfunction _tr_stored_block(s, buf, stored_len, last)\n//DeflateState *s;\n//charf *buf; /* input block */\n//ulg stored_len; /* length of input block */\n//int last; /* one if this is the last block for a file */\n{\n send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3); /* send block type */\n copy_block(s, buf, stored_len, true); /* with header */\n}\n\n\n/* ===========================================================================\n * Send one empty static block to give enough lookahead for inflate.\n * This takes 10 bits, of which 7 may remain in the bit buffer.\n */\nfunction _tr_align(s) {\n send_bits(s, STATIC_TREES << 1, 3);\n send_code(s, END_BLOCK, static_ltree);\n bi_flush(s);\n}\n\n\n/* ===========================================================================\n * Determine the best encoding for the current block: dynamic trees, static\n * trees or store, and output the encoded block to the zip file.\n */\nfunction _tr_flush_block(s, buf, stored_len, last)\n//DeflateState *s;\n//charf *buf; /* input block, or NULL if too old */\n//ulg stored_len; /* length of input block */\n//int last; /* one if this is the last block for a file */\n{\n var opt_lenb, static_lenb; /* opt_len and static_len in bytes */\n var max_blindex = 0; /* index of last bit length code of non zero freq */\n\n /* Build the Huffman trees unless a stored block is forced */\n if (s.level > 0) {\n\n /* Check if the file is binary or text */\n if (s.strm.data_type === Z_UNKNOWN) {\n s.strm.data_type = detect_data_type(s);\n }\n\n /* Construct the literal and distance trees */\n build_tree(s, s.l_desc);\n // Tracev((stderr, \"\\nlit data: dyn %ld, stat %ld\", s->opt_len,\n // s->static_len));\n\n build_tree(s, s.d_desc);\n // Tracev((stderr, \"\\ndist data: dyn %ld, stat %ld\", s->opt_len,\n // s->static_len));\n /* At this point, opt_len and static_len are the total bit lengths of\n * the compressed block data, excluding the tree representations.\n */\n\n /* Build the bit length tree for the above two trees, and get the index\n * in bl_order of the last bit length code to send.\n */\n max_blindex = build_bl_tree(s);\n\n /* Determine the best encoding. Compute the block lengths in bytes. */\n opt_lenb = (s.opt_len + 3 + 7) >>> 3;\n static_lenb = (s.static_len + 3 + 7) >>> 3;\n\n // Tracev((stderr, \"\\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u \",\n // opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,\n // s->last_lit));\n\n if (static_lenb <= opt_lenb) { opt_lenb = static_lenb; }\n\n } else {\n // Assert(buf != (char*)0, \"lost buf\");\n opt_lenb = static_lenb = stored_len + 5; /* force a stored block */\n }\n\n if ((stored_len + 4 <= opt_lenb) && (buf !== -1)) {\n /* 4: two words for the lengths */\n\n /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.\n * Otherwise we can't have processed more than WSIZE input bytes since\n * the last block flush, because compression would have been\n * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to\n * transform a block into a stored block.\n */\n _tr_stored_block(s, buf, stored_len, last);\n\n } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) {\n\n send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3);\n compress_block(s, static_ltree, static_dtree);\n\n } else {\n send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3);\n send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1);\n compress_block(s, s.dyn_ltree, s.dyn_dtree);\n }\n // Assert (s->compressed_len == s->bits_sent, \"bad compressed size\");\n /* The above check is made mod 2^32, for files larger than 512 MB\n * and uLong implemented on 32 bits.\n */\n init_block(s);\n\n if (last) {\n bi_windup(s);\n }\n // Tracev((stderr,\"\\ncomprlen %lu(%lu) \", s->compressed_len>>3,\n // s->compressed_len-7*last));\n}\n\n/* ===========================================================================\n * Save the match info and tally the frequency counts. Return true if\n * the current block must be flushed.\n */\nfunction _tr_tally(s, dist, lc)\n// deflate_state *s;\n// unsigned dist; /* distance of matched string */\n// unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */\n{\n //var out_length, in_length, dcode;\n\n s.pending_buf[s.d_buf + s.last_lit * 2] = (dist >>> 8) & 0xff;\n s.pending_buf[s.d_buf + s.last_lit * 2 + 1] = dist & 0xff;\n\n s.pending_buf[s.l_buf + s.last_lit] = lc & 0xff;\n s.last_lit++;\n\n if (dist === 0) {\n /* lc is the unmatched char */\n s.dyn_ltree[lc * 2]/*.Freq*/++;\n } else {\n s.matches++;\n /* Here, lc is the match length - MIN_MATCH */\n dist--; /* dist = match distance - 1 */\n //Assert((ush)dist < (ush)MAX_DIST(s) &&\n // (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&\n // (ush)d_code(dist) < (ush)D_CODES, \"_tr_tally: bad match\");\n\n s.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2]/*.Freq*/++;\n s.dyn_dtree[d_code(dist) * 2]/*.Freq*/++;\n }\n\n// (!) This block is disabled in zlib defaults,\n// don't enable it for binary compatibility\n\n//#ifdef TRUNCATE_BLOCK\n// /* Try to guess if it is profitable to stop the current block here */\n// if ((s.last_lit & 0x1fff) === 0 && s.level > 2) {\n// /* Compute an upper bound for the compressed length */\n// out_length = s.last_lit*8;\n// in_length = s.strstart - s.block_start;\n//\n// for (dcode = 0; dcode < D_CODES; dcode++) {\n// out_length += s.dyn_dtree[dcode*2]/*.Freq*/ * (5 + extra_dbits[dcode]);\n// }\n// out_length >>>= 3;\n// //Tracev((stderr,\"\\nlast_lit %u, in %ld, out ~%ld(%ld%%) \",\n// // s->last_lit, in_length, out_length,\n// // 100L - out_length*100L/in_length));\n// if (s.matches < (s.last_lit>>1)/*int /2*/ && out_length < (in_length>>1)/*int /2*/) {\n// return true;\n// }\n// }\n//#endif\n\n return (s.last_lit === s.lit_bufsize - 1);\n /* We avoid equality with lit_bufsize because of wraparound at 64K\n * on 16 bit machines and because stored blocks are restricted to\n * 64K-1 bytes.\n */\n}\n\nexports._tr_init = _tr_init;\nexports._tr_stored_block = _tr_stored_block;\nexports._tr_flush_block = _tr_flush_block;\nexports._tr_tally = _tr_tally;\nexports._tr_align = _tr_align;\n","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nfunction ZStream() {\n /* next input byte */\n this.input = null; // JS specific, because we have no pointers\n this.next_in = 0;\n /* number of bytes available at input */\n this.avail_in = 0;\n /* total number of input bytes read so far */\n this.total_in = 0;\n /* next output byte should be put there */\n this.output = null; // JS specific, because we have no pointers\n this.next_out = 0;\n /* remaining free space at output */\n this.avail_out = 0;\n /* total number of bytes output so far */\n this.total_out = 0;\n /* last error message, NULL if no error */\n this.msg = ''/*Z_NULL*/;\n /* not visible by applications */\n this.state = null;\n /* best guess about the data type: binary or text */\n this.data_type = 2/*Z_UNKNOWN*/;\n /* adler32 value of the uncompressed data */\n this.adler = 0;\n}\n\nmodule.exports = ZStream;\n","module.exports = Pend;\n\nfunction Pend() {\n this.pending = 0;\n this.max = Infinity;\n this.listeners = [];\n this.waiting = [];\n this.error = null;\n}\n\nPend.prototype.go = function(fn) {\n if (this.pending < this.max) {\n pendGo(this, fn);\n } else {\n this.waiting.push(fn);\n }\n};\n\nPend.prototype.wait = function(cb) {\n if (this.pending === 0) {\n cb(this.error);\n } else {\n this.listeners.push(cb);\n }\n};\n\nPend.prototype.hold = function() {\n return pendHold(this);\n};\n\nfunction pendHold(self) {\n self.pending += 1;\n var called = false;\n return onCb;\n function onCb(err) {\n if (called) throw new Error(\"callback called twice\");\n called = true;\n self.error = self.error || err;\n self.pending -= 1;\n if (self.waiting.length > 0 && self.pending < self.max) {\n pendGo(self, self.waiting.shift());\n } else if (self.pending === 0) {\n var listeners = self.listeners;\n self.listeners = [];\n listeners.forEach(cbListener);\n }\n }\n function cbListener(listener) {\n listener(self.error);\n }\n}\n\nfunction pendGo(self, fn) {\n fn(pendHold(self));\n}\n","// shim for using process in browser\nvar process = module.exports = {};\n\n// cached from whatever global is present so that test runners that stub it\n// don't break things. But we need to wrap it in a try catch in case it is\n// wrapped in strict mode code which doesn't define any globals. It's inside a\n// function because try/catches deoptimize in certain engines.\n\nvar cachedSetTimeout;\nvar cachedClearTimeout;\n\nfunction defaultSetTimout() {\n throw new Error('setTimeout has not been defined');\n}\nfunction defaultClearTimeout () {\n throw new Error('clearTimeout has not been defined');\n}\n(function () {\n try {\n if (typeof setTimeout === 'function') {\n cachedSetTimeout = setTimeout;\n } else {\n cachedSetTimeout = defaultSetTimout;\n }\n } catch (e) {\n cachedSetTimeout = defaultSetTimout;\n }\n try {\n if (typeof clearTimeout === 'function') {\n cachedClearTimeout = clearTimeout;\n } else {\n cachedClearTimeout = defaultClearTimeout;\n }\n } catch (e) {\n cachedClearTimeout = defaultClearTimeout;\n }\n} ())\nfunction runTimeout(fun) {\n if (cachedSetTimeout === setTimeout) {\n //normal enviroments in sane situations\n return setTimeout(fun, 0);\n }\n // if setTimeout wasn't available but was latter defined\n if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {\n cachedSetTimeout = setTimeout;\n return setTimeout(fun, 0);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedSetTimeout(fun, 0);\n } catch(e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedSetTimeout.call(null, fun, 0);\n } catch(e){\n // 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\n return cachedSetTimeout.call(this, fun, 0);\n }\n }\n\n\n}\nfunction runClearTimeout(marker) {\n if (cachedClearTimeout === clearTimeout) {\n //normal enviroments in sane situations\n return clearTimeout(marker);\n }\n // if clearTimeout wasn't available but was latter defined\n if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {\n cachedClearTimeout = clearTimeout;\n return clearTimeout(marker);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedClearTimeout(marker);\n } catch (e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedClearTimeout.call(null, marker);\n } catch (e){\n // 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.\n // Some versions of I.E. have different rules for clearTimeout vs setTimeout\n return cachedClearTimeout.call(this, marker);\n }\n }\n\n\n\n}\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n if (!draining || !currentQueue) {\n return;\n }\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = runTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n runClearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n runTimeout(drainQueue);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\nprocess.prependListener = noop;\nprocess.prependOnceListener = noop;\n\nprocess.listeners = function (name) { return [] }\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n","/**\n * Copyright (c) 2014-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nvar runtime = (function (exports) {\n \"use strict\";\n\n var Op = Object.prototype;\n var hasOwn = Op.hasOwnProperty;\n var undefined; // More compressible than void 0.\n var $Symbol = typeof Symbol === \"function\" ? Symbol : {};\n var iteratorSymbol = $Symbol.iterator || \"@@iterator\";\n var asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\";\n var toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\";\n\n function wrap(innerFn, outerFn, self, tryLocsList) {\n // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.\n var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;\n var generator = Object.create(protoGenerator.prototype);\n var context = new Context(tryLocsList || []);\n\n // The ._invoke method unifies the implementations of the .next,\n // .throw, and .return methods.\n generator._invoke = makeInvokeMethod(innerFn, self, context);\n\n return generator;\n }\n exports.wrap = wrap;\n\n // Try/catch helper to minimize deoptimizations. Returns a completion\n // record like context.tryEntries[i].completion. This interface could\n // have been (and was previously) designed to take a closure to be\n // invoked without arguments, but in all the cases we care about we\n // already have an existing method we want to call, so there's no need\n // to create a new function object. We can even get away with assuming\n // the method takes exactly one argument, since that happens to be true\n // in every case, so we don't have to touch the arguments object. The\n // only additional allocation required is the completion record, which\n // has a stable shape and so hopefully should be cheap to allocate.\n function tryCatch(fn, obj, arg) {\n try {\n return { type: \"normal\", arg: fn.call(obj, arg) };\n } catch (err) {\n return { type: \"throw\", arg: err };\n }\n }\n\n var GenStateSuspendedStart = \"suspendedStart\";\n var GenStateSuspendedYield = \"suspendedYield\";\n var GenStateExecuting = \"executing\";\n var GenStateCompleted = \"completed\";\n\n // Returning this object from the innerFn has the same effect as\n // breaking out of the dispatch switch statement.\n var ContinueSentinel = {};\n\n // Dummy constructor functions that we use as the .constructor and\n // .constructor.prototype properties for functions that return Generator\n // objects. For full spec compliance, you may wish to configure your\n // minifier not to mangle the names of these two functions.\n function Generator() {}\n function GeneratorFunction() {}\n function GeneratorFunctionPrototype() {}\n\n // This is a polyfill for %IteratorPrototype% for environments that\n // don't natively support it.\n var IteratorPrototype = {};\n IteratorPrototype[iteratorSymbol] = function () {\n return this;\n };\n\n var getProto = Object.getPrototypeOf;\n var NativeIteratorPrototype = getProto && getProto(getProto(values([])));\n if (NativeIteratorPrototype &&\n NativeIteratorPrototype !== Op &&\n hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {\n // This environment has a native %IteratorPrototype%; use it instead\n // of the polyfill.\n IteratorPrototype = NativeIteratorPrototype;\n }\n\n var Gp = GeneratorFunctionPrototype.prototype =\n Generator.prototype = Object.create(IteratorPrototype);\n GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;\n GeneratorFunctionPrototype.constructor = GeneratorFunction;\n GeneratorFunctionPrototype[toStringTagSymbol] =\n GeneratorFunction.displayName = \"GeneratorFunction\";\n\n // Helper for defining the .next, .throw, and .return methods of the\n // Iterator interface in terms of a single ._invoke method.\n function defineIteratorMethods(prototype) {\n [\"next\", \"throw\", \"return\"].forEach(function(method) {\n prototype[method] = function(arg) {\n return this._invoke(method, arg);\n };\n });\n }\n\n exports.isGeneratorFunction = function(genFun) {\n var ctor = typeof genFun === \"function\" && genFun.constructor;\n return ctor\n ? ctor === GeneratorFunction ||\n // For the native GeneratorFunction constructor, the best we can\n // do is to check its .name property.\n (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n : false;\n };\n\n exports.mark = function(genFun) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);\n } else {\n genFun.__proto__ = GeneratorFunctionPrototype;\n if (!(toStringTagSymbol in genFun)) {\n genFun[toStringTagSymbol] = \"GeneratorFunction\";\n }\n }\n genFun.prototype = Object.create(Gp);\n return genFun;\n };\n\n // Within the body of any async function, `await x` is transformed to\n // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n // `hasOwn.call(value, \"__await\")` to determine if the yielded value is\n // meant to be awaited.\n exports.awrap = function(arg) {\n return { __await: arg };\n };\n\n function AsyncIterator(generator, PromiseImpl) {\n function invoke(method, arg, resolve, reject) {\n var record = tryCatch(generator[method], generator, arg);\n if (record.type === \"throw\") {\n reject(record.arg);\n } else {\n var result = record.arg;\n var value = result.value;\n if (value &&\n typeof value === \"object\" &&\n hasOwn.call(value, \"__await\")) {\n return PromiseImpl.resolve(value.__await).then(function(value) {\n invoke(\"next\", value, resolve, reject);\n }, function(err) {\n invoke(\"throw\", err, resolve, reject);\n });\n }\n\n return PromiseImpl.resolve(value).then(function(unwrapped) {\n // When a yielded Promise is resolved, its final value becomes\n // the .value of the Promise<{value,done}> result for the\n // current iteration.\n result.value = unwrapped;\n resolve(result);\n }, function(error) {\n // If a rejected Promise was yielded, throw the rejection back\n // into the async generator function so it can be handled there.\n return invoke(\"throw\", error, resolve, reject);\n });\n }\n }\n\n var previousPromise;\n\n function enqueue(method, arg) {\n function callInvokeWithMethodAndArg() {\n return new PromiseImpl(function(resolve, reject) {\n invoke(method, arg, resolve, reject);\n });\n }\n\n return previousPromise =\n // If enqueue has been called before, then we want to wait until\n // all previous Promises have been resolved before calling invoke,\n // so that results are always delivered in the correct order. If\n // enqueue has not been called before, then it is important to\n // call invoke immediately, without waiting on a callback to fire,\n // so that the async generator function has the opportunity to do\n // any necessary setup in a predictable way. This predictability\n // is why the Promise constructor synchronously invokes its\n // executor callback, and why async functions synchronously\n // execute code before the first await. Since we implement simple\n // async functions in terms of async generators, it is especially\n // important to get this right, even though it requires care.\n previousPromise ? previousPromise.then(\n callInvokeWithMethodAndArg,\n // Avoid propagating failures to Promises returned by later\n // invocations of the iterator.\n callInvokeWithMethodAndArg\n ) : callInvokeWithMethodAndArg();\n }\n\n // Define the unified helper method that is used to implement .next,\n // .throw, and .return (see defineIteratorMethods).\n this._invoke = enqueue;\n }\n\n defineIteratorMethods(AsyncIterator.prototype);\n AsyncIterator.prototype[asyncIteratorSymbol] = function () {\n return this;\n };\n exports.AsyncIterator = AsyncIterator;\n\n // Note that simple async functions are implemented on top of\n // AsyncIterator objects; they just return a Promise for the value of\n // the final result produced by the iterator.\n exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {\n if (PromiseImpl === void 0) PromiseImpl = Promise;\n\n var iter = new AsyncIterator(\n wrap(innerFn, outerFn, self, tryLocsList),\n PromiseImpl\n );\n\n return exports.isGeneratorFunction(outerFn)\n ? iter // If outerFn is a generator, return the full iterator.\n : iter.next().then(function(result) {\n return result.done ? result.value : iter.next();\n });\n };\n\n function makeInvokeMethod(innerFn, self, context) {\n var state = GenStateSuspendedStart;\n\n return function invoke(method, arg) {\n if (state === GenStateExecuting) {\n throw new Error(\"Generator is already running\");\n }\n\n if (state === GenStateCompleted) {\n if (method === \"throw\") {\n throw arg;\n }\n\n // Be forgiving, per 25.3.3.3.3 of the spec:\n // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n return doneResult();\n }\n\n context.method = method;\n context.arg = arg;\n\n while (true) {\n var delegate = context.delegate;\n if (delegate) {\n var delegateResult = maybeInvokeDelegate(delegate, context);\n if (delegateResult) {\n if (delegateResult === ContinueSentinel) continue;\n return delegateResult;\n }\n }\n\n if (context.method === \"next\") {\n // Setting context._sent for legacy support of Babel's\n // function.sent implementation.\n context.sent = context._sent = context.arg;\n\n } else if (context.method === \"throw\") {\n if (state === GenStateSuspendedStart) {\n state = GenStateCompleted;\n throw context.arg;\n }\n\n context.dispatchException(context.arg);\n\n } else if (context.method === \"return\") {\n context.abrupt(\"return\", context.arg);\n }\n\n state = GenStateExecuting;\n\n var record = tryCatch(innerFn, self, context);\n if (record.type === \"normal\") {\n // If an exception is thrown from innerFn, we leave state ===\n // GenStateExecuting and loop back for another invocation.\n state = context.done\n ? GenStateCompleted\n : GenStateSuspendedYield;\n\n if (record.arg === ContinueSentinel) {\n continue;\n }\n\n return {\n value: record.arg,\n done: context.done\n };\n\n } else if (record.type === \"throw\") {\n state = GenStateCompleted;\n // Dispatch the exception by looping back around to the\n // context.dispatchException(context.arg) call above.\n context.method = \"throw\";\n context.arg = record.arg;\n }\n }\n };\n }\n\n // Call delegate.iterator[context.method](context.arg) and handle the\n // result, either by returning a { value, done } result from the\n // delegate iterator, or by modifying context.method and context.arg,\n // setting context.delegate to null, and returning the ContinueSentinel.\n function maybeInvokeDelegate(delegate, context) {\n var method = delegate.iterator[context.method];\n if (method === undefined) {\n // A .throw or .return when the delegate iterator has no .throw\n // method always terminates the yield* loop.\n context.delegate = null;\n\n if (context.method === \"throw\") {\n // Note: [\"return\"] must be used for ES3 parsing compatibility.\n if (delegate.iterator[\"return\"]) {\n // If the delegate iterator has a return method, give it a\n // chance to clean up.\n context.method = \"return\";\n context.arg = undefined;\n maybeInvokeDelegate(delegate, context);\n\n if (context.method === \"throw\") {\n // If maybeInvokeDelegate(context) changed context.method from\n // \"return\" to \"throw\", let that override the TypeError below.\n return ContinueSentinel;\n }\n }\n\n context.method = \"throw\";\n context.arg = new TypeError(\n \"The iterator does not provide a 'throw' method\");\n }\n\n return ContinueSentinel;\n }\n\n var record = tryCatch(method, delegate.iterator, context.arg);\n\n if (record.type === \"throw\") {\n context.method = \"throw\";\n context.arg = record.arg;\n context.delegate = null;\n return ContinueSentinel;\n }\n\n var info = record.arg;\n\n if (! info) {\n context.method = \"throw\";\n context.arg = new TypeError(\"iterator result is not an object\");\n context.delegate = null;\n return ContinueSentinel;\n }\n\n if (info.done) {\n // Assign the result of the finished delegate to the temporary\n // variable specified by delegate.resultName (see delegateYield).\n context[delegate.resultName] = info.value;\n\n // Resume execution at the desired location (see delegateYield).\n context.next = delegate.nextLoc;\n\n // If context.method was \"throw\" but the delegate handled the\n // exception, let the outer generator proceed normally. If\n // context.method was \"next\", forget context.arg since it has been\n // \"consumed\" by the delegate iterator. If context.method was\n // \"return\", allow the original .return call to continue in the\n // outer generator.\n if (context.method !== \"return\") {\n context.method = \"next\";\n context.arg = undefined;\n }\n\n } else {\n // Re-yield the result returned by the delegate method.\n return info;\n }\n\n // The delegate iterator is finished, so forget it and continue with\n // the outer generator.\n context.delegate = null;\n return ContinueSentinel;\n }\n\n // Define Generator.prototype.{next,throw,return} in terms of the\n // unified ._invoke helper method.\n defineIteratorMethods(Gp);\n\n Gp[toStringTagSymbol] = \"Generator\";\n\n // A Generator should always return itself as the iterator object when the\n // @@iterator function is called on it. Some browsers' implementations of the\n // iterator prototype chain incorrectly implement this, causing the Generator\n // object to not be returned from this call. This ensures that doesn't happen.\n // See https://github.com/facebook/regenerator/issues/274 for more details.\n Gp[iteratorSymbol] = function() {\n return this;\n };\n\n Gp.toString = function() {\n return \"[object Generator]\";\n };\n\n function pushTryEntry(locs) {\n var entry = { tryLoc: locs[0] };\n\n if (1 in locs) {\n entry.catchLoc = locs[1];\n }\n\n if (2 in locs) {\n entry.finallyLoc = locs[2];\n entry.afterLoc = locs[3];\n }\n\n this.tryEntries.push(entry);\n }\n\n function resetTryEntry(entry) {\n var record = entry.completion || {};\n record.type = \"normal\";\n delete record.arg;\n entry.completion = record;\n }\n\n function Context(tryLocsList) {\n // The root entry object (effectively a try statement without a catch\n // or a finally block) gives us a place to store values thrown from\n // locations where there is no enclosing try statement.\n this.tryEntries = [{ tryLoc: \"root\" }];\n tryLocsList.forEach(pushTryEntry, this);\n this.reset(true);\n }\n\n exports.keys = function(object) {\n var keys = [];\n for (var key in object) {\n keys.push(key);\n }\n keys.reverse();\n\n // Rather than returning an object with a next method, we keep\n // things simple and return the next function itself.\n return function next() {\n while (keys.length) {\n var key = keys.pop();\n if (key in object) {\n next.value = key;\n next.done = false;\n return next;\n }\n }\n\n // To avoid creating an additional object, we just hang the .value\n // and .done properties off the next function object itself. This\n // also ensures that the minifier will not anonymize the function.\n next.done = true;\n return next;\n };\n };\n\n function values(iterable) {\n if (iterable) {\n var iteratorMethod = iterable[iteratorSymbol];\n if (iteratorMethod) {\n return iteratorMethod.call(iterable);\n }\n\n if (typeof iterable.next === \"function\") {\n return iterable;\n }\n\n if (!isNaN(iterable.length)) {\n var i = -1, next = function next() {\n while (++i < iterable.length) {\n if (hasOwn.call(iterable, i)) {\n next.value = iterable[i];\n next.done = false;\n return next;\n }\n }\n\n next.value = undefined;\n next.done = true;\n\n return next;\n };\n\n return next.next = next;\n }\n }\n\n // Return an iterator with no values.\n return { next: doneResult };\n }\n exports.values = values;\n\n function doneResult() {\n return { value: undefined, done: true };\n }\n\n Context.prototype = {\n constructor: Context,\n\n reset: function(skipTempReset) {\n this.prev = 0;\n this.next = 0;\n // Resetting context._sent for legacy support of Babel's\n // function.sent implementation.\n this.sent = this._sent = undefined;\n this.done = false;\n this.delegate = null;\n\n this.method = \"next\";\n this.arg = undefined;\n\n this.tryEntries.forEach(resetTryEntry);\n\n if (!skipTempReset) {\n for (var name in this) {\n // Not sure about the optimal order of these conditions:\n if (name.charAt(0) === \"t\" &&\n hasOwn.call(this, name) &&\n !isNaN(+name.slice(1))) {\n this[name] = undefined;\n }\n }\n }\n },\n\n stop: function() {\n this.done = true;\n\n var rootEntry = this.tryEntries[0];\n var rootRecord = rootEntry.completion;\n if (rootRecord.type === \"throw\") {\n throw rootRecord.arg;\n }\n\n return this.rval;\n },\n\n dispatchException: function(exception) {\n if (this.done) {\n throw exception;\n }\n\n var context = this;\n function handle(loc, caught) {\n record.type = \"throw\";\n record.arg = exception;\n context.next = loc;\n\n if (caught) {\n // If the dispatched exception was caught by a catch block,\n // then let that catch block handle the exception normally.\n context.method = \"next\";\n context.arg = undefined;\n }\n\n return !! caught;\n }\n\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n var record = entry.completion;\n\n if (entry.tryLoc === \"root\") {\n // Exception thrown outside of any try block that could handle\n // it, so set the completion value of the entire function to\n // throw the exception.\n return handle(\"end\");\n }\n\n if (entry.tryLoc <= this.prev) {\n var hasCatch = hasOwn.call(entry, \"catchLoc\");\n var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n if (hasCatch && hasFinally) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n } else if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else if (hasCatch) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n }\n\n } else if (hasFinally) {\n if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else {\n throw new Error(\"try statement without catch or finally\");\n }\n }\n }\n },\n\n abrupt: function(type, arg) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc <= this.prev &&\n hasOwn.call(entry, \"finallyLoc\") &&\n this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n\n if (finallyEntry &&\n (type === \"break\" ||\n type === \"continue\") &&\n finallyEntry.tryLoc <= arg &&\n arg <= finallyEntry.finallyLoc) {\n // Ignore the finally entry if control is not jumping to a\n // location outside the try/catch block.\n finallyEntry = null;\n }\n\n var record = finallyEntry ? finallyEntry.completion : {};\n record.type = type;\n record.arg = arg;\n\n if (finallyEntry) {\n this.method = \"next\";\n this.next = finallyEntry.finallyLoc;\n return ContinueSentinel;\n }\n\n return this.complete(record);\n },\n\n complete: function(record, afterLoc) {\n if (record.type === \"throw\") {\n throw record.arg;\n }\n\n if (record.type === \"break\" ||\n record.type === \"continue\") {\n this.next = record.arg;\n } else if (record.type === \"return\") {\n this.rval = this.arg = record.arg;\n this.method = \"return\";\n this.next = \"end\";\n } else if (record.type === \"normal\" && afterLoc) {\n this.next = afterLoc;\n }\n\n return ContinueSentinel;\n },\n\n finish: function(finallyLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.finallyLoc === finallyLoc) {\n this.complete(entry.completion, entry.afterLoc);\n resetTryEntry(entry);\n return ContinueSentinel;\n }\n }\n },\n\n \"catch\": function(tryLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc === tryLoc) {\n var record = entry.completion;\n if (record.type === \"throw\") {\n var thrown = record.arg;\n resetTryEntry(entry);\n }\n return thrown;\n }\n }\n\n // The context.catch method must only be called with a location\n // argument that corresponds to a known catch block.\n throw new Error(\"illegal catch attempt\");\n },\n\n delegateYield: function(iterable, resultName, nextLoc) {\n this.delegate = {\n iterator: values(iterable),\n resultName: resultName,\n nextLoc: nextLoc\n };\n\n if (this.method === \"next\") {\n // Deliberately forget the last sent value so that we don't\n // accidentally pass it on to the delegate.\n this.arg = undefined;\n }\n\n return ContinueSentinel;\n }\n };\n\n // Regardless of whether this script is executing as a CommonJS module\n // or not, return the runtime object so that we can declare the variable\n // regeneratorRuntime in the outer scope, which allows this module to be\n // injected easily by `bin/regenerator --include-runtime script.js`.\n return exports;\n\n}(\n // If this script is executing as a CommonJS module, use module.exports\n // as the regeneratorRuntime namespace. Otherwise create a new empty\n // object. Either way, the resulting object will be used to initialize\n // the regeneratorRuntime variable at the top of this file.\n typeof module === \"object\" ? module.exports : {}\n));\n\ntry {\n regeneratorRuntime = runtime;\n} catch (accidentalStrictMode) {\n // This module should not be running in strict mode, so the above\n // assignment should always work unless something is misconfigured. Just\n // in case runtime.js accidentally runs in strict mode, we can escape\n // strict mode using a global Function call. This could conceivably fail\n // if a Content Security Policy forbids using Function, but in that case\n // the proper solution is to fix the accidental strict mode problem. If\n // you've misconfigured your bundler to force strict mode and applied a\n // CSP to forbid Function, and you're not willing to fix either of those\n // problems, please detail your unique predicament in a GitHub issue.\n Function(\"r\", \"regeneratorRuntime = r\")(runtime);\n}\n","(function (global, undefined) {\n \"use strict\";\n\n if (global.setImmediate) {\n return;\n }\n\n var nextHandle = 1; // Spec says greater than zero\n var tasksByHandle = {};\n var currentlyRunningATask = false;\n var doc = global.document;\n var registerImmediate;\n\n function setImmediate(callback) {\n // Callback can either be a function or a string\n if (typeof callback !== \"function\") {\n callback = new Function(\"\" + callback);\n }\n // Copy function arguments\n var args = new Array(arguments.length - 1);\n for (var i = 0; i < args.length; i++) {\n args[i] = arguments[i + 1];\n }\n // Store and register the task\n var task = { callback: callback, args: args };\n tasksByHandle[nextHandle] = task;\n registerImmediate(nextHandle);\n return nextHandle++;\n }\n\n function clearImmediate(handle) {\n delete tasksByHandle[handle];\n }\n\n function run(task) {\n var callback = task.callback;\n var args = task.args;\n switch (args.length) {\n case 0:\n callback();\n break;\n case 1:\n callback(args[0]);\n break;\n case 2:\n callback(args[0], args[1]);\n break;\n case 3:\n callback(args[0], args[1], args[2]);\n break;\n default:\n callback.apply(undefined, args);\n break;\n }\n }\n\n function runIfPresent(handle) {\n // From the spec: \"Wait until any invocations of this algorithm started before this one have completed.\"\n // So if we're currently running a task, we'll need to delay this invocation.\n if (currentlyRunningATask) {\n // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a\n // \"too much recursion\" error.\n setTimeout(runIfPresent, 0, handle);\n } else {\n var task = tasksByHandle[handle];\n if (task) {\n currentlyRunningATask = true;\n try {\n run(task);\n } finally {\n clearImmediate(handle);\n currentlyRunningATask = false;\n }\n }\n }\n }\n\n function installNextTickImplementation() {\n registerImmediate = function(handle) {\n process.nextTick(function () { runIfPresent(handle); });\n };\n }\n\n function canUsePostMessage() {\n // The test against `importScripts` prevents this implementation from being installed inside a web worker,\n // where `global.postMessage` means something completely different and can't be used for this purpose.\n if (global.postMessage && !global.importScripts) {\n var postMessageIsAsynchronous = true;\n var oldOnMessage = global.onmessage;\n global.onmessage = function() {\n postMessageIsAsynchronous = false;\n };\n global.postMessage(\"\", \"*\");\n global.onmessage = oldOnMessage;\n return postMessageIsAsynchronous;\n }\n }\n\n function installPostMessageImplementation() {\n // Installs an event handler on `global` for the `message` event: see\n // * https://developer.mozilla.org/en/DOM/window.postMessage\n // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages\n\n var messagePrefix = \"setImmediate$\" + Math.random() + \"$\";\n var onGlobalMessage = function(event) {\n if (event.source === global &&\n typeof event.data === \"string\" &&\n event.data.indexOf(messagePrefix) === 0) {\n runIfPresent(+event.data.slice(messagePrefix.length));\n }\n };\n\n if (global.addEventListener) {\n global.addEventListener(\"message\", onGlobalMessage, false);\n } else {\n global.attachEvent(\"onmessage\", onGlobalMessage);\n }\n\n registerImmediate = function(handle) {\n global.postMessage(messagePrefix + handle, \"*\");\n };\n }\n\n function installMessageChannelImplementation() {\n var channel = new MessageChannel();\n channel.port1.onmessage = function(event) {\n var handle = event.data;\n runIfPresent(handle);\n };\n\n registerImmediate = function(handle) {\n channel.port2.postMessage(handle);\n };\n }\n\n function installReadyStateChangeImplementation() {\n var html = doc.documentElement;\n registerImmediate = function(handle) {\n // Create a \"\n * in order to use this functionality. Then just uncomment the rest, and choose\n * which of the makeDebugContext lines at the end to uncomment.\n */\n /*\n // A standard one. Chrome already reports such errors without you adding this, and yourw\n // will take the place of theirs.\n function throwOnGLError(err, funcName, args) {\n throw WebGLDebugUtils.glEnumToString(err) + \" was caused by call to: \" + funcName;\n };\n // this one is terribly weird, but provided by Khronos as an example.\n function logGLCall(functionName, args) {\n console.log(\"gl.\" + functionName + \"(\" +\n WebGLDebugUtils.glFunctionArgsToString(functionName, args) + \")\");\n }\n // this one is actually handy: flags an error when we try to pass in an argument that is undefined.\n function validateNoneOfTheArgsAreUndefined(functionName, args) {\n for (var ii = 0; ii < args.length; ++ii) {\n if (args[ii] === undefined) {\n console.error(\"undefined passed to gl.\" + functionName + \"(\" +\n WebGLDebugUtils.glFunctionArgsToString(functionName, args) + \")\");\n }\n }\n }\n // Choose one of these two:\n // the default, shows usual errors.\n _gl = WebGLDebugUtils.makeDebugContext(_gl, throwOnGLError);\n // to check for undefined args passed in to WebGL, which is a no-no:\n //_gl = WebGLDebugUtils.makeDebugContext(_gl, undefined, validateNoneOfTheArgsAreUndefined);\n */\n\n\n\n\n\n //LMV-1914: lower fragment precision for low-end mobile devices (Android)\n var highp = _gl.getShaderPrecisionFormat(_gl.FRAGMENT_SHADER, _gl.HIGH_FLOAT);\n if (highp.precision == 0) _precisionFragment = 'mediump';\n\n _canvas.addEventListener('webglcontextlost', function (event) {\n\n event.preventDefault();\n\n resetGLState();\n setDefaultGLState();\n\n _webglObjects = {};\n\n _this.webglcontextlost && _this.webglcontextlost(event);\n\n }, false);\n\n } catch (error) {\n\n THREE.error(error);\n return;\n\n }\n\n var state = new THREE.WebGLState(_gl, paramThreeToGL);\n\n if (_gl.getShaderPrecisionFormat === undefined) {\n\n _gl.getShaderPrecisionFormat = function () {\n\n return {\n \"rangeMin\": 1,\n \"rangeMax\": 1,\n \"precision\": 1 };\n\n\n };\n }\n\n var extensions = new THREE.WebGLExtensions(_gl);\n\n //We know we are going to be using some extensions for sure\n extensions.get('EXT_texture_filter_anisotropic');\n extensions.get('WEBGL_compressed_texture_s3tc');\n\n if (!_isWebGL2) {\n\n extensions.get('OES_texture_float');\n extensions.get('OES_texture_float_linear');\n extensions.get('OES_texture_half_float');\n extensions.get('OES_texture_half_float_linear');\n extensions.get('OES_standard_derivatives');\n extensions.get('EXT_shader_texture_lod');\n\n _glExtensionDrawBuffers = extensions.get('WEBGL_draw_buffers');\n _glExtensionInstancedArrays = extensions.get('ANGLE_instanced_arrays');\n _glExtensionVAO = extensions.get('OES_vertex_array_object');\n\n } else {\n\n extensions.get('EXT_color_buffer_float');\n\n }\n\n\n\n var glClearColor = function glClearColor(r, g, b, a) {\n\n if (_premultipliedAlpha === true) {\n\n r *= a;g *= a;b *= a;\n\n }\n\n _gl.clearColor(r, g, b, a);\n\n };\n\n var setDefaultGLState = function setDefaultGLState() {\n\n _gl.clearColor(0, 0, 0, 1);\n _gl.clearDepth(1);\n _gl.clearStencil(0);\n\n _gl.enable(_gl.DEPTH_TEST);\n _gl.depthFunc(_gl.LEQUAL);\n\n _gl.frontFace(_gl.CCW);\n _gl.cullFace(_gl.BACK);\n _gl.enable(_gl.CULL_FACE);\n\n _gl.enable(_gl.BLEND);\n _gl.blendEquation(_gl.FUNC_ADD);\n _gl.blendFunc(_gl.SRC_ALPHA, _gl.ONE_MINUS_SRC_ALPHA);\n\n _gl.viewport(_viewportX, _viewportY, _viewportWidth, _viewportHeight);\n\n glClearColor(_clearColor.r, _clearColor.g, _clearColor.b, _clearAlpha);\n\n };\n\n var resetGLState = function resetGLState() {\n\n _currentProgram = null;\n _currentCamera = null;\n\n _currentGeometryProgram = '';\n _currentMaterialId = -1;\n\n _lightsNeedUpdate = true;\n\n state.reset();\n state.disableUnusedAttributes();\n };\n\n\n setDefaultGLState();\n\n this.context = _gl;\n this.state = state;\n\n // GPU capabilities\n\n var _maxTextures = _gl.getParameter(_gl.MAX_TEXTURE_IMAGE_UNITS);\n var _maxVertexTextures = _gl.getParameter(_gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);\n var _maxTextureSize = _gl.getParameter(_gl.MAX_TEXTURE_SIZE);\n var _maxCubemapSize = _gl.getParameter(_gl.MAX_CUBE_MAP_TEXTURE_SIZE);\n\n var _supportsVertexTextures = _maxVertexTextures > 0;\n // not used, though used in three.js's version:\n //var _supportsBoneTextures = _supportsVertexTextures && extensions.get( 'OES_texture_float' );\n\n\n var _vertexShaderPrecisionHighpFloat = _gl.getShaderPrecisionFormat(_gl.VERTEX_SHADER, _gl.HIGH_FLOAT);\n var _vertexShaderPrecisionMediumpFloat = _gl.getShaderPrecisionFormat(_gl.VERTEX_SHADER, _gl.MEDIUM_FLOAT);\n //var _vertexShaderPrecisionLowpFloat = _gl.getShaderPrecisionFormat( _gl.VERTEX_SHADER, _gl.LOW_FLOAT );\n\n var _fragmentShaderPrecisionHighpFloat = _gl.getShaderPrecisionFormat(_gl.FRAGMENT_SHADER, _gl.HIGH_FLOAT);\n var _fragmentShaderPrecisionMediumpFloat = _gl.getShaderPrecisionFormat(_gl.FRAGMENT_SHADER, _gl.MEDIUM_FLOAT);\n //var _fragmentShaderPrecisionLowpFloat = _gl.getShaderPrecisionFormat( _gl.FRAGMENT_SHADER, _gl.LOW_FLOAT );\n\n // Sometimes a texture is not actually available to bind. We use _nullTexture so that the uniform sampler2D\n // is bound to something, so that we don't get a warning from Chrome.\n var pixels = new Uint8Array(16);\n\n // checkerboard\n for (var i = 0; i < 4; i++) {\n // for debugging - gives a pink and green pattern, which will show textures that are not loaded properly.\n // Sometimes textures are not loaded yet and so will use this texture temporarily, so we don't normally load this pattern.\n if (DEBUG_TEXTURE_LOAD) {\n if (i === 1 || i === 2) {\n pixels[i * 4] = 246;\n pixels[i * 4 + 1] = 140;\n pixels[i * 4 + 2] = 220;\n } else {\n pixels[i * 4] = 48;\n pixels[i * 4 + 1] = 195;\n pixels[i * 4 + 2] = 3;\n }\n } else {\n // black - we actually use this color as a sign that the texture is not loaded for Graphite and take corrective action there.\n pixels[i * 4] =\n pixels[i * 4 + 1] =\n pixels[i * 4 + 2] = 0;\n }\n pixels[i * 4 + 3] = 255;\n }\n\n var _nullTexture = new THREE.DataTexture(pixels, 2, 2, THREE.RGBAFormat, THREE.UnsignedByteType, THREE.UVMapping,\n THREE.RepeatWrapping, THREE.RepeatWrapping,\n THREE.NearestFilter, THREE.NearestFilter);\n _nullTexture.needsUpdate = true;\n\n var getCompressedTextureFormats = function () {\n\n var array;\n\n return function () {\n\n if (array !== undefined) {\n\n return array;\n\n }\n\n array = [];\n\n if (extensions.get('WEBGL_compressed_texture_pvrtc') || extensions.get('WEBGL_compressed_texture_s3tc')) {\n\n var formats = _gl.getParameter(_gl.COMPRESSED_TEXTURE_FORMATS);\n\n for (var i = 0; i < formats.length; i++) {\n\n array.push(formats[i]);\n\n }\n\n }\n\n return array;\n\n };\n\n }();\n\n\n // clamp precision to maximum available\n\n var highpAvailable = _vertexShaderPrecisionHighpFloat.precision > 0;\n var mediumpAvailable = _vertexShaderPrecisionMediumpFloat.precision > 0;\n\n if (_precisionVertex === \"highp\" && !highpAvailable) {\n\n if (mediumpAvailable) {\n\n _precisionVertex = \"mediump\";\n THREE.warn(\"WebGLRenderer: highp not supported, using mediump\");\n\n } else {\n\n _precisionVertex = \"lowp\";\n THREE.warn(\"WebGLRenderer: highp and mediump not supported, using lowp\");\n\n }\n\n }\n\n if (_precisionVertex === \"mediump\" && !mediumpAvailable) {\n\n _precisionVertex = \"lowp\";\n THREE.warn(\"WebGLRenderer: mediump not supported, using lowp\");\n\n }\n\n highpAvailable = _fragmentShaderPrecisionHighpFloat.precision > 0;\n mediumpAvailable = _fragmentShaderPrecisionMediumpFloat.precision > 0;\n\n if (_precisionFragment === \"highp\" && !highpAvailable) {\n\n if (mediumpAvailable) {\n\n _precisionFragment = \"mediump\";\n THREE.warn(\"WebGLRenderer: highp not supported, using mediump\");\n\n } else {\n\n _precisionFragment = \"lowp\";\n THREE.warn(\"WebGLRenderer: highp and mediump not supported, using lowp\");\n\n }\n\n }\n\n if (_precisionFragment === \"mediump\" && !mediumpAvailable) {\n\n _precisionFragment = \"lowp\";\n THREE.warn(\"WebGLRenderer: mediump not supported, using lowp\");\n\n }\n\n\n\n // API\n\n this.getContext = function () {\n\n return _gl;\n\n };\n\n this.isWebGL2 = function () {\n\n return _isWebGL2;\n\n };\n\n this.forceContextLoss = function () {\n\n extensions.get('WEBGL_lose_context').loseContext();\n\n };\n\n this.supportsVertexTextures = function () {\n\n return _supportsVertexTextures;\n\n };\n\n this.supportsFloatTextures = function () {\n\n return _isWebGL2 || extensions.get('OES_texture_float');\n\n };\n\n this.supportsHalfFloatTextures = function () {\n\n return _isWebGL2 || extensions.get('OES_texture_half_float_linear');\n\n };\n\n this.supportsStandardDerivatives = function () {\n\n return _isWebGL2 || extensions.get('OES_standard_derivatives');\n\n };\n\n this.supportsCompressedTextureS3TC = function () {\n\n return _isWebGL2 || extensions.get('WEBGL_compressed_texture_s3tc');\n\n };\n\n this.supportsElementIndexUint = function () {\n\n return _isWebGL2 || extensions.get('OES_element_index_uint');\n\n };\n\n this.supportsMRT = function () {\n return _isWebGL2 || !_blockMRT && _glExtensionDrawBuffers;\n };\n\n this.supportsInstancedArrays = function () {\n return _isWebGL2 || !!_glExtensionInstancedArrays;\n };\n\n this.supportsBlendMinMax = function () {\n\n return _isWebGL2 || extensions.get('EXT_blend_minmax');\n\n };\n\n this.getMaxAnisotropy = function () {\n\n var value;\n\n return function () {\n\n if (value !== undefined) {\n\n return value;\n\n }\n\n var extension = extensions.get('EXT_texture_filter_anisotropic');\n\n value = extension !== null ? _gl.getParameter(extension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0;\n\n return value;\n\n };\n\n }();\n\n this.getPixelRatio = function () {\n return _pixelRatio || _window.devicePixelRatio || 1;\n };\n /**\n * Sets a custom pixel ratio instead of the device's.\n * Set to a falsy value to restore the devicePixelRatio;\n * @param {Number|null} value\n */\n this.setPixelRatio = function (value) {\n _pixelRatio = value;\n };\n\n /**\n * @returns {WebGLFramebuffer} Currently bound framebuffer\n */\n this.getCurrentFramebuffer = function () {\n return _currentFramebuffer;\n };\n\n this.setSize = function (width, height, updateStyle) {\n var pixelRatio = this.getPixelRatio();\n _canvas.width = width * pixelRatio;\n _canvas.height = height * pixelRatio;\n\n if (updateStyle !== false) {\n\n _canvas.style.width = width + 'px';\n _canvas.style.height = height + 'px';\n\n }\n\n this.setViewport(0, 0, width, height);\n };\n\n this.setViewport = function (x, y, width, height) {\n var pixelRatio = this.getPixelRatio();\n _viewportX = x * pixelRatio;\n _viewportY = y * pixelRatio;\n\n _viewportWidth = width * pixelRatio;\n _viewportHeight = height * pixelRatio;\n\n _gl.viewport(_viewportX, _viewportY, _viewportWidth, _viewportHeight);\n };\n\n // By default, setting a viewport only affects rendering to the framebuffer. I.e., when setting an offscreen \n // target, gl viewport is set to the target size. This makes sure that a RenderTarget is always properly filled by default - independent of its resolution.\n // \n // Setting resetViewportOnSetTarget to true avoids this behavior, so that the current viewport is also be preserved when using offscreen targets.\n var _enableViewportOnOffscreenTargets = false;\n this.enableViewportOnOffscreenTargets = function (enable) {\n _enableViewportOnOffscreenTargets = enable;\n };\n\n var _viewportStack = [];\n\n /** Push current viewport to viewport stack, so that it can be recovered by popViewport later. */\n this.pushViewport = function () {\n _viewportStack.push(_viewportX);\n _viewportStack.push(_viewportY);\n _viewportStack.push(_viewportWidth);\n _viewportStack.push(_viewportHeight);\n };\n\n /** Recover previously pushed viewport.*/\n this.popViewport = function () {\n var index = _viewportStack.length - 4;\n _viewportX = _viewportStack[index];\n _viewportY = _viewportStack[index + 1];\n _viewportWidth = _viewportStack[index + 2];\n _viewportHeight = _viewportStack[index + 3];\n _gl.viewport(_viewportX, _viewportY, _viewportWidth, _viewportHeight);\n\n _viewportStack.length = index;\n };\n\n this.setScissor = function (x, y, width, height) {\n var pixelRatio = this.getPixelRatio();\n _gl.scissor(\n x * pixelRatio,\n y * pixelRatio,\n width * pixelRatio,\n height * pixelRatio);\n\n\n };\n\n this.enableScissorTest = function (enable) {\n\n if (enable) {\n _gl.enable(_gl.SCISSOR_TEST);\n } else {\n _gl.disable(_gl.SCISSOR_TEST);\n }\n\n };\n\n this.setLoadingAnimationDuration = function (duration) {\n _loadingAnimationDuration = duration;\n };\n\n this.getLoadingAnimationDuration = function () {\n return _loadingAnimationDuration;\n };\n\n // Clearing\n\n this.getClearColor = function () {\n\n return _clearColor;\n\n };\n\n this.setClearColor = function (color, alpha) {\n\n _clearColor.set(color);\n _clearAlpha = alpha !== undefined ? alpha : 1;\n\n glClearColor(_clearColor.r, _clearColor.g, _clearColor.b, _clearAlpha);\n\n };\n\n this.getClearAlpha = function () {\n\n return _clearAlpha;\n\n };\n\n this.setClearAlpha = function (alpha) {\n\n _clearAlpha = alpha;\n\n glClearColor(_clearColor.r, _clearColor.g, _clearColor.b, _clearAlpha);\n\n };\n\n this.clear = function (color, depth, stencil) {\n\n var bits = 0;\n\n if (color === undefined || color) bits |= _gl.COLOR_BUFFER_BIT;\n if (depth === undefined || depth) bits |= _gl.DEPTH_BUFFER_BIT;\n if (stencil === undefined || stencil) bits |= _gl.STENCIL_BUFFER_BIT;\n\n _gl.clear(bits);\n\n };\n\n this.clearColor = function () {\n\n _gl.clear(_gl.COLOR_BUFFER_BIT);\n\n };\n\n this.clearDepth = function () {\n\n _gl.clear(_gl.DEPTH_BUFFER_BIT);\n\n };\n\n this.clearStencil = function () {\n\n _gl.clear(_gl.STENCIL_BUFFER_BIT);\n\n };\n\n this.clearTarget = function (renderTarget, color, depth, stencil) {\n\n this.setRenderTarget(renderTarget);\n this.clear(color, depth, stencil);\n\n };\n\n\n // Reset\n\n this.resetGLState = resetGLState;\n\n // Internal functions\n\n // Buffer allocation\n\n function createLineBuffers(geometry) {\n\n geometry.__webglVertexBuffer = _gl.createBuffer();\n geometry.__webglColorBuffer = _gl.createBuffer();\n geometry.__webglLineDistanceBuffer = _gl.createBuffer();\n\n _this.info.memory.geometries++;\n }\n\n function createPointCloudBuffers(geometry) {\n\n geometry.__webglVertexBuffer = _gl.createBuffer();\n geometry.__webglColorBuffer = _gl.createBuffer();\n\n _this.info.memory.geometries++;\n }\n\n function createMeshBuffers(geometryGroup) {\n\n geometryGroup.__webglVertexBuffer = _gl.createBuffer();\n geometryGroup.__webglNormalBuffer = _gl.createBuffer();\n geometryGroup.__webglTangentBuffer = _gl.createBuffer();\n geometryGroup.__webglColorBuffer = _gl.createBuffer();\n geometryGroup.__webglUVBuffer = _gl.createBuffer();\n geometryGroup.__webglUV2Buffer = _gl.createBuffer();\n\n geometryGroup.__webglSkinIndicesBuffer = _gl.createBuffer();\n geometryGroup.__webglSkinWeightsBuffer = _gl.createBuffer();\n\n geometryGroup.__webglFaceBuffer = _gl.createBuffer();\n geometryGroup.__webglLineBuffer = _gl.createBuffer();\n\n _this.info.memory.geometries++;\n\n }\n\n // Events\n\n var onObjectRemoved = function onObjectRemoved(event) {\n\n var object = event.target;\n\n object.traverse(function (child) {\n\n child.removeEventListener('remove', onObjectRemoved);\n\n removeObject(child);\n\n });\n\n };\n\n var onGeometryDispose = function onGeometryDispose(event) {\n\n var geometry = event.target;\n\n geometry.removeEventListener('dispose', onGeometryDispose);\n\n deallocateGeometry(geometry);\n\n };\n\n var onTextureDispose = function onTextureDispose(event) {\n\n var texture = event.target;\n\n texture.removeEventListener('dispose', onTextureDispose);\n\n deallocateTexture(texture);\n\n _this.info.memory.textures--;\n\n\n };\n\n var onRenderTargetDispose = function onRenderTargetDispose(event) {\n\n var renderTarget = event.target;\n\n renderTarget.removeEventListener('dispose', onRenderTargetDispose);\n\n deallocateRenderTarget(renderTarget);\n\n _this.info.memory.textures--;\n\n };\n\n var onMaterialDispose = function onMaterialDispose(event) {\n\n var material = event.target;\n\n material.removeEventListener('dispose', onMaterialDispose);\n\n deallocateMaterial(material);\n\n };\n\n // Buffer deallocation\n\n var deleteBuffers = function deleteBuffers(geometry) {\n\n if (geometry.__webglVertexBuffer !== undefined) {_gl.deleteBuffer(geometry.__webglVertexBuffer);geometry.__webglVertexBuffer = undefined;}\n if (geometry.__webglNormalBuffer !== undefined) {_gl.deleteBuffer(geometry.__webglNormalBuffer);geometry.__webglNormalBuffer = undefined;}\n if (geometry.__webglTangentBuffer !== undefined) {_gl.deleteBuffer(geometry.__webglTangentBuffer);geometry.__webglTangentBuffer = undefined;}\n if (geometry.__webglColorBuffer !== undefined) {_gl.deleteBuffer(geometry.__webglColorBuffer);geometry.__webglColorBuffer = undefined;}\n if (geometry.__webglUVBuffer !== undefined) {_gl.deleteBuffer(geometry.__webglUVBuffer);geometry.__webglUVBuffer = undefined;}\n if (geometry.__webglUV2Buffer !== undefined) {_gl.deleteBuffer(geometry.__webglUV2Buffer);geometry.__webglUV2Buffer = undefined;}\n\n if (geometry.__webglSkinIndicesBuffer !== undefined) {_gl.deleteBuffer(geometry.__webglSkinIndicesBuffer);geometry.__webglSkinIndicesBuffer = undefined;}\n if (geometry.__webglSkinWeightsBuffer !== undefined) {_gl.deleteBuffer(geometry.__webglSkinWeightsBuffer);geometry.__webglSkinWeightsBuffer = undefined;}\n\n if (geometry.__webglFaceBuffer !== undefined) {_gl.deleteBuffer(geometry.__webglFaceBuffer);geometry.__webglFaceBuffer = undefined;}\n if (geometry.__webglLineBuffer !== undefined) {_gl.deleteBuffer(geometry.__webglLineBuffer);geometry.__webglLineBuffer = undefined;}\n\n if (geometry.__webglLineDistanceBuffer !== undefined) {_gl.deleteBuffer(geometry.__webglLineDistanceBuffer);geometry.__webglLineDistanceBuffer = undefined;}\n // custom attributes\n\n if (geometry.__webglCustomAttributesList !== undefined) {\n\n for (var name in geometry.__webglCustomAttributesList) {\n\n _gl.deleteBuffer(geometry.__webglCustomAttributesList[name].buffer);\n\n }\n geometry.__webglCustomAttributesList = undefined;\n }\n\n _this.info.memory.geometries--;\n\n };\n\n\n var deallocateGeometry = function deallocateGeometry(geometry) {\n\n geometry.__webglInit = undefined;\n\n var i, len, m, ml;\n\n if (geometry instanceof THREE.BufferGeometry) {\n\n //[Firefly] Delete interleaved buffer\n if (geometry.vbbuffer !== undefined) {\n _gl.deleteBuffer(geometry.vbbuffer);\n geometry.vbbuffer = undefined;\n }\n\n //[Firefly] Delete index buffer (if not stored in vertex attribute object)\n if (geometry.ibbuffer !== undefined) {\n _gl.deleteBuffer(geometry.ibbuffer);\n geometry.ibbuffer = undefined;\n }\n if (geometry.iblinesbuffer !== undefined) {\n _gl.deleteBuffer(geometry.iblinesbuffer);\n geometry.iblinesbuffer = undefined;\n }\n\n //[Firefly] Delete vertex array objects.\n if (geometry.vaos) {\n for (i = 0; i < geometry.vaos.length; i++) {\n deleteVertexArray(geometry.vaos[i].vao);\n }\n geometry.vaos = undefined;\n }\n\n var attributes = geometry.attributes;\n\n for (var key in attributes) {\n\n if (attributes[key].buffer !== undefined) {\n\n _gl.deleteBuffer(attributes[key].buffer);\n attributes[key].buffer = undefined;\n }\n\n }\n\n _this.info.memory.geometries--;\n\n } else {\n\n var geometryGroupsList = geometryGroups[geometry.id];\n\n if (geometryGroupsList !== undefined) {\n\n for (i = 0, len = geometryGroupsList.length; i < len; i++) {\n\n var geometryGroup = geometryGroupsList[i];\n\n if (geometryGroup.numMorphTargets !== undefined) {\n\n for (m = 0, ml = geometryGroup.numMorphTargets; m < ml; m++) {\n\n _gl.deleteBuffer(geometryGroup.__webglMorphTargetsBuffers[m]);\n\n }\n\n delete geometryGroup.__webglMorphTargetsBuffers;\n\n }\n\n if (geometryGroup.numMorphNormals !== undefined) {\n\n for (m = 0, ml = geometryGroup.numMorphNormals; m < ml; m++) {\n\n _gl.deleteBuffer(geometryGroup.__webglMorphNormalsBuffers[m]);\n\n }\n\n delete geometryGroup.__webglMorphNormalsBuffers;\n\n }\n\n deleteBuffers(geometryGroup);\n\n }\n\n delete geometryGroups[geometry.id];\n\n } else {\n\n deleteBuffers(geometry);\n\n }\n\n }\n\n };\n\n this.deallocateGeometry = deallocateGeometry;\n\n var deallocateTexture = function deallocateTexture(texture) {\n\n if (texture.__webglTextureCube) {\n\n // cube texture\n\n _gl.deleteTexture(texture.__webglTextureCube);\n texture.__webglTextureCube = undefined;\n\n } else {\n\n // 2D texture\n\n if (!texture.__webglInit) return;\n\n _gl.deleteTexture(texture.__webglTexture);\n texture.__webglInit = undefined;\n texture.__webglTexture = undefined;\n }\n\n };\n\n var deallocateRenderTarget = function deallocateRenderTarget(renderTarget) {\n\n if (!renderTarget || !renderTarget.__webglTexture) return;\n\n _gl.deleteTexture(renderTarget.__webglTexture);\n\n _gl.deleteFramebuffer(renderTarget.__webglFramebuffer);\n // if the z-buffer is shared among targets, the first deallocation will set this shared\n // value to be undefined. Avoid calling WebGL with undefined parameters.\n if (renderTarget.__webglRenderbuffer !== undefined) {\n _gl.deleteRenderbuffer(renderTarget.__webglRenderbuffer);\n }\n\n };\n\n var deallocateMaterial = function deallocateMaterial(material) {\n\n var deleteProgram = false;\n material.program = undefined;\n material.programs.forEach(function (wrapper) {\n\n var program;\n if (wrapper === undefined || (program = wrapper.program) == undefined)\n return;\n\n // only deallocate GL program if this was the last use of shared program\n // assumed there is only single copy of any program in the _programs list\n // (that's how it's constructed)\n\n var i, il, programInfo;\n\n for (i = 0, il = _programs.length; i < il; i++) {\n\n programInfo = _programs[i];\n\n if (programInfo && programInfo.program === program) {\n\n programInfo.usedTimes--;\n\n if (programInfo.usedTimes === 0) {\n\n _programs[i] = undefined;\n _gl.deleteProgram(program);\n _this.info.memory.programs--;\n deleteProgram = true;\n\n }\n\n break;\n\n }\n\n }\n\n }, false);\n\n material.programs.length = 0;\n\n if (deleteProgram) {\n\n // avoid using array.splice, this is costlier than creating new array from scratch\n\n _programs = _programs.filter(function (programInfo) {\n return programInfo !== undefined;\n });\n\n }\n\n };\n\n // Buffer initialization\n\n function initCustomAttributes(geometry, object) {\n\n var nvertices = geometry.vertices.length;\n\n var material = object.material;\n\n if (material.attributes) {\n\n if (geometry.__webglCustomAttributesList === undefined) {\n\n geometry.__webglCustomAttributesList = [];\n\n }\n\n for (var a in material.attributes) {\n\n var attribute = material.attributes[a];\n\n if (!attribute.__webglInitialized || attribute.createUniqueBuffers) {\n\n attribute.__webglInitialized = true;\n\n var size = 1; // \"f\" and \"i\"\n\n if (attribute.type === \"v2\") size = 2;else\n if (attribute.type === \"v3\") size = 3;else\n if (attribute.type === \"v4\") size = 4;else\n if (attribute.type === \"c\") size = 3;\n\n attribute.size = size;\n\n attribute.array = new Float32Array(nvertices * size);\n\n attribute.buffer = _gl.createBuffer();\n attribute.buffer.belongsToAttribute = a;\n\n attribute.needsUpdate = true;\n\n }\n\n geometry.__webglCustomAttributesList.push(attribute);\n\n }\n\n }\n\n }\n\n function initLineBuffers(geometry, object) {\n\n var nvertices = geometry.vertices.length;\n\n geometry.__vertexArray = new Float32Array(nvertices * 3);\n geometry.__colorArray = new Float32Array(nvertices * 3);\n geometry.__lineDistanceArray = new Float32Array(nvertices * 1);\n\n geometry.__webglLineCount = nvertices;\n\n initCustomAttributes(geometry, object);\n }\n\n function initPointCloudBuffers(geometry, object) {\n\n var nvertices = geometry.vertices.length;\n\n geometry.__vertexArray = new Float32Array(nvertices * 3);\n geometry.__colorArray = new Float32Array(nvertices * 3);\n\n geometry.__webglPointCount = nvertices;\n\n initCustomAttributes(geometry, object);\n }\n\n function initMeshBuffers(geometryGroup, object) {\n\n var geometry = object.geometry,\n faces3 = geometryGroup.faces3,\n\n nvertices = faces3.length * 3,\n ntris = faces3.length * 1,\n nlines = faces3.length * 3,\n\n material = getBufferMaterial(object, geometryGroup),\n\n uvType = bufferGuessUVType(material),\n normalType = bufferGuessNormalType(material),\n vertexColorType = bufferGuessVertexColorType(material);\n\n // THREE.log( \"uvType\", uvType, \"normalType\", normalType, \"vertexColorType\", vertexColorType, object, geometryGroup, material );\n\n geometryGroup.__vertexArray = new Float32Array(nvertices * 3);\n\n if (normalType) {\n\n geometryGroup.__normalArray = new Float32Array(nvertices * 3);\n\n }\n\n if (geometry.hasTangents) {\n\n geometryGroup.__tangentArray = new Float32Array(nvertices * 4);\n\n }\n\n if (vertexColorType) {\n\n geometryGroup.__colorArray = new Float32Array(nvertices * 3);\n\n }\n\n if (uvType) {\n\n if (geometry.faceVertexUvs.length > 0) {\n\n geometryGroup.__uvArray = new Float32Array(nvertices * 2);\n\n }\n\n if (geometry.faceVertexUvs.length > 1) {\n\n geometryGroup.__uv2Array = new Float32Array(nvertices * 2);\n\n }\n\n }\n\n if (object.geometry.skinWeights.length && object.geometry.skinIndices.length) {\n\n geometryGroup.__skinIndexArray = new Float32Array(nvertices * 4);\n geometryGroup.__skinWeightArray = new Float32Array(nvertices * 4);\n\n }\n\n var UintArray = (_isWebGL2 || extensions.get('OES_element_index_uint')) && ntris > 21845 ? Uint32Array : Uint16Array; // 65535 / 3\n\n geometryGroup.__typeArray = UintArray;\n geometryGroup.__faceArray = new UintArray(ntris * 3);\n geometryGroup.__lineArray = new UintArray(nlines * 2);\n\n geometryGroup.__webglFaceCount = ntris * 3;\n geometryGroup.__webglLineCount = nlines * 2;\n\n\n // custom attributes\n\n if (material.attributes) {\n\n if (geometryGroup.__webglCustomAttributesList === undefined) {\n\n geometryGroup.__webglCustomAttributesList = [];\n\n }\n\n for (var a in material.attributes) {\n\n // Do a shallow copy of the attribute object so different geometryGroup chunks use different\n // attribute buffers which are correctly indexed in the setMeshBuffers function\n\n var originalAttribute = material.attributes[a];\n\n var attribute = {};\n\n for (var property in originalAttribute) {\n\n attribute[property] = originalAttribute[property];\n\n }\n\n if (!attribute.__webglInitialized || attribute.createUniqueBuffers) {\n\n attribute.__webglInitialized = true;\n\n var size = 1; // \"f\" and \"i\"\n\n if (attribute.type === \"v2\") size = 2;else\n if (attribute.type === \"v3\") size = 3;else\n if (attribute.type === \"v4\") size = 4;else\n if (attribute.type === \"c\") size = 3;\n\n attribute.size = size;\n\n attribute.array = new Float32Array(nvertices * size);\n\n attribute.buffer = _gl.createBuffer();\n attribute.buffer.belongsToAttribute = a;\n\n originalAttribute.needsUpdate = true;\n attribute.__original = originalAttribute;\n\n }\n\n geometryGroup.__webglCustomAttributesList.push(attribute);\n\n }\n\n }\n\n geometryGroup.__inittedArrays = true;\n\n }\n\n function getBufferMaterial(object, geometryGroup) {\n\n return object.material instanceof THREE.MeshFaceMaterial ?\n object.material.materials[geometryGroup.materialIndex] : object.material;\n\n }\n\n function materialNeedsSmoothNormals(material) {\n\n return material && material.shading !== undefined && material.shading === THREE.SmoothShading;\n\n }\n\n function bufferGuessNormalType(material) {\n\n // only MeshBasicMaterial and MeshDepthMaterial don't need normals\n\n if (material instanceof THREE.MeshBasicMaterial && !material.envMap || material instanceof THREE.MeshDepthMaterial) {\n\n return false;\n\n }\n\n if (materialNeedsSmoothNormals(material)) {\n\n return THREE.SmoothShading;\n\n } else {\n\n return THREE.FlatShading;\n\n }\n\n }\n\n function bufferGuessVertexColorType(material) {\n\n if (material.vertexColors) {\n\n return material.vertexColors;\n\n }\n\n return false;\n\n }\n\n function bufferGuessUVType(material) {\n\n // material must use some texture to require uvs\n\n if (material.map ||\n material.lightMap ||\n material.bumpMap ||\n material.normalMap ||\n material.specularMap ||\n material.alphaMap ||\n material instanceof THREE.ShaderMaterial) {\n\n return true;\n\n }\n\n return false;\n\n }\n\n\n // Buffer setting\n\n\n function setLineBuffers(geometry, hint) {\n\n var v,c,d,vertex,offset,color,\n\n vertices = geometry.vertices,\n colors = geometry.colors,\n lineDistances = geometry.lineDistances,\n\n vl = vertices.length,\n cl = colors.length,\n dl = lineDistances.length,\n\n vertexArray = geometry.__vertexArray,\n colorArray = geometry.__colorArray,\n lineDistanceArray = geometry.__lineDistanceArray,\n\n dirtyVertices = geometry.verticesNeedUpdate,\n dirtyColors = geometry.colorsNeedUpdate,\n dirtyLineDistances = geometry.lineDistancesNeedUpdate,\n\n customAttributes = geometry.__webglCustomAttributesList,\n\n i,il,\n ca,cal,value,\n customAttribute;\n\n if (dirtyVertices) {\n\n for (v = 0; v < vl; v++) {\n\n vertex = vertices[v];\n\n offset = v * 3;\n\n vertexArray[offset] = vertex.x;\n vertexArray[offset + 1] = vertex.y;\n vertexArray[offset + 2] = vertex.z;\n\n }\n\n _gl.bindBuffer(_gl.ARRAY_BUFFER, geometry.__webglVertexBuffer);\n _gl.bufferData(_gl.ARRAY_BUFFER, vertexArray, hint);\n\n }\n\n if (dirtyColors) {\n\n for (c = 0; c < cl; c++) {\n\n color = colors[c];\n\n offset = c * 3;\n\n colorArray[offset] = color.r;\n colorArray[offset + 1] = color.g;\n colorArray[offset + 2] = color.b;\n\n }\n\n _gl.bindBuffer(_gl.ARRAY_BUFFER, geometry.__webglColorBuffer);\n _gl.bufferData(_gl.ARRAY_BUFFER, colorArray, hint);\n\n }\n\n if (dirtyLineDistances) {\n\n for (d = 0; d < dl; d++) {\n\n lineDistanceArray[d] = lineDistances[d];\n\n }\n\n _gl.bindBuffer(_gl.ARRAY_BUFFER, geometry.__webglLineDistanceBuffer);\n _gl.bufferData(_gl.ARRAY_BUFFER, lineDistanceArray, hint);\n\n }\n\n if (customAttributes) {\n\n for (i = 0, il = customAttributes.length; i < il; i++) {\n\n customAttribute = customAttributes[i];\n\n if (customAttribute.needsUpdate && (\n customAttribute.boundTo === undefined ||\n customAttribute.boundTo === \"vertices\")) {\n\n offset = 0;\n\n cal = customAttribute.value.length;\n\n if (customAttribute.size === 1) {\n\n for (ca = 0; ca < cal; ca++) {\n\n customAttribute.array[ca] = customAttribute.value[ca];\n\n }\n\n } else if (customAttribute.size === 2) {\n\n for (ca = 0; ca < cal; ca++) {\n\n value = customAttribute.value[ca];\n\n customAttribute.array[offset] = value.x;\n customAttribute.array[offset + 1] = value.y;\n\n offset += 2;\n\n }\n\n } else if (customAttribute.size === 3) {\n\n if (customAttribute.type === \"c\") {\n\n for (ca = 0; ca < cal; ca++) {\n\n value = customAttribute.value[ca];\n\n customAttribute.array[offset] = value.r;\n customAttribute.array[offset + 1] = value.g;\n customAttribute.array[offset + 2] = value.b;\n\n offset += 3;\n\n }\n\n } else {\n\n for (ca = 0; ca < cal; ca++) {\n\n value = customAttribute.value[ca];\n\n customAttribute.array[offset] = value.x;\n customAttribute.array[offset + 1] = value.y;\n customAttribute.array[offset + 2] = value.z;\n\n offset += 3;\n\n }\n\n }\n\n } else if (customAttribute.size === 4) {\n\n for (ca = 0; ca < cal; ca++) {\n\n value = customAttribute.value[ca];\n\n customAttribute.array[offset] = value.x;\n customAttribute.array[offset + 1] = value.y;\n customAttribute.array[offset + 2] = value.z;\n customAttribute.array[offset + 3] = value.w;\n\n offset += 4;\n\n }\n\n }\n\n _gl.bindBuffer(_gl.ARRAY_BUFFER, customAttribute.buffer);\n _gl.bufferData(_gl.ARRAY_BUFFER, customAttribute.array, hint);\n\n }\n\n }\n\n }\n\n }\n\n function setPointCloudBuffers(geometry, hint) {\n\n var v,c,vertex,offset,color,\n\n vertices = geometry.vertices,\n colors = geometry.colors,\n\n vl = vertices.length,\n cl = colors.length,\n\n vertexArray = geometry.__vertexArray,\n colorArray = geometry.__colorArray,\n\n dirtyVertices = geometry.verticesNeedUpdate,\n dirtyColors = geometry.colorsNeedUpdate,\n\n customAttributes = geometry.__webglCustomAttributesList,\n\n i,il,\n ca,cal,value,\n customAttribute;\n\n if (dirtyVertices) {\n\n for (v = 0; v < vl; v++) {\n\n vertex = vertices[v];\n\n offset = v * 3;\n\n vertexArray[offset] = vertex.x;\n vertexArray[offset + 1] = vertex.y;\n vertexArray[offset + 2] = vertex.z;\n\n }\n\n _gl.bindBuffer(_gl.ARRAY_BUFFER, geometry.__webglVertexBuffer);\n _gl.bufferData(_gl.ARRAY_BUFFER, vertexArray, hint);\n\n }\n\n if (dirtyColors) {\n\n for (c = 0; c < cl; c++) {\n\n color = colors[c];\n\n offset = c * 3;\n\n colorArray[offset] = color.r;\n colorArray[offset + 1] = color.g;\n colorArray[offset + 2] = color.b;\n\n }\n\n _gl.bindBuffer(_gl.ARRAY_BUFFER, geometry.__webglColorBuffer);\n _gl.bufferData(_gl.ARRAY_BUFFER, colorArray, hint);\n\n }\n\n if (customAttributes) {\n\n for (i = 0, il = customAttributes.length; i < il; i++) {\n\n customAttribute = customAttributes[i];\n\n if (customAttribute.needsUpdate && (\n customAttribute.boundTo === undefined ||\n customAttribute.boundTo === \"vertices\")) {\n\n offset = 0;\n\n cal = customAttribute.value.length;\n\n if (customAttribute.size === 1) {\n\n for (ca = 0; ca < cal; ca++) {\n\n customAttribute.array[ca] = customAttribute.value[ca];\n\n }\n\n } else if (customAttribute.size === 2) {\n\n for (ca = 0; ca < cal; ca++) {\n\n value = customAttribute.value[ca];\n\n customAttribute.array[offset] = value.x;\n customAttribute.array[offset + 1] = value.y;\n\n offset += 2;\n\n }\n\n } else if (customAttribute.size === 3) {\n\n if (customAttribute.type === \"c\") {\n\n for (ca = 0; ca < cal; ca++) {\n\n value = customAttribute.value[ca];\n\n customAttribute.array[offset] = value.r;\n customAttribute.array[offset + 1] = value.g;\n customAttribute.array[offset + 2] = value.b;\n\n offset += 3;\n\n }\n\n } else {\n\n for (ca = 0; ca < cal; ca++) {\n\n value = customAttribute.value[ca];\n\n customAttribute.array[offset] = value.x;\n customAttribute.array[offset + 1] = value.y;\n customAttribute.array[offset + 2] = value.z;\n\n offset += 3;\n\n }\n\n }\n\n } else if (customAttribute.size === 4) {\n\n for (ca = 0; ca < cal; ca++) {\n\n value = customAttribute.value[ca];\n\n customAttribute.array[offset] = value.x;\n customAttribute.array[offset + 1] = value.y;\n customAttribute.array[offset + 2] = value.z;\n customAttribute.array[offset + 3] = value.w;\n\n offset += 4;\n\n }\n\n }\n\n _gl.bindBuffer(_gl.ARRAY_BUFFER, customAttribute.buffer);\n _gl.bufferData(_gl.ARRAY_BUFFER, customAttribute.array, hint);\n\n }\n\n }\n\n }\n\n }\n\n function setMeshBuffers(geometryGroup, object, hint, dispose, material) {\n\n if (!geometryGroup.__inittedArrays) {\n\n return;\n\n }\n\n var normalType = bufferGuessNormalType(material),\n vertexColorType = bufferGuessVertexColorType(material),\n uvType = bufferGuessUVType(material),\n\n needsSmoothNormals = normalType === THREE.SmoothShading;\n\n var f,fl,fi,face,\n vertexNormals,faceNormal,\n vertexColors,faceColor,\n vertexTangents,\n uv,uv2,v1,v2,v3,t1,t2,t3,\n c1,c2,c3,\n i,il,\n vn,uvi,uv2i,\n\n vertexIndex = 0,\n\n offset = 0,\n offset_uv = 0,\n offset_uv2 = 0,\n offset_face = 0,\n offset_normal = 0,\n offset_tangent = 0,\n offset_line = 0,\n offset_color = 0,\n offset_custom = 0,\n\n value,\n\n vertexArray = geometryGroup.__vertexArray,\n uvArray = geometryGroup.__uvArray,\n uv2Array = geometryGroup.__uv2Array,\n normalArray = geometryGroup.__normalArray,\n tangentArray = geometryGroup.__tangentArray,\n colorArray = geometryGroup.__colorArray,\n\n customAttributes = geometryGroup.__webglCustomAttributesList,\n customAttribute,\n\n faceArray = geometryGroup.__faceArray,\n lineArray = geometryGroup.__lineArray,\n\n geometry = object.geometry, // this is shared for all chunks\n\n dirtyVertices = geometry.verticesNeedUpdate,\n dirtyElements = geometry.elementsNeedUpdate,\n dirtyUvs = geometry.uvsNeedUpdate,\n dirtyNormals = geometry.normalsNeedUpdate,\n dirtyTangents = geometry.tangentsNeedUpdate,\n dirtyColors = geometry.colorsNeedUpdate,\n\n vertices = geometry.vertices,\n chunk_faces3 = geometryGroup.faces3,\n obj_faces = geometry.faces,\n\n obj_uvs = geometry.faceVertexUvs[0],\n obj_uvs2 = geometry.faceVertexUvs[1];\n\n if (dirtyVertices) {\n\n for (f = 0, fl = chunk_faces3.length; f < fl; f++) {\n\n face = obj_faces[chunk_faces3[f]];\n\n v1 = vertices[face.a];\n v2 = vertices[face.b];\n v3 = vertices[face.c];\n\n vertexArray[offset] = v1.x;\n vertexArray[offset + 1] = v1.y;\n vertexArray[offset + 2] = v1.z;\n\n vertexArray[offset + 3] = v2.x;\n vertexArray[offset + 4] = v2.y;\n vertexArray[offset + 5] = v2.z;\n\n vertexArray[offset + 6] = v3.x;\n vertexArray[offset + 7] = v3.y;\n vertexArray[offset + 8] = v3.z;\n\n offset += 9;\n\n }\n\n _gl.bindBuffer(_gl.ARRAY_BUFFER, geometryGroup.__webglVertexBuffer);\n _gl.bufferData(_gl.ARRAY_BUFFER, vertexArray, hint);\n\n }\n\n\n if (dirtyColors && vertexColorType) {\n\n for (f = 0, fl = chunk_faces3.length; f < fl; f++) {\n\n face = obj_faces[chunk_faces3[f]];\n\n vertexColors = face.vertexColors;\n faceColor = face.color;\n\n if (vertexColors.length === 3 && vertexColorType === THREE.VertexColors) {\n\n c1 = vertexColors[0];\n c2 = vertexColors[1];\n c3 = vertexColors[2];\n\n } else {\n\n c1 = faceColor;\n c2 = faceColor;\n c3 = faceColor;\n\n }\n\n colorArray[offset_color] = c1.r;\n colorArray[offset_color + 1] = c1.g;\n colorArray[offset_color + 2] = c1.b;\n\n colorArray[offset_color + 3] = c2.r;\n colorArray[offset_color + 4] = c2.g;\n colorArray[offset_color + 5] = c2.b;\n\n colorArray[offset_color + 6] = c3.r;\n colorArray[offset_color + 7] = c3.g;\n colorArray[offset_color + 8] = c3.b;\n\n offset_color += 9;\n\n }\n\n if (offset_color > 0) {\n\n _gl.bindBuffer(_gl.ARRAY_BUFFER, geometryGroup.__webglColorBuffer);\n _gl.bufferData(_gl.ARRAY_BUFFER, colorArray, hint);\n\n }\n\n }\n\n if (dirtyTangents && geometry.hasTangents) {\n\n for (f = 0, fl = chunk_faces3.length; f < fl; f++) {\n\n face = obj_faces[chunk_faces3[f]];\n\n vertexTangents = face.vertexTangents;\n\n t1 = vertexTangents[0];\n t2 = vertexTangents[1];\n t3 = vertexTangents[2];\n\n tangentArray[offset_tangent] = t1.x;\n tangentArray[offset_tangent + 1] = t1.y;\n tangentArray[offset_tangent + 2] = t1.z;\n tangentArray[offset_tangent + 3] = t1.w;\n\n tangentArray[offset_tangent + 4] = t2.x;\n tangentArray[offset_tangent + 5] = t2.y;\n tangentArray[offset_tangent + 6] = t2.z;\n tangentArray[offset_tangent + 7] = t2.w;\n\n tangentArray[offset_tangent + 8] = t3.x;\n tangentArray[offset_tangent + 9] = t3.y;\n tangentArray[offset_tangent + 10] = t3.z;\n tangentArray[offset_tangent + 11] = t3.w;\n\n offset_tangent += 12;\n\n }\n\n _gl.bindBuffer(_gl.ARRAY_BUFFER, geometryGroup.__webglTangentBuffer);\n _gl.bufferData(_gl.ARRAY_BUFFER, tangentArray, hint);\n\n }\n\n if (dirtyNormals && normalType) {\n\n for (f = 0, fl = chunk_faces3.length; f < fl; f++) {\n\n face = obj_faces[chunk_faces3[f]];\n\n vertexNormals = face.vertexNormals;\n faceNormal = face.normal;\n\n if (vertexNormals.length === 3 && needsSmoothNormals) {\n\n for (i = 0; i < 3; i++) {\n\n vn = vertexNormals[i];\n\n normalArray[offset_normal] = vn.x;\n normalArray[offset_normal + 1] = vn.y;\n normalArray[offset_normal + 2] = vn.z;\n\n offset_normal += 3;\n\n }\n\n } else {\n\n for (i = 0; i < 3; i++) {\n\n normalArray[offset_normal] = faceNormal.x;\n normalArray[offset_normal + 1] = faceNormal.y;\n normalArray[offset_normal + 2] = faceNormal.z;\n\n offset_normal += 3;\n\n }\n\n }\n\n }\n\n _gl.bindBuffer(_gl.ARRAY_BUFFER, geometryGroup.__webglNormalBuffer);\n _gl.bufferData(_gl.ARRAY_BUFFER, normalArray, hint);\n\n }\n\n if (dirtyUvs && obj_uvs && uvType) {\n\n for (f = 0, fl = chunk_faces3.length; f < fl; f++) {\n\n fi = chunk_faces3[f];\n\n uv = obj_uvs[fi];\n\n if (uv === undefined) continue;\n\n for (i = 0; i < 3; i++) {\n\n uvi = uv[i];\n\n uvArray[offset_uv] = uvi.x;\n uvArray[offset_uv + 1] = uvi.y;\n\n offset_uv += 2;\n\n }\n\n }\n\n if (offset_uv > 0) {\n\n _gl.bindBuffer(_gl.ARRAY_BUFFER, geometryGroup.__webglUVBuffer);\n _gl.bufferData(_gl.ARRAY_BUFFER, uvArray, hint);\n\n }\n\n }\n\n if (dirtyUvs && obj_uvs2 && uvType) {\n\n for (f = 0, fl = chunk_faces3.length; f < fl; f++) {\n\n fi = chunk_faces3[f];\n\n uv2 = obj_uvs2[fi];\n\n if (uv2 === undefined) continue;\n\n for (i = 0; i < 3; i++) {\n\n uv2i = uv2[i];\n\n uv2Array[offset_uv2] = uv2i.x;\n uv2Array[offset_uv2 + 1] = uv2i.y;\n\n offset_uv2 += 2;\n\n }\n\n }\n\n if (offset_uv2 > 0) {\n\n _gl.bindBuffer(_gl.ARRAY_BUFFER, geometryGroup.__webglUV2Buffer);\n _gl.bufferData(_gl.ARRAY_BUFFER, uv2Array, hint);\n\n }\n\n }\n\n if (dirtyElements) {\n\n for (f = 0, fl = chunk_faces3.length; f < fl; f++) {\n\n faceArray[offset_face] = vertexIndex;\n faceArray[offset_face + 1] = vertexIndex + 1;\n faceArray[offset_face + 2] = vertexIndex + 2;\n\n offset_face += 3;\n\n lineArray[offset_line] = vertexIndex;\n lineArray[offset_line + 1] = vertexIndex + 1;\n\n lineArray[offset_line + 2] = vertexIndex;\n lineArray[offset_line + 3] = vertexIndex + 2;\n\n lineArray[offset_line + 4] = vertexIndex + 1;\n lineArray[offset_line + 5] = vertexIndex + 2;\n\n offset_line += 6;\n\n vertexIndex += 3;\n\n }\n\n _gl.bindBuffer(_gl.ELEMENT_ARRAY_BUFFER, geometryGroup.__webglFaceBuffer);\n _gl.bufferData(_gl.ELEMENT_ARRAY_BUFFER, faceArray, hint);\n\n _gl.bindBuffer(_gl.ELEMENT_ARRAY_BUFFER, geometryGroup.__webglLineBuffer);\n _gl.bufferData(_gl.ELEMENT_ARRAY_BUFFER, lineArray, hint);\n\n }\n\n if (customAttributes) {\n\n for (i = 0, il = customAttributes.length; i < il; i++) {\n\n customAttribute = customAttributes[i];\n\n if (!customAttribute.__original.needsUpdate) continue;\n\n offset_custom = 0;\n\n if (customAttribute.size === 1) {\n\n if (customAttribute.boundTo === undefined || customAttribute.boundTo === \"vertices\") {\n\n for (f = 0, fl = chunk_faces3.length; f < fl; f++) {\n\n face = obj_faces[chunk_faces3[f]];\n\n customAttribute.array[offset_custom] = customAttribute.value[face.a];\n customAttribute.array[offset_custom + 1] = customAttribute.value[face.b];\n customAttribute.array[offset_custom + 2] = customAttribute.value[face.c];\n\n offset_custom += 3;\n\n }\n\n } else if (customAttribute.boundTo === \"faces\") {\n\n for (f = 0, fl = chunk_faces3.length; f < fl; f++) {\n\n value = customAttribute.value[chunk_faces3[f]];\n\n customAttribute.array[offset_custom] = value;\n customAttribute.array[offset_custom + 1] = value;\n customAttribute.array[offset_custom + 2] = value;\n\n offset_custom += 3;\n\n }\n\n }\n\n } else if (customAttribute.size === 2) {\n\n if (customAttribute.boundTo === undefined || customAttribute.boundTo === \"vertices\") {\n\n for (f = 0, fl = chunk_faces3.length; f < fl; f++) {\n\n face = obj_faces[chunk_faces3[f]];\n\n v1 = customAttribute.value[face.a];\n v2 = customAttribute.value[face.b];\n v3 = customAttribute.value[face.c];\n\n customAttribute.array[offset_custom] = v1.x;\n customAttribute.array[offset_custom + 1] = v1.y;\n\n customAttribute.array[offset_custom + 2] = v2.x;\n customAttribute.array[offset_custom + 3] = v2.y;\n\n customAttribute.array[offset_custom + 4] = v3.x;\n customAttribute.array[offset_custom + 5] = v3.y;\n\n offset_custom += 6;\n\n }\n\n } else if (customAttribute.boundTo === \"faces\") {\n\n for (f = 0, fl = chunk_faces3.length; f < fl; f++) {\n\n value = customAttribute.value[chunk_faces3[f]];\n\n v1 = value;\n v2 = value;\n v3 = value;\n\n customAttribute.array[offset_custom] = v1.x;\n customAttribute.array[offset_custom + 1] = v1.y;\n\n customAttribute.array[offset_custom + 2] = v2.x;\n customAttribute.array[offset_custom + 3] = v2.y;\n\n customAttribute.array[offset_custom + 4] = v3.x;\n customAttribute.array[offset_custom + 5] = v3.y;\n\n offset_custom += 6;\n\n }\n\n }\n\n } else if (customAttribute.size === 3) {\n\n var pp;\n\n if (customAttribute.type === \"c\") {\n\n pp = [\"r\", \"g\", \"b\"];\n\n } else {\n\n pp = [\"x\", \"y\", \"z\"];\n\n }\n\n if (customAttribute.boundTo === undefined || customAttribute.boundTo === \"vertices\") {\n\n for (f = 0, fl = chunk_faces3.length; f < fl; f++) {\n\n face = obj_faces[chunk_faces3[f]];\n\n v1 = customAttribute.value[face.a];\n v2 = customAttribute.value[face.b];\n v3 = customAttribute.value[face.c];\n\n customAttribute.array[offset_custom] = v1[pp[0]];\n customAttribute.array[offset_custom + 1] = v1[pp[1]];\n customAttribute.array[offset_custom + 2] = v1[pp[2]];\n\n customAttribute.array[offset_custom + 3] = v2[pp[0]];\n customAttribute.array[offset_custom + 4] = v2[pp[1]];\n customAttribute.array[offset_custom + 5] = v2[pp[2]];\n\n customAttribute.array[offset_custom + 6] = v3[pp[0]];\n customAttribute.array[offset_custom + 7] = v3[pp[1]];\n customAttribute.array[offset_custom + 8] = v3[pp[2]];\n\n offset_custom += 9;\n\n }\n\n } else if (customAttribute.boundTo === \"faces\") {\n\n for (f = 0, fl = chunk_faces3.length; f < fl; f++) {\n\n value = customAttribute.value[chunk_faces3[f]];\n\n v1 = value;\n v2 = value;\n v3 = value;\n\n customAttribute.array[offset_custom] = v1[pp[0]];\n customAttribute.array[offset_custom + 1] = v1[pp[1]];\n customAttribute.array[offset_custom + 2] = v1[pp[2]];\n\n customAttribute.array[offset_custom + 3] = v2[pp[0]];\n customAttribute.array[offset_custom + 4] = v2[pp[1]];\n customAttribute.array[offset_custom + 5] = v2[pp[2]];\n\n customAttribute.array[offset_custom + 6] = v3[pp[0]];\n customAttribute.array[offset_custom + 7] = v3[pp[1]];\n customAttribute.array[offset_custom + 8] = v3[pp[2]];\n\n offset_custom += 9;\n\n }\n\n } else if (customAttribute.boundTo === \"faceVertices\") {\n\n for (f = 0, fl = chunk_faces3.length; f < fl; f++) {\n\n value = customAttribute.value[chunk_faces3[f]];\n\n v1 = value[0];\n v2 = value[1];\n v3 = value[2];\n\n customAttribute.array[offset_custom] = v1[pp[0]];\n customAttribute.array[offset_custom + 1] = v1[pp[1]];\n customAttribute.array[offset_custom + 2] = v1[pp[2]];\n\n customAttribute.array[offset_custom + 3] = v2[pp[0]];\n customAttribute.array[offset_custom + 4] = v2[pp[1]];\n customAttribute.array[offset_custom + 5] = v2[pp[2]];\n\n customAttribute.array[offset_custom + 6] = v3[pp[0]];\n customAttribute.array[offset_custom + 7] = v3[pp[1]];\n customAttribute.array[offset_custom + 8] = v3[pp[2]];\n\n offset_custom += 9;\n\n }\n\n }\n\n } else if (customAttribute.size === 4) {\n\n if (customAttribute.boundTo === undefined || customAttribute.boundTo === \"vertices\") {\n\n for (f = 0, fl = chunk_faces3.length; f < fl; f++) {\n\n face = obj_faces[chunk_faces3[f]];\n\n v1 = customAttribute.value[face.a];\n v2 = customAttribute.value[face.b];\n v3 = customAttribute.value[face.c];\n\n customAttribute.array[offset_custom] = v1.x;\n customAttribute.array[offset_custom + 1] = v1.y;\n customAttribute.array[offset_custom + 2] = v1.z;\n customAttribute.array[offset_custom + 3] = v1.w;\n\n customAttribute.array[offset_custom + 4] = v2.x;\n customAttribute.array[offset_custom + 5] = v2.y;\n customAttribute.array[offset_custom + 6] = v2.z;\n customAttribute.array[offset_custom + 7] = v2.w;\n\n customAttribute.array[offset_custom + 8] = v3.x;\n customAttribute.array[offset_custom + 9] = v3.y;\n customAttribute.array[offset_custom + 10] = v3.z;\n customAttribute.array[offset_custom + 11] = v3.w;\n\n offset_custom += 12;\n\n }\n\n } else if (customAttribute.boundTo === \"faces\") {\n\n for (f = 0, fl = chunk_faces3.length; f < fl; f++) {\n\n value = customAttribute.value[chunk_faces3[f]];\n\n v1 = value;\n v2 = value;\n v3 = value;\n\n customAttribute.array[offset_custom] = v1.x;\n customAttribute.array[offset_custom + 1] = v1.y;\n customAttribute.array[offset_custom + 2] = v1.z;\n customAttribute.array[offset_custom + 3] = v1.w;\n\n customAttribute.array[offset_custom + 4] = v2.x;\n customAttribute.array[offset_custom + 5] = v2.y;\n customAttribute.array[offset_custom + 6] = v2.z;\n customAttribute.array[offset_custom + 7] = v2.w;\n\n customAttribute.array[offset_custom + 8] = v3.x;\n customAttribute.array[offset_custom + 9] = v3.y;\n customAttribute.array[offset_custom + 10] = v3.z;\n customAttribute.array[offset_custom + 11] = v3.w;\n\n offset_custom += 12;\n\n }\n\n } else if (customAttribute.boundTo === \"faceVertices\") {\n\n for (f = 0, fl = chunk_faces3.length; f < fl; f++) {\n\n value = customAttribute.value[chunk_faces3[f]];\n\n v1 = value[0];\n v2 = value[1];\n v3 = value[2];\n\n customAttribute.array[offset_custom] = v1.x;\n customAttribute.array[offset_custom + 1] = v1.y;\n customAttribute.array[offset_custom + 2] = v1.z;\n customAttribute.array[offset_custom + 3] = v1.w;\n\n customAttribute.array[offset_custom + 4] = v2.x;\n customAttribute.array[offset_custom + 5] = v2.y;\n customAttribute.array[offset_custom + 6] = v2.z;\n customAttribute.array[offset_custom + 7] = v2.w;\n\n customAttribute.array[offset_custom + 8] = v3.x;\n customAttribute.array[offset_custom + 9] = v3.y;\n customAttribute.array[offset_custom + 10] = v3.z;\n customAttribute.array[offset_custom + 11] = v3.w;\n\n offset_custom += 12;\n\n }\n\n }\n\n }\n\n _gl.bindBuffer(_gl.ARRAY_BUFFER, customAttribute.buffer);\n _gl.bufferData(_gl.ARRAY_BUFFER, customAttribute.array, hint);\n\n }\n\n }\n\n if (dispose) {\n\n delete geometryGroup.__inittedArrays;\n delete geometryGroup.__colorArray;\n delete geometryGroup.__normalArray;\n delete geometryGroup.__tangentArray;\n delete geometryGroup.__uvArray;\n delete geometryGroup.__uv2Array;\n delete geometryGroup.__faceArray;\n delete geometryGroup.__vertexArray;\n delete geometryGroup.__lineArray;\n delete geometryGroup.__skinIndexArray;\n delete geometryGroup.__skinWeightArray;\n\n }\n\n }\n\n\n //[Firefly] This function is different from Three.js -- it adds\n //support for interleaved buffers and drawing from system memory\n //using a shared dynamic buffer.\n function setDirectBuffers(geometry) {\n\n //[Firefly]\n //Geometries that will draw directly\n //from system memory skip alocations of\n //GPU side GL buffers.\n if (geometry.streamingDraw) {\n\n //Do we want just the index buffer on the GPU?\n if (!geometry.streamingIndex) {\n var index = geometry.attributes.index;\n if (index) {\n index.buffer = _gl.createBuffer();\n _gl.bindBuffer(_gl.ELEMENT_ARRAY_BUFFER, index.buffer);\n _gl.bufferData(_gl.ELEMENT_ARRAY_BUFFER, index.array || geometry.ib, _gl.STATIC_DRAW);\n }\n }\n\n return;\n }\n\n\n //[Firefly]\n //Does the geometry have an interleaved\n //vertex buffer?\n if (geometry.vb && geometry.vbbuffer === undefined) {\n\n geometry.vbbuffer = _gl.createBuffer();\n geometry.vbNeedsUpdate = true;\n }\n //[Firefly] Is there an .ib property outside the index attribute (since we use globally shared attributes)?\n if (geometry.ib && geometry.ibbuffer === undefined) {\n geometry.ibbuffer = _gl.createBuffer();\n _gl.bindBuffer(_gl.ELEMENT_ARRAY_BUFFER, geometry.ibbuffer);\n _gl.bufferData(_gl.ELEMENT_ARRAY_BUFFER, geometry.ib, _gl.STATIC_DRAW);\n }\n if (geometry.iblines && geometry.iblinesbuffer === undefined) {\n geometry.iblinesbuffer = _gl.createBuffer();\n _gl.bindBuffer(_gl.ELEMENT_ARRAY_BUFFER, geometry.iblinesbuffer);\n _gl.bufferData(_gl.ELEMENT_ARRAY_BUFFER, geometry.iblines, _gl.STATIC_DRAW);\n }\n\n var attributes = geometry.attributes;\n var attributesKeys = geometry.attributesKeys;\n\n for (var i = 0, len = attributesKeys.length; i < len; i++) {\n\n var attributeName = attributesKeys[i];\n var attributeItem = attributes[attributeName];\n var isIndex = attributeName === 'index';\n\n if (attributeItem.array &&\n attributeItem.buffer === undefined) {\n\n attributeItem.buffer = _gl.createBuffer();\n attributeItem.needsUpdate = true;\n\n }\n\n if (attributeItem.needsUpdate === true) {\n\n var bufferType = isIndex ? _gl.ELEMENT_ARRAY_BUFFER : _gl.ARRAY_BUFFER;\n\n _gl.bindBuffer(bufferType, attributeItem.buffer);\n _gl.bufferData(bufferType, attributeItem.array, _gl.STATIC_DRAW);\n\n attributeItem.needsUpdate = false;\n\n }\n\n }\n\n //Update the common interleaved vb if needed\n if (geometry.vbNeedsUpdate) {\n\n _gl.bindBuffer(_gl.ARRAY_BUFFER, geometry.vbbuffer);\n _gl.bufferData(_gl.ARRAY_BUFFER, geometry.vb, _gl.STATIC_DRAW);\n geometry.vbNeedsUpdate = false;\n\n // free cpu-side copy (if wanted)\n if (geometry.discardAfterUpload) {\n geometry.vb = null;\n }\n }\n\n }\n\n //Wrappers for smoothing API differences between WebGL 1 and 2.\n\n function createVertexArray() {\n return _isWebGL2 ? _gl.createVertexArray() : _glExtensionVAO.createVertexArrayOES();\n }\n\n function bindVertexArray(vao) {\n _isWebGL2 ? _gl.bindVertexArray(vao) : _glExtensionVAO.bindVertexArrayOES(vao);\n }\n\n function deleteVertexArray(vao) {\n _isWebGL2 ? _gl.deleteVertexArray(vao) : _glExtensionVAO.deleteVertexArrayOES(vao);\n }\n\n function vertexAttribDivisor(programAttribute, numInstances, divisor) {\n if (_isWebGL2) {\n _gl.vertexAttribDivisor(programAttribute, numInstances ? divisor || 0 : 0);\n } else if (_glExtensionInstancedArrays) {\n _glExtensionInstancedArrays.vertexAttribDivisorANGLE(programAttribute, numInstances ? divisor || 0 : 0);\n }\n\n }\n\n function drawElementsInstanced(geomType, count, type, offset, numInstances) {\n if (_isWebGL2) {\n _gl.drawElementsInstanced(geomType, count, type, offset, numInstances);\n } else {\n _glExtensionInstancedArrays.drawElementsInstancedANGLE(geomType, count, type, offset, numInstances);\n }\n }\n\n function drawArraysInstanced(geomType, first, count, numInstances) {\n if (_isWebGL2) {\n _gl.drawArraysInstanced(geomType, first, count, numInstances);\n } else {\n _glExtensionInstancedArrays.drawArraysInstancedANGLE(geomType, first, count, numInstances);\n }\n }\n\n // Buffer rendering\n\n //[Firefly] Setup rendering of static model data using Vertex Array Objects\n //Currently we only do this for buffer geometry that is on GPU memory and has no\n //default material attributes and has a single draw batch (offsets array has length 1).\n //Other geometry passes through setupVertexAttributes instead, to set up\n //the vertex layout on every draw.\n function setupVAO(material, program, geometry, uvChannel) {\n\n var vao;\n\n if (!USE_VAO || geometry.streamingDraw) {\n geometry.vaos = null;\n return false;\n }\n\n if (!_isWebGL2 && !_glExtensionVAO) {\n geometry.vaos = null;\n return false;\n }\n\n if (geometry.vaos === undefined)\n geometry.vaos = [];\n\n //Set up a VAO for this object\n vao = createVertexArray();\n geometry.vaos.push({ geomhash: program.id, uv: uvChannel, vao: vao });\n bindVertexArray(vao);\n\n //bind the index buffer\n if (material.isEdgeMaterial) {\n _gl.bindBuffer(_gl.ELEMENT_ARRAY_BUFFER, geometry.iblinesbuffer);\n } else {\n var index = geometry.attributes.index;\n if (index)\n _gl.bindBuffer(_gl.ELEMENT_ARRAY_BUFFER, geometry.ibbuffer || index.buffer);\n }\n\n //Bind the vertex attributes used by the current program\n var boundBuffer = null;\n var programAttributes = program.attributes;\n var programAttributesKeys = program.attributesKeys;\n\n var stride = geometry.vbstride;\n var startIndex = geometry.offsets && geometry.offsets.length ? geometry.offsets[0].index : 0;\n var instanceStart = geometry.offsets && geometry.offsets.length ? geometry.offsets[0].instanceStart || 0 : 0;\n\n //Set up vertex attributes\n for (var i = 0, len = programAttributesKeys.length; i < len; i++) {\n\n var key = programAttributesKeys[i];\n var programAttribute = programAttributes[key];\n\n if (programAttribute >= 0) {\n\n var geometryAttribute = geometry.attributes[key];\n\n // Override 'uv' attribute mapping if uvChannel is specified\n // (account for the 1-based indexing used for the additional UV channel attributes)\n if (key === 'uv' && uvChannel) {\n geometryAttribute = geometry.attributes['uv' + (uvChannel + 1)];\n }\n\n if (geometryAttribute) {\n\n var type = _gl.FLOAT;\n var itemWidth = geometryAttribute.bytesPerItem || 4;\n if (itemWidth === 1) {\n type = _gl.UNSIGNED_BYTE;\n } else if (itemWidth === 2) {\n type = _gl.UNSIGNED_SHORT;\n }\n\n _gl.enableVertexAttribArray(programAttribute);\n\n var start = startIndex;\n if (geometryAttribute.divisor)\n start += instanceStart;\n if (geometryAttribute.itemOffset !== undefined) //it's part of the interleaved VB, so process it here\n {\n if (boundBuffer != geometry.vbbuffer) {\n _gl.bindBuffer(_gl.ARRAY_BUFFER, geometry.vbbuffer);\n boundBuffer = geometry.vbbuffer;\n }\n\n _gl.vertexAttribPointer(programAttribute, geometryAttribute.itemSize, type, !!geometryAttribute.normalize, stride * 4, (geometryAttribute.itemOffset + start * stride) * 4);\n } else\n {\n _gl.bindBuffer(_gl.ARRAY_BUFFER, geometryAttribute.buffer);\n boundBuffer = geometryAttribute.buffer;\n\n _gl.vertexAttribPointer(programAttribute, geometryAttribute.itemSize, type, !!geometryAttribute.normalize, 0, start * geometryAttribute.itemSize * itemWidth); // 4 bytes per Float32\n }\n\n vertexAttribDivisor(programAttribute, geometry.numInstances, geometryAttribute.divisor);\n\n } else {\n\n //Default material attributes cannot be set in VAO, so we have to abort the VAO setup\n //and fall back to the regular setupVertexAttributes in draw loop way.\n //This is hopefully very rare.\n bindVertexArray(null);\n\n for (var j = 0; j < geometry.vaos.length; j++) {\n deleteVertexArray(geometry.vaos[j].vao);}\n\n geometry.vaos = null; //Flag it so we don't pass through here again.\n\n return false;\n }\n\n }\n }\n\n return true;\n }\n\n function activateVAO(material, program, geometry, uvChannel) {\n var vaos = geometry.vaos;\n\n if (vaos) {\n //The assumption is that this array is rarely bigger than one or two items,\n //so it's faster to do a search than use object hashmap based on geomhash.\n for (var i = 0, len = vaos.length; i < len; i++) {\n var cache = vaos[i];\n if (cache.geomhash === program.id && cache.uv === uvChannel) {\n bindVertexArray(cache.vao);\n return true;\n }\n }\n } else if (vaos === null) {\n return false;\n }\n\n return setupVAO(material, program, geometry, uvChannel);\n }\n\n\n function bindDynamic(dynBufName, srcData) {\n var boundBuffer = _dynamicBuffers[dynBufName];\n if (!boundBuffer) {\n boundBuffer = _gl.createBuffer();\n _dynamicBuffers[dynBufName] = boundBuffer;\n }\n\n _gl.bindBuffer(_gl.ARRAY_BUFFER, boundBuffer);\n _gl.bufferData(_gl.ARRAY_BUFFER, srcData, _gl.DYNAMIC_DRAW);\n\n return boundBuffer;\n }\n\n\n //[Firefly] This function is different from Three.js -- it adds\n //support for interleaved buffers and drawing from system memory\n //using a shared dynamic buffer.\n function setupVertexAttributes(material, program, geometry, startIndex, indices, uvChannel, instanceStart) {\n\n var programAttributes = program.attributes;\n var programAttributesKeys = program.attributesKeys;\n\n //Those two need to be unequal to begin with...\n var boundBuffer = 0;\n var interleavedBuffer;\n\n\n if (indices) {\n // indices (they can have a VBO even if the geometry part is streamed)\n if (!indices.buffer && geometry.streamingDraw) {\n var buffer = _dynamicBuffers.index;\n if (!buffer) {\n buffer = _gl.createBuffer();\n _dynamicBuffers.index = buffer;\n }\n\n //_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, null);\n _gl.bindBuffer(_gl.ELEMENT_ARRAY_BUFFER, buffer);\n\n if (material.isEdgeMaterial) {\n _gl.bufferData(_gl.ELEMENT_ARRAY_BUFFER, geometry.iblines, _gl.DYNAMIC_DRAW);\n } else {\n _gl.bufferData(_gl.ELEMENT_ARRAY_BUFFER, indices.array || geometry.ib, _gl.DYNAMIC_DRAW);\n }\n } else\n {\n if (material.isEdgeMaterial) {\n _gl.bindBuffer(_gl.ELEMENT_ARRAY_BUFFER, geometry.iblinesbuffer);\n } else {\n _gl.bindBuffer(_gl.ELEMENT_ARRAY_BUFFER, geometry.ibbuffer || indices.buffer);\n }\n }\n }\n\n\n //Set attributes\n for (var i = 0, len = programAttributesKeys.length; i < len; i++) {\n\n var key = programAttributesKeys[i];\n var programAttribute = programAttributes[key];\n\n if (programAttribute >= 0) {\n\n var geometryAttribute = geometry.attributes[key];\n if (key === 'uv' && uvChannel) {\n geometryAttribute = geometry.attributes['uv' + (uvChannel + 1)];\n }\n\n if (geometryAttribute) {\n\n var isInterleaved = geometryAttribute.itemOffset !== undefined;\n\n var stride, itemOffset;\n\n if (isInterleaved) {\n\n stride = geometry.vbstride;\n itemOffset = geometryAttribute.itemOffset;\n\n if (boundBuffer !== interleavedBuffer) {\n if (geometry.streamingDraw) {\n\n boundBuffer = bindDynamic('interleavedVB', geometry.vb);\n\n } else {\n\n boundBuffer = geometry.vbbuffer;\n _gl.bindBuffer(_gl.ARRAY_BUFFER, boundBuffer);\n\n }\n\n interleavedBuffer = boundBuffer;\n }\n\n } else {\n\n stride = geometryAttribute.itemSize;\n itemOffset = 0;\n\n if (geometry.streamingDraw) {\n\n boundBuffer = bindDynamic(key, geometryAttribute.array);\n\n } else {\n\n boundBuffer = geometryAttribute.buffer;\n _gl.bindBuffer(_gl.ARRAY_BUFFER, boundBuffer);\n\n }\n }\n\n var type = _gl.FLOAT;\n var itemWidth = geometryAttribute.bytesPerItem || 4;\n if (itemWidth === 1) {\n type = _gl.UNSIGNED_BYTE;\n } else if (itemWidth === 2) {\n type = _gl.UNSIGNED_SHORT;\n }\n\n if (isInterleaved)\n itemWidth = 4; //our interleaved buffers define stride in multiples of 4 bytes\n\n state.enableAttribute(programAttribute);\n var start = startIndex;\n if (geometryAttribute.divisor)\n start += instanceStart;\n _gl.vertexAttribPointer(programAttribute, geometryAttribute.itemSize, type, geometryAttribute.normalize, stride * itemWidth, (itemOffset + start * stride) * itemWidth);\n\n vertexAttribDivisor(programAttribute, geometry.numInstances, geometryAttribute.divisor);\n\n } else if (material.defaultAttributeValues) {\n\n var attr = material.defaultAttributeValues[key];\n\n if (attr && attr.length === 2) {\n\n _gl.vertexAttrib2fv(programAttribute, material.defaultAttributeValues[key]);\n\n } else if (attr && attr.length === 3) {\n\n _gl.vertexAttrib3fv(programAttribute, material.defaultAttributeValues[key]);\n\n } else if (attr && attr.length === 4) {\n\n _gl.vertexAttrib4fv(programAttribute, material.defaultAttributeValues[key]);\n\n }\n\n }\n }\n }\n\n state.disableUnusedAttributes();\n\n }\n\n\n // Buffer rendering\n\n this.renderBufferDirect = function (camera, lights, fog, material, geometry, object, uvChannel) {\n\n if (material.visible === false) return;\n\n if (material.isEdgeMaterial && !geometry.iblines) return;\n\n //updateObject(object);\n setDirectBuffers(object.geometry);\n\n var program = setProgram(camera, lights, fog, material, object);\n\n var geometryAttributes = geometry.attributes;\n\n var updateBuffers = false,\n wireframeBit = material.wireframe ? 1 : 0,\n geometryHash = 'direct_' + geometry.id + (uvChannel ? '/' + uvChannel : '') + '_' + program.id + '_' + wireframeBit;\n\n if (geometryHash !== _currentGeometryProgram) {\n\n _currentGeometryProgram = geometryHash;\n updateBuffers = true;\n\n }\n\n // By default, we do a single drawcall for the whole geometry.\n // Alternatively, geometry.offsets may specify one or more sub-drawcalls.\n var hasDrawCalls = geometry.offsets && geometry.offsets.length;\n\n // Even multiple draw-calls can usually be rendered with a single VAO or, if VAO is not available,\n // with only a single call to setupVertexAttirbutes().\n // Only exception is if the drawCalls require offsets into instanceBuffer or vertexBuffer.\n // In this case, we have to force setupVertexAttribute() call per drawCall and cannot use a fixed buffer setup.\n var updateBuffersPerDrawCall = hasDrawCalls && geometry.offsets.some(function (offset) {\n return offset.index >= 0 || offset.instanceStart >= 0;\n });\n\n var vao;\n\n if (updateBuffersPerDrawCall) {\n // Do not use VAO here, because we must call setupVertexAttributes() anyway.\n // Note that setVertexAttributes() must not be called when a VAO is bound. \n // 1. Because it's pointless if you already have the VAO set.\n // 2. Because state.enableAttribute() will modify the VAO scope instead of the global one. This is not expected\n // by WebGLState. As a consequence, the cache may think an attribute is enabled while it actually isn't.\n // Result is that the next mesh without VAO may just not show up.\n updateBuffers = true;\n } else {\n vao = activateVAO(material, program, geometry, uvChannel || 0);\n updateBuffers = updateBuffers && !vao;\n }\n\n if (updateBuffers) {\n state.initAttributes();\n }\n\n // render mesh\n\n var index = geometryAttributes.index;\n\n // indexed triangles\n var geomType;\n\n if (index) {\n\n var type, size;\n var ib = index.array ? index.array : geometry.ib;\n\n if (material.isEdgeMaterial) {\n index = geometryAttributes.indexlines;\n ib = geometry.iblines;\n }\n\n if (index.bytesPerItem) {\n size = index.bytesPerItem;\n if (size === 4) {\n // load the unsigned integer index buffer extension if needed.\n !_isWebGL2 && extensions.get('OES_element_index_uint');\n }\n } else {\n if (ib instanceof Uint32Array && (_isWebGL2 || extensions.get('OES_element_index_uint'))) {\n size = 4;\n } else {\n size = 2;\n }\n }\n\n if (size === 4) {\n type = _gl.UNSIGNED_INT;\n } else {\n type = _gl.UNSIGNED_SHORT;\n }\n\n\n var offsets = geometry.offsets;\n if (hasDrawCalls && material.isEdgeMaterial && !offsets[0].hasOwnProperty(\"edgeStart\")) {\n // This geometry isn't consolidated.\n offsets = null;\n }\n\n var i = 0;\n do\n {\n var startIndex, startOffset, count, instanceStart, numInstances;\n if (hasDrawCalls)\n {\n var offset = offsets[i];\n startIndex = offset.index;\n startOffset = material.isEdgeMaterial ? offset.edgeStart || 0 : offset.start;\n count = material.isEdgeMaterial ? offset.edgeCount || ib.length : offset.count;\n instanceStart = offset.instanceStart || 0;\n numInstances = offset.numInstances || geometry.numInstances;\n var p_uniforms = material.program.uniforms;\n if (p_uniforms.themingColor && 'themingColor' in offset) {\n var color = offset.themingColor;\n if (color instanceof THREE.Vector4) {\n _gl.uniform4f(p_uniforms.themingColor, color.x, color.y, color.z, color.w);\n } else {\n _gl.uniform4f(p_uniforms.themingColor, 0.0, 0.0, 0.0, 0.0);\n }\n }\n } else\n\n {\n startIndex = 0;\n startOffset = 0;\n count = ib.length;\n instanceStart = 0;\n numInstances = geometry.numInstances;\n }\n\n if (updateBuffers) {\n setupVertexAttributes(material, program, geometry, startIndex, index, uvChannel, instanceStart);\n\n // In most cases, it's sufficent to call setupVertexAttributes() just once in the first cycle.\n if (!updateBuffersPerDrawCall) {\n updateBuffers = false;\n }\n }\n\n // render indexed triangles\n geomType = _gl.TRIANGLES;\n if (geometry.isPoints)\n geomType = _gl.POINTS;else\n if (geometry.isLines || material.isEdgeMaterial)\n geomType = _gl.LINES;\n\n if (numInstances)\n drawElementsInstanced(geomType, count, type, startOffset * size, numInstances); // 2 bytes per Uint16\n else {\n _gl.drawElements(geomType, count, type, startOffset * size); // 2 bytes per Uint16\n\n }\n\n } while (offsets && ++i < offsets.length);\n\n // non-indexed triangles\n\n } else {\n\n if (geometry.offsets && geometry.offsets.length > 1) {\n console.error(\"Geometry with draw calls and no index buffer\");\n }\n\n if (updateBuffers) {\n\n setupVertexAttributes(material, program, geometry, 0, undefined, uvChannel, 0);\n }\n\n var position = geometry.attributes.position;\n\n // render non-indexed triangles\n geomType = _gl.TRIANGLES;\n if (geometry.isPoints)\n geomType = _gl.POINTS;else\n if (geometry.isLines || material.isEdgeMaterial)\n geomType = _gl.LINES;\n if (geometry.numInstances)\n drawArraysInstanced(geomType, 0, position.array.length / 3, geometry.numInstances);else\n {\n _gl.drawArrays(geomType, 0, position.array.length / position.itemSize);\n }\n\n }\n\n if (vao)\n bindVertexArray(null);\n };\n\n this.renderBuffer = function (camera, lights, fog, material, geometryGroup, object) {\n\n if (material.visible === false) return;\n\n // Don't draw regular geometry with the edgeMaterial - it doesn't work.\n if (material.isEdgeMaterial) return;\n\n updateObject(object);\n\n var program = setProgram(camera, lights, fog, material, object);\n\n var attributes = program.attributes;\n\n var updateBuffers = false,\n wireframeBit = material.wireframe ? 1 : 0,\n geometryGroupHash = geometryGroup.id + '_' + program.id + '_' + wireframeBit;\n\n if (geometryGroupHash !== _currentGeometryProgram) {\n\n _currentGeometryProgram = geometryGroupHash;\n updateBuffers = true;\n\n }\n\n if (updateBuffers) {\n\n state.initAttributes();\n\n }\n\n // vertices\n\n // We need to make sure the divisor is 0 when we use this path.\n function setVertexAttribute(index, size, type, normalized, stride, offset) {\n _gl.vertexAttribPointer(index, size, type, normalized, stride, offset);\n if (_glExtensionInstancedArrays) {\n _glExtensionInstancedArrays.vertexAttribDivisorANGLE(index, 0);\n }\n }\n\n if (!material.morphTargets && attributes.position >= 0) {\n\n if (updateBuffers) {\n\n _gl.bindBuffer(_gl.ARRAY_BUFFER, geometryGroup.__webglVertexBuffer);\n state.enableAttribute(attributes.position);\n setVertexAttribute(attributes.position, 3, _gl.FLOAT, false, 0, 0);\n\n }\n\n }\n\n\n if (updateBuffers) {\n\n // custom attributes\n\n // Use the per-geometryGroup custom attribute arrays which are setup in initMeshBuffers\n\n if (geometryGroup.__webglCustomAttributesList) {\n\n for (var i = 0, il = geometryGroup.__webglCustomAttributesList.length; i < il; i++) {\n\n var attribute = geometryGroup.__webglCustomAttributesList[i];\n\n if (attributes[attribute.buffer.belongsToAttribute] >= 0) {\n\n _gl.bindBuffer(_gl.ARRAY_BUFFER, attribute.buffer);\n state.enableAttribute(attributes[attribute.buffer.belongsToAttribute]);\n setVertexAttribute(attributes[attribute.buffer.belongsToAttribute], attribute.size, _gl.FLOAT, false, 0, 0);\n\n }\n\n }\n\n }\n\n\n // colors\n\n if (attributes.color >= 0) {\n\n if (object.geometry.colors.length > 0 || object.geometry.faces.length > 0) {\n\n _gl.bindBuffer(_gl.ARRAY_BUFFER, geometryGroup.__webglColorBuffer);\n state.enableAttribute(attributes.color);\n setVertexAttribute(attributes.color, 3, _gl.FLOAT, false, 0, 0);\n\n } else if (material.defaultAttributeValues) {\n\n\n _gl.vertexAttrib3fv(attributes.color, material.defaultAttributeValues.color);\n\n }\n\n }\n\n // normals\n\n if (attributes.normal >= 0) {\n\n _gl.bindBuffer(_gl.ARRAY_BUFFER, geometryGroup.__webglNormalBuffer);\n state.enableAttribute(attributes.normal);\n setVertexAttribute(attributes.normal, 3, _gl.FLOAT, false, 0, 0);\n\n }\n\n // tangents\n\n if (attributes.tangent >= 0) {\n\n _gl.bindBuffer(_gl.ARRAY_BUFFER, geometryGroup.__webglTangentBuffer);\n state.enableAttribute(attributes.tangent);\n setVertexAttribute(attributes.tangent, 4, _gl.FLOAT, false, 0, 0);\n\n }\n\n // uvs\n\n if (attributes.uv >= 0) {\n\n if (object.geometry.faceVertexUvs[0]) {\n\n _gl.bindBuffer(_gl.ARRAY_BUFFER, geometryGroup.__webglUVBuffer);\n state.enableAttribute(attributes.uv);\n setVertexAttribute(attributes.uv, 2, _gl.FLOAT, false, 0, 0);\n\n } else if (material.defaultAttributeValues) {\n\n\n _gl.vertexAttrib2fv(attributes.uv, material.defaultAttributeValues.uv);\n\n }\n\n }\n\n if (attributes.uv2 >= 0) {\n\n if (object.geometry.faceVertexUvs[1]) {\n\n _gl.bindBuffer(_gl.ARRAY_BUFFER, geometryGroup.__webglUV2Buffer);\n state.enableAttribute(attributes.uv2);\n setVertexAttribute(attributes.uv2, 2, _gl.FLOAT, false, 0, 0);\n\n } else if (material.defaultAttributeValues) {\n\n\n _gl.vertexAttrib2fv(attributes.uv2, material.defaultAttributeValues.uv2);\n\n }\n\n }\n\n // line distances\n\n if (attributes.lineDistance >= 0) {\n\n _gl.bindBuffer(_gl.ARRAY_BUFFER, geometryGroup.__webglLineDistanceBuffer);\n state.enableAttribute(attributes.lineDistance);\n setVertexAttribute(attributes.lineDistance, 1, _gl.FLOAT, false, 0, 0);\n\n }\n\n }\n\n state.disableUnusedAttributes();\n\n\n // render mesh\n\n if (object instanceof THREE.Mesh) {\n\n var type = geometryGroup.__typeArray === Uint32Array ? _gl.UNSIGNED_INT : _gl.UNSIGNED_SHORT;\n\n // wireframe\n\n if (material.wireframe) {\n\n state.setLineWidth(material.wireframeLinewidth * this.getPixelRatio());\n if (updateBuffers) _gl.bindBuffer(_gl.ELEMENT_ARRAY_BUFFER, geometryGroup.__webglLineBuffer);\n _gl.drawElements(_gl.LINES, geometryGroup.__webglLineCount, type, 0);\n\n // triangles\n\n } else {\n\n if (updateBuffers) _gl.bindBuffer(_gl.ELEMENT_ARRAY_BUFFER, geometryGroup.__webglFaceBuffer);\n _gl.drawElements(_gl.TRIANGLES, geometryGroup.__webglFaceCount, type, 0);\n\n }\n\n // render lines\n\n } else if (object instanceof THREE.Line) {\n\n var mode = object.mode === THREE.LineStrip ? _gl.LINE_STRIP : _gl.LINES;\n\n state.setLineWidth(material.linewidth * this.getPixelRatio());\n\n _gl.drawArrays(mode, 0, geometryGroup.__webglLineCount);\n\n // render particles\n\n } else if (object instanceof THREE.PointCloud) {\n\n _gl.drawArrays(_gl.POINTS, 0, geometryGroup.__webglPointCount);\n\n }\n };\n\n\n // Sorting\n\n // This method is for transparency\n function painterSortStable(a, b) {\n\n // first see if there's a render order set - if so, this takes precedence\n if (a.object.renderOrder !== b.object.renderOrder) {\n\n return a.object.renderOrder - b.object.renderOrder;\n\n // If render order are the same, then use z distance.\n // We want to render from farthest to nearest.\n } else if (a.z !== b.z) {\n\n return a.z - b.z;\n\n // if z distances match, then use id, for a consistent result\n } else {\n\n return a.id - b.id;\n\n }\n\n }\n\n // This method is for opaque objects\n function reversePainterSortStable(a, b) {\n\n // first see if there's a render order set - if so, this takes precedence\n if (a.object.renderOrder !== b.object.renderOrder) {\n\n return a.object.renderOrder - b.object.renderOrder;\n\n // Next, sort by material, for efficiency, to avoid state changes.\n // (Note this is not done for transparency, as back to front order is more significant.)\n } else if (a.material.id !== b.material.id) {\n\n return a.material.id - b.material.id;\n\n // If render order and material are the same, then use z distance.\n // To minimize processing fragments, we render roughly from nearest to farthest.\n // In this way, the closer objects cover pixels and so hide more distance objects.\n }if (a.z !== b.z) {\n\n return b.z - a.z;\n\n // if z distances match, then use id, for a consistent sorted result\n } else {\n\n return a.id - b.id;\n\n }\n\n }\n\n /* currently not used\n function numericalSort ( a, b ) {\n return b[ 0 ] - a[ 0 ];\n }\n */\n\n\n\n\n // Rendering\n\n this.render = function (scene, camera, renderTarget, forceClear, customLights) {\n\n if (camera instanceof THREE.Camera === false) {\n\n THREE.error('THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.');\n return;\n\n }\n\n // reset caching for this frame\n\n _currentGeometryProgram = '';\n _currentMaterialId = -1;\n _currentCamera = null;\n\n if (customLights !== undefined) {\n lights.length = 0;\n _lightsNeedUpdate = true;\n }\n\n var fog = scene.fog;\n\n // update scene graph\n\n if (scene.autoUpdate === true) scene.updateMatrixWorld();\n\n // update camera matrices and frustum\n\n if (camera.parent === undefined) camera.updateMatrixWorld();\n\n camera.matrixWorldInverse.getInverse(camera.matrixWorld);\n\n if (camera.worldUpTransform)\n _viewInverseEnv.multiplyMatrices(camera.worldUpTransform, camera.matrixWorld);else\n\n _viewInverseEnv.copy(camera.matrixWorld);\n\n _projScreenMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);\n _frustum.setFromMatrix(_projScreenMatrix);\n\n // update WebGL objects\n var renderImmediate = scene instanceof RenderBatch && scene.renderImmediate;\n\n if (!renderImmediate) {\n opaqueObjects.length = 0;\n transparentObjects.length = 0;\n\n projectObject(scene, _this.sortObjects === true, scene.forceVisible === true);\n\n // note: the following flag is never set in WebGLRenderer; this may change in the future\n if (_this.sortObjects === true) {\n opaqueObjects.sort(reversePainterSortStable);\n transparentObjects.sort(painterSortStable);\n }\n }\n\n if (_lightsNeedUpdate) {\n if (customLights && customLights.length)\n lights = customLights.slice();\n setupLights(lights);\n }\n\n //\n this.setRenderTarget(renderTarget);\n\n this.resetGLState();\n\n if (this.autoClear || forceClear) {\n\n this.clear(this.autoClearColor, this.autoClearDepth, this.autoClearStencil);\n\n }\n\n if (scene.overrideMaterial) {\n\n var overrideMaterial = scene.overrideMaterial;\n\n setMaterial(overrideMaterial);\n\n if (!renderImmediate) {\n renderObjects(opaqueObjects, camera, lights, fog, overrideMaterial);\n renderObjects(transparentObjects, camera, lights, fog, overrideMaterial);\n } else {\n renderObjectsImmediate(scene, \"\", camera, lights, fog, overrideMaterial);\n }\n\n } else {\n\n if (!renderImmediate) {\n // opaque pass (front-to-back order)\n state.setBlending(THREE.NoBlending);\n\n renderObjects(opaqueObjects, camera, lights, fog, null);\n\n // transparent pass (back-to-front order)\n\n renderObjects(transparentObjects, camera, lights, fog, null);\n } else {\n renderObjectsImmediate(scene, \"\", camera, lights, fog, null);\n }\n\n }\n\n if (scene.edgeMaterial) {\n\n _gl.depthFunc(_gl.LESS); //hope to avoid some line-on-line overdraw this way\n\n var _overrideMaterial = scene.edgeMaterial;\n\n setMaterial(_overrideMaterial);\n\n if (!renderImmediate) {\n renderObjects(opaqueObjects, camera, lights, fog, _overrideMaterial);\n renderObjects(transparentObjects, camera, lights, fog, _overrideMaterial);\n } else {\n renderObjectsImmediate(scene, \"\", camera, lights, fog, _overrideMaterial);\n }\n\n _gl.depthFunc(_gl.LEQUAL);\n\n }\n\n\n // Generate mipmap if we're using any kind of mipmap filtering\n if (renderTarget && renderTarget.generateMipmaps && renderTarget.minFilter !== THREE.NearestFilter && renderTarget.minFilter !== THREE.LinearFilter) {\n\n updateRenderTargetMipmap(renderTarget);\n\n }\n\n this.resetGLState();\n\n // Ensure depth buffer writing is enabled so it can be cleared on next render\n\n state.setDepthTest(true);\n state.setDepthWrite(true);\n\n // _gl.finish();\n\n };\n\n this.clearBlend = function () {\n state.setBlending(THREE.NoBlending);\n };\n\n this.setProgramPrefix = function (index, vertexPrefix, fragmentPrefix) {\n _programIndex = index;\n _vertexPrefix = vertexPrefix;\n _fragmentPrefix = fragmentPrefix;\n };\n\n this.getProgramPrefix = function () {\n return { programPrefix: _programIndex,\n vertexPrefix: _vertexPrefix,\n fragmentPrefix: _fragmentPrefix };\n };\n\n this.updateTimestamp = function (highResTimeStamp) {\n _highResTimeStamp = highResTimeStamp;\n };\n\n function renderBatchIterSort(m) {\n projectObject(m, true);\n }\n\n function renderBatchIterNoSort(m) {\n projectObject(m, false);\n }\n\n function projectObject(object, sortObjects, forceVisible) {\n\n var i, len;\n\n if (!forceVisible && object.visible === false)\n return;\n\n if (object instanceof THREE.Scene || object instanceof THREE.Group) {\n\n // skip\n\n } else if (object instanceof RenderBatch) {\n\n object.forEach(sortObjects ? renderBatchIterSort : renderBatchIterNoSort);\n\n } else {\n\n initObject(object);\n\n if (object instanceof THREE.Light) {\n\n lights.push(object);\n\n } else {\n\n var webglObjects = _webglObjects[object.id];\n\n if (webglObjects && (object.frustumCulled === false || _frustum.intersectsObject(object) === true)) {\n\n for (i = 0, len = webglObjects.length; i < len; i++) {\n\n var webglObject = webglObjects[i];\n\n unrollBufferMaterial(webglObject);\n\n webglObject.render = true;\n\n if (sortObjects === true) {\n\n _vector3.setFromMatrixPosition(object.matrixWorld);\n _vector3.applyProjection(_projScreenMatrix);\n webglObject.z = _vector3.z;\n\n }\n\n }\n\n }\n\n }\n\n }\n\n if (object.children) {\n\n for (i = 0, len = object.children.length; i < len; i++) {\n\n projectObject(object.children[i], sortObjects, forceVisible);\n\n }\n\n }\n\n }\n\n // depending on the original material of a shape, we use either the main\n // override directly or a custom variant (if needed).\n function chooseOverrideMaterial(shapeMaterial, overrideMaterial) {\n\n // if override material does not define custom variants, there is nothing to do\n if (!overrideMaterial.getCustomOverrideMaterial) {\n return overrideMaterial;\n }\n\n // check if a custom override material should be used\n var customOverride = overrideMaterial.getCustomOverrideMaterial(shapeMaterial);\n if (!customOverride) {\n return overrideMaterial;\n }\n\n // use alternative variant\n return customOverride;\n }\n\n function renderObjects(renderList, camera, lights, fog, overrideMaterial) {\n\n var material;\n\n //TODO: we have to iterate upwards in order to preserve draw order for 2d\n //without having to sort the scene. Figure out how to keep the reverse iteration so that\n //we are consistent with three.js\n for (var i = 0, iEnd = renderList.length; i < iEnd; i++) {\n //for ( var i = renderList.length - 1; i !== - 1; i -- ) {\n\n var webglObject = renderList[i];\n\n var object = webglObject.object;\n var buffer = webglObject.buffer;\n\n if (overrideMaterial) {\n // either use overrideMaterial or a custom variant if needed for this render item\n material = chooseOverrideMaterial(webglObject.material, overrideMaterial);\n } else {\n\n material = webglObject.material;\n\n if (!material) continue;\n\n setMaterial(material);\n }\n\n // If the object is transparent, render it in two passes:\n // backfaces, then frontfaces. This helps avoid out-of-order sorting\n // transparency blending artifacts (these still can occur for pixels where\n // four or more triangles in a single mesh overlap the same pixel).\n // Also, check that depth testing is on; if not, we're in 2D mode and draw\n // order matters so we should not use this mode.\n // Else render normally.\n // See https://jira.autodesk.com/browse/LMV-1121\n if (material.twoPassTransparency)\n {\n var originalSide = material.side;\n // note we do NOT set material.needsUpdate to true, as the double-sided shader\n // works fine for back and front faces.\n material.side = THREE.BackSide;\n renderObjectsFace(material, camera, lights, fog, buffer, overrideMaterial, object);\n material.side = THREE.FrontSide;\n renderObjectsFace(material, camera, lights, fog, buffer, overrideMaterial, object);\n material.side = originalSide;\n } else\n\n {\n renderObjectsFace(material, camera, lights, fog, buffer, overrideMaterial, object);\n }\n }\n }\n\n function renderObjectsFace(material, camera, lights, fog, buffer, overrideMaterial, object)\n {\n _this.setMaterialFaces(material);\n\n if (buffer instanceof THREE.BufferGeometry) {\n _this.renderBufferDirect(camera, lights, fog, material, buffer, object);\n } else {\n _this.renderBuffer(camera, lights, fog, material, buffer, object);\n }\n\n if (material.decals) {\n var decals = material.decals;\n for (var di = 0, dlen = decals.length; di < dlen; di++) {\n var decal = decals[di];\n material = decal.material;\n setMaterial(material);\n _this.setMaterialFaces(material);\n if (buffer instanceof THREE.BufferGeometry) {\n _this.renderBufferDirect(camera, lights, fog, material, buffer, object, decal.uv);\n }\n }\n }\n }\n\n var roi_camera, roi_lights, roi_fog, roi_overrideMaterial; // unused: roi_materialType,\n\n function renderImmediateCallback(m, idx) {\n\n if (m.visible && !m.hide) {\n var material;\n\n if (roi_overrideMaterial) {\n // either use overrideMaterial or a custom variant if needed for this render item\n material = chooseOverrideMaterial(m.material, roi_overrideMaterial);\n } else {\n\n material = m.material;\n\n if (!material) return;\n\n setMaterial(material);\n }\n\n // If the object is transparent, render it in two passes:\n // backfaces, then frontfaces. This helps avoid out-of-order sorting\n // transparency blending artifacts (these still can occur for pixels where\n // four or more triangles in a single mesh overlap the same pixel).\n // Also, check that depth testing is on; if not, we're in 2D mode and draw\n // order matters so we should not use this mode.\n // Else render normally.\n // See https://jira.autodesk.com/browse/LMV-1121\n if (material.twoPassTransparency)\n {\n var originalSide = material.side;\n // note we do NOT set material.needsUpdate to true, as the double-sided shader\n // works fine for back and front faces.\n material.side = THREE.BackSide;\n renderImmediateFace(m, material);\n material.side = THREE.FrontSide;\n renderImmediateFace(m, material);\n material.side = originalSide;\n } else\n\n {\n renderImmediateFace(m, material);\n }\n }\n }\n\n function renderImmediateFace(m, material)\n {\n _this.setMaterialFaces(material);\n _this.renderBufferDirect(roi_camera, roi_lights, roi_fog, material, m.geometry, m);\n\n if (material.decals) {\n var decals = material.decals;\n for (var di = 0, dlen = decals.length; di < dlen; di++) {\n var decal = decals[di];\n material = decal.material;\n setMaterial(material);\n _this.setMaterialFaces(material);\n _this.renderBufferDirect(roi_camera, roi_lights, roi_fog, material, m.geometry, m, decal.uv);\n }\n }\n }\n\n function renderObjectsImmediate(renderList, materialType, camera, lights, fog, overrideMaterial) {\n\n //roi_materialType = materialType;\n roi_camera = camera;\n roi_lights = lights;\n roi_fog = fog;\n roi_overrideMaterial = overrideMaterial || null;\n\n // not really \"forceVisible\"\n // it's really only for ground shadows, or custom modelQueue iteration passes\n // In such cases we use the MESH_VISIBLE bit instead of the actual current visibility of the mesh (which is dependent on the render pass being done)\n renderList.forEach(renderImmediateCallback, renderList.forceVisible ? 1 : 0x20 /* MESH_RENDERFLAG */, false);\n\n }\n\n\n function unrollBufferMaterial(globject) {\n\n var object = globject.object;\n var buffer = globject.buffer;\n\n var geometry = object.geometry;\n var material = object.material;\n\n if (material instanceof THREE.MeshFaceMaterial) {\n\n var materialIndex = geometry instanceof THREE.BufferGeometry ? 0 : buffer.materialIndex;\n\n material = material.materials[materialIndex];\n\n globject.material = material;\n\n if (material.transparent) {\n\n transparentObjects.push(globject);\n\n } else {\n\n opaqueObjects.push(globject);\n\n }\n\n } else if (material) {\n\n globject.material = material;\n\n if (material.transparent) {\n\n transparentObjects.push(globject);\n\n } else {\n\n opaqueObjects.push(globject);\n\n }\n\n }\n\n }\n\n\n\n // Objects adding\n\n function initObject(object) {\n\n if (object.__webglInit === undefined) {\n\n object.__webglInit = true;\n\n object.addEventListener('removed', onObjectRemoved);\n\n }\n\n var geometry = object.geometry;\n\n if (geometry === undefined) {\n\n // ImmediateRenderObject\n\n } else if (geometry.__webglInit === undefined) {\n\n geometry.__webglInit = true;\n geometry.addEventListener('dispose', onGeometryDispose);\n\n if (geometry instanceof THREE.BufferGeometry) {\n\n //\n\n } else if (object instanceof THREE.Mesh) {\n\n initGeometryGroups(object, geometry);\n\n } else if (object instanceof THREE.Line) {\n\n if (geometry.__webglVertexBuffer === undefined) {\n\n createLineBuffers(geometry);\n initLineBuffers(geometry, object);\n\n geometry.verticesNeedUpdate = true;\n geometry.colorsNeedUpdate = true;\n geometry.lineDistancesNeedUpdate = true;\n\n }\n } else if (object instanceof THREE.PointCloud) {\n\n if (geometry.__webglVertexBuffer === undefined) {\n\n createPointCloudBuffers(geometry);\n initPointCloudBuffers(geometry, object);\n\n geometry.verticesNeedUpdate = true;\n geometry.colorsNeedUpdate = true;\n }\n\n }\n\n }\n\n if (object.__webglActive === undefined) {\n\n object.__webglActive = true;\n\n if (object instanceof THREE.Mesh) {\n\n if (geometry instanceof THREE.BufferGeometry) {\n\n addBuffer(_webglObjects, geometry, object);\n\n } else if (geometry instanceof THREE.Geometry) {\n\n var geometryGroupsList = geometryGroups[geometry.id];\n\n for (var i = 0, len = geometryGroupsList.length; i < len; i++) {\n\n addBuffer(_webglObjects, geometryGroupsList[i], object);\n\n }\n\n }\n\n } else if (object instanceof THREE.Line || object instanceof THREE.PointCloud) {\n\n addBuffer(_webglObjects, geometry, object);\n\n }\n\n }\n\n }\n\n\n // Geometry splitting\n\n var geometryGroups = {};\n var geometryGroupCounter = 0;\n\n function makeGroups(geometry, usesFaceMaterial) {\n\n var maxVerticesInGroup = _isWebGL2 || extensions.get('OES_element_index_uint') ? 4294967296 : 65535;\n\n var groupHash,hash_map = {};\n\n var numMorphTargets = geometry.morphTargets ? geometry.morphTargets.length : 0;\n var numMorphNormals = geometry.morphNormals ? geometry.morphNormals.length : 0;\n\n var group;\n var groups = {};\n var groupsList = [];\n\n for (var f = 0, fl = geometry.faces.length; f < fl; f++) {\n\n var face = geometry.faces[f];\n var materialIndex = usesFaceMaterial ? face.materialIndex : 0;\n\n if (!(materialIndex in hash_map)) {\n\n hash_map[materialIndex] = { hash: materialIndex, counter: 0 };\n\n }\n\n groupHash = hash_map[materialIndex].hash + '_' + hash_map[materialIndex].counter;\n\n if (!(groupHash in groups)) {\n\n group = {\n id: geometryGroupCounter++,\n faces3: [],\n materialIndex: materialIndex,\n vertices: 0,\n numMorphTargets: numMorphTargets,\n numMorphNormals: numMorphNormals };\n\n\n groups[groupHash] = group;\n groupsList.push(group);\n\n }\n\n if (groups[groupHash].vertices + 3 > maxVerticesInGroup) {\n\n hash_map[materialIndex].counter += 1;\n groupHash = hash_map[materialIndex].hash + '_' + hash_map[materialIndex].counter;\n\n if (!(groupHash in groups)) {\n\n group = {\n id: geometryGroupCounter++,\n faces3: [],\n materialIndex: materialIndex,\n vertices: 0,\n numMorphTargets: numMorphTargets,\n numMorphNormals: numMorphNormals };\n\n\n groups[groupHash] = group;\n groupsList.push(group);\n\n }\n\n }\n\n groups[groupHash].faces3.push(f);\n groups[groupHash].vertices += 3;\n\n }\n\n return groupsList;\n\n }\n\n function initGeometryGroups(object, geometry) {\n\n var material = object.material,addBuffers = false;\n\n if (geometryGroups[geometry.id] === undefined || geometry.groupsNeedUpdate === true) {\n\n delete _webglObjects[object.id];\n\n geometryGroups[geometry.id] = makeGroups(geometry, material instanceof THREE.MeshFaceMaterial);\n\n geometry.groupsNeedUpdate = false;\n\n }\n\n var geometryGroupsList = geometryGroups[geometry.id];\n\n // create separate VBOs per geometry chunk\n\n for (var i = 0, il = geometryGroupsList.length; i < il; i++) {\n\n var geometryGroup = geometryGroupsList[i];\n\n // initialise VBO on the first access\n\n if (geometryGroup.__webglVertexBuffer === undefined) {\n\n createMeshBuffers(geometryGroup);\n initMeshBuffers(geometryGroup, object);\n\n geometry.verticesNeedUpdate = true;\n geometry.morphTargetsNeedUpdate = true;\n geometry.elementsNeedUpdate = true;\n geometry.uvsNeedUpdate = true;\n geometry.normalsNeedUpdate = true;\n geometry.tangentsNeedUpdate = true;\n geometry.colorsNeedUpdate = true;\n\n addBuffers = true;\n\n } else {\n\n addBuffers = false;\n\n }\n\n if (addBuffers || object.__webglActive === undefined) {\n\n addBuffer(_webglObjects, geometryGroup, object);\n\n }\n\n }\n\n object.__webglActive = true;\n\n }\n\n\n function addBuffer(objlist, buffer, object) {\n\n var id = object.id;\n objlist[id] = objlist[id] || [];\n objlist[id].push(\n {\n id: id,\n buffer: buffer,\n object: object,\n material: null,\n z: 0 });\n\n\n\n }\n\n // Objects updates\n\n // Objects updates\n\n function updateObject(object) {\n\n var geometry = object.geometry,customAttributesDirty,material;\n\n if (geometry instanceof THREE.BufferGeometry) {\n\n setDirectBuffers(geometry);\n\n } else if (object instanceof THREE.Mesh) {\n\n // check all geometry groups\n\n if (geometry.groupsNeedUpdate === true) {\n\n initGeometryGroups(object, geometry);\n\n }\n\n var geometryGroupsList = geometryGroups[geometry.id];\n\n for (var i = 0, il = geometryGroupsList.length; i < il; i++) {\n\n var geometryGroup = geometryGroupsList[i];\n\n material = getBufferMaterial(object, geometryGroup);\n\n customAttributesDirty = material.attributes && areCustomAttributesDirty(material);\n\n if (geometry.verticesNeedUpdate || geometry.morphTargetsNeedUpdate || geometry.elementsNeedUpdate ||\n geometry.uvsNeedUpdate || geometry.normalsNeedUpdate ||\n geometry.colorsNeedUpdate || geometry.tangentsNeedUpdate || customAttributesDirty) {\n\n setMeshBuffers(geometryGroup, object, _gl.DYNAMIC_DRAW, !geometry.dynamic, material);\n\n }\n\n }\n\n geometry.verticesNeedUpdate = false;\n geometry.morphTargetsNeedUpdate = false;\n geometry.elementsNeedUpdate = false;\n geometry.uvsNeedUpdate = false;\n geometry.normalsNeedUpdate = false;\n geometry.colorsNeedUpdate = false;\n geometry.tangentsNeedUpdate = false;\n\n material.attributes && clearCustomAttributes(material);\n\n } else if (object instanceof THREE.Line) {\n\n material = getBufferMaterial(object, geometry);\n\n customAttributesDirty = material.attributes && areCustomAttributesDirty(material);\n\n if (geometry.verticesNeedUpdate || geometry.colorsNeedUpdate || geometry.lineDistancesNeedUpdate || customAttributesDirty) {\n\n setLineBuffers(geometry, _gl.DYNAMIC_DRAW);\n\n }\n\n geometry.verticesNeedUpdate = false;\n geometry.colorsNeedUpdate = false;\n geometry.lineDistancesNeedUpdate = false;\n\n material.attributes && clearCustomAttributes(material);\n\n } else if (object instanceof THREE.PointCloud) {\n\n material = getBufferMaterial(object, geometry);\n\n customAttributesDirty = material.attributes && areCustomAttributesDirty(material);\n\n if (geometry.verticesNeedUpdate || geometry.colorsNeedUpdate || customAttributesDirty) {\n\n setPointCloudBuffers(geometry, _gl.DYNAMIC_DRAW);\n\n }\n\n geometry.verticesNeedUpdate = false;\n geometry.colorsNeedUpdate = false;\n\n material.attributes && clearCustomAttributes(material);\n }\n\n }\n\n // Objects updates - custom attributes check\n\n function areCustomAttributesDirty(material) {\n\n for (var name in material.attributes) {\n\n if (material.attributes[name].needsUpdate) return true;\n\n }\n\n return false;\n\n }\n\n function clearCustomAttributes(material) {\n\n for (var name in material.attributes) {\n\n material.attributes[name].needsUpdate = false;\n\n }\n\n }\n\n // Objects removal\n\n function removeObject(object) {\n\n if (object instanceof THREE.Mesh ||\n object instanceof THREE.PointCloud ||\n object instanceof THREE.Line) {\n\n delete _webglObjects[object.id];\n\n }\n\n delete object.__webglInit;\n delete object.__webglActive;\n\n }\n\n // Materials\n\n function getPrismClampFlags(parameters, material) {\n\n if (!material.textureMaps)\n return;\n\n for (var i = 0; i < PrismMaps.length; i++) {\n\n var name = PrismMaps[i];\n // note this code keys off the fact that textures end with \"_map\";\n // any new PRISM map materials should end with this suffix.\n var map = material.textureMaps[name + \"_map\"];\n\n if (!map)\n continue;\n\n var bools = map.textureObj.properties.booleans;\n\n parameters[name] = {\n S: !bools.texture_URepeat.values[0],\n T: !bools.texture_VRepeat.values[0] };\n\n }\n }\n\n var shaderIDs = {\n MeshDepthMaterial: 'depth',\n MeshNormalMaterial: 'normal',\n MeshBasicMaterial: 'firefly_basic',\n MeshLambertMaterial: 'lambert',\n MeshPhongMaterial: 'firefly_phong',\n LineBasicMaterial: 'firefly_basic',\n LineDashedMaterial: 'dashed',\n PointCloudMaterial: 'firefly_basic' };\n\n\n function initMaterial(material, lights, fog, object) {\n\n material.addEventListener('dispose', onMaterialDispose);\n\n var shaderID = shaderIDs[material.type];\n\n if (shaderID) {\n\n var shader = THREE.ShaderLib[shaderID];\n\n material.__webglShader = {\n uniforms: THREE.UniformsUtils.clone(shader.uniforms),\n vertexShader: shader.vertexShader,\n fragmentShader: shader.fragmentShader };\n\n\n } else {\n\n material.__webglShader = {\n uniforms: material.uniforms,\n vertexShader: material.vertexShader,\n fragmentShader: material.fragmentShader };\n\n }\n\n // heuristics to create shader parameters according to lights in the scene\n // (not to blow over maxLights budget)\n\n var maxLightCount = allocateLights(lights);\n\n //var maxBones = 0;//allocateBones( object );\n\n var parameters = {\n\n precision: _precisionVertex,\n precisionFragment: _precisionFragment,\n supportsVertexTextures: _supportsVertexTextures,\n haveTextureLod: _isWebGL2 || !!extensions.get(\"EXT_shader_texture_lod\"),\n loadingAnimationDuration: _loadingAnimationDuration,\n\n map: !!material.map,\n envMap: !!material.envMap,\n irradianceMap: !!material.irradianceMap,\n envIsSpherical: material.envMap && material.envMap.mapping == THREE.SphericalReflectionMapping,\n envGammaEncoded: material.envMap && material.envMap.GammaEncoded,\n irrGammaEncoded: material.irradianceMap && material.irradianceMap.GammaEncoded,\n envRGBM: material.envMap && material.envMap.RGBM,\n irrRGBM: material.irradianceMap && material.irradianceMap.RGBM,\n lightMap: !!material.lightMap,\n bumpMap: (_isWebGL2 || extensions.get(\"OES_standard_derivatives\")) && !!material.bumpMap,\n normalMap: (_isWebGL2 || extensions.get(\"OES_standard_derivatives\")) && !!material.normalMap,\n specularMap: !!material.specularMap,\n alphaMap: !!material.alphaMap,\n\n vertexColors: material.vertexColors,\n vertexIds: material.vertexIds,\n\n useInstancing: material.useInstancing,\n\n wideLines: material.wideLines,\n\n fog: fog,\n useFog: material.fog,\n //fogExp: fog instanceof THREE.FogExp2,\n\n sizeAttenuation: material.sizeAttenuation,\n\n maxDirLights: maxLightCount.directional,\n maxPointLights: maxLightCount.point,\n maxSpotLights: maxLightCount.spot,\n maxHemiLights: maxLightCount.hemi,\n\n alphaTest: material.alphaTest,\n metal: material.metal,\n clearcoat: material.clearcoat,\n wrapAround: material.wrapAround,\n doubleSided: material.side === THREE.DoubleSide,\n flipSided: material.side === THREE.BackSide,\n\n mrtNormals: material.mrtNormals,\n mrtIdBuffer: material.mrtIdBuffer,\n vertexPrefix: _vertexPrefix,\n fragmentPrefix: _fragmentPrefix,\n tonemapOutput: material.tonemapOutput,\n packedNormals: material.packedNormals,\n hatchPattern: !!material.hatchParams,\n\n // TODO_NOP should not be per mat\n numCutplanes: material.cutplanes ? material.cutplanes.length : 0,\n\n useTiling: material.useTiling,\n tilingRepeatRange: material.useTiling && material.tilingRepeatRange,\n hasRoundCorner: material.hasRoundCorner,\n useRandomOffset: material.useRandomOffset,\n\n // texture flags for clamp and invert for simple phong material\n // add as wanted/necessary\n mapInvert: material.map && material.map.invert,\n mapClampS: material.map && material.map.clampS,\n mapClampT: material.map && material.map.clampT,\n bumpMapClampS: material.bumpMap && material.bumpMap.clampS,\n bumpMapClampT: material.bumpMap && material.bumpMap.clampT,\n normalMapClampS: material.normalMap && material.normalMap.clampS,\n normalMapClampT: material.normalMap && material.normalMap.clampT,\n specularMapClampS: material.specularMap && material.specularMap.clampS,\n specularMapClampT: material.specularMap && material.specularMap.clampT,\n alphaMapInvert: material.alphaMap && material.alphaMap.invert,\n alphaMapClampS: material.alphaMap && material.alphaMap.clampS,\n alphaMapClampT: material.alphaMap && material.alphaMap.clampT };\n\n\n\n // texture flags for clamp for PRISM shader\n if (material.isPrismMaterial) {\n getPrismClampFlags(parameters, material);\n parameters.isPrism = true;\n }\n\n var chunks = [];\n\n if (shaderID) {\n\n chunks.push(shaderID);\n\n } else {\n\n chunks.push(material.fragmentShader);\n chunks.push(material.vertexShader);\n\n }\n\n //Append any custom defines to the shader cache key\n for (var d in material.defines) {\n\n chunks.push(d);\n chunks.push(material.defines[d]);\n\n }\n\n var p, pl;\n for (p in parameters) {\n\n chunks.push(p);\n chunks.push(parameters[p]);\n\n }\n\n var code = chunks.join();\n\n var program;\n\n // Check if code has been already compiled\n\n for (p = 0, pl = _programs.length; p < pl; p++) {\n\n var programInfo = _programs[p];\n\n if (programInfo.code === code) {\n\n program = programInfo;\n program.usedTimes++;\n\n break;\n\n }\n\n }\n\n if (program === undefined) {\n\n program = new WebGLProgram(_this, code, material, parameters);\n _programs.push(program);\n\n _this.info.memory.programs = _programs.length;\n\n }\n\n if (!material.programs)\n material.programs = [];\n material.programs[_programIndex] = program;\n\n\n if (!material.uniformsLists)\n material.uniformsLists = [];\n material.uniformsList = material.uniformsLists[_programIndex] = [];\n\n // to see which uniform name is at what location, uncomment\n // let dump = true;\n //if (dump) {\n // console.log(\"Uniform locations and names\");\n //}\n //let ic = 0;\n for (var u in material.__webglShader.uniforms) {\n\n var location = program.uniforms[u];\n\n if (location) {\n //if (dump) {\n // console.log(\"index: \" + (ic++) + \" has name: \" + u);\n //}\n material.uniformsList.push([material.__webglShader.uniforms[u], location]);\n }\n\n }\n\n }\n\n function setMaterial(material) {\n\n if (material.transparent === true) {\n\n state.setBlending(material.blending, material.blendEquation, material.blendSrc, material.blendDst, material.blendEquationAlpha, material.blendSrcAlpha, material.blendDstAlpha);\n\n } else {\n\n state.setBlending(THREE.NoBlending);\n\n }\n\n state.setDepthTest(material.depthTest);\n state.setDepthWrite(material.depthWrite);\n state.setPolygonOffset(material.polygonOffset, material.polygonOffsetFactor, material.polygonOffsetUnits);\n\n }\n\n\n function setProgram(camera, lights, fog, material, object) {\n\n _usedTextureUnits = 0;\n\n if (material.needsUpdate) {\n\n if (material.program) deallocateMaterial(material);\n\n initMaterial(material, lights, fog, object);\n material.needsUpdate = false;\n\n } else if (!material.programs[_programIndex])\n initMaterial(material, lights, fog, object);\n\n\n var refreshProgram = false;\n var refreshMaterial = false;\n var refreshLights = false;\n\n material.uniformsList = material.uniformsLists[_programIndex];\n var program = material.program = material.programs[_programIndex],\n p_uniforms = program.uniforms,\n m_uniforms = material.__webglShader.uniforms;\n\n if (program.id !== _currentProgram) {\n\n _gl.useProgram(program.program);\n _currentProgram = program.id;\n\n refreshProgram = true;\n refreshMaterial = true;\n refreshLights = true;\n\n }\n\n if (material.id !== _currentMaterialId) {\n\n if (_currentMaterialId === -1) refreshLights = true;\n _currentMaterialId = material.id;\n\n refreshMaterial = true;\n\n }\n\n if (p_uniforms.meshAnimTime) {\n var meshAnimTime = 1.0; // In case no creationTime value is found, keep it 1.0, so it won't have animation.\n\n if (object.geometry.creationTime && _loadingAnimationDuration > 0) {\n meshAnimTime = Math.min((_highResTimeStamp - object.geometry.creationTime) / _loadingAnimationDuration, 1.0);\n }\n\n _gl.uniform1f(p_uniforms.meshAnimTime, meshAnimTime);\n }\n\n if (refreshProgram || camera !== _currentCamera) {\n\n _gl.uniformMatrix4fv(p_uniforms.projectionMatrix, false, camera.projectionMatrix.elements);\n\n if (camera !== _currentCamera) _currentCamera = camera;\n\n\n // load material specific uniforms\n // (shader material also gets them for the sake of genericity)\n\n if (material instanceof THREE.ShaderMaterial ||\n material instanceof THREE.MeshPhongMaterial ||\n material.isPrismMaterial ||\n material.envMap) {\n\n if (p_uniforms.cameraPosition !== null) {\n\n _vector3.setFromMatrixPosition(camera.matrixWorld);\n _gl.uniform3f(p_uniforms.cameraPosition, _vector3.x, _vector3.y, _vector3.z);\n\n }\n\n }\n\n if (material instanceof THREE.MeshPhongMaterial ||\n material instanceof THREE.MeshLambertMaterial ||\n material instanceof THREE.ShaderMaterial ||\n material.isPrismMaterial ||\n material.skinning) {\n\n if (p_uniforms.viewMatrix !== null) {\n\n _gl.uniformMatrix4fv(p_uniforms.viewMatrix, false, camera.matrixWorldInverse.elements);\n\n }\n\n //NOTE: viewMatrixInverse is only used for transforming normal vectors\n //for sampling environment textures. This is why we do not use camera.matrixWorld here,\n //but a combination of camera.matrixWorld plus a rotation to make Y the up vector, so that\n //the top of the scene (whichever axis is up) results in sampling the top of the environment map.\n //If viewMatrixInverse is needed for other things in the shader, then we will need a second\n //uniform that does not include the world-up rotation, or apply a consistent world up rotation\n //to all geometries in the scene.\n if (p_uniforms.viewMatrixInverse !== null) {\n\n _gl.uniformMatrix4fv(p_uniforms.viewMatrixInverse, false, _viewInverseEnv.elements);\n\n }\n\n if (p_uniforms.mvpMatrix) {\n\n _gl.uniformMatrix4fv(p_uniforms.mvpMatrix, false, _projScreenMatrix.elements);\n\n }\n\n if (refreshLights) {\n refreshUniformsIBL(m_uniforms, material);\n markUniformsIBLNeedsUpdate(m_uniforms, true);\n } else {\n markUniformsIBLNeedsUpdate(m_uniforms, false);\n }\n\n }\n\n }\n\n //For some reason this needs to happen here, before refreshMaterial,\n //in order to use a good texture slot for the tIdColor texture. If it happens\n //after the dbId uniform handling below, rendering becomes terribly slow.\n if (p_uniforms.unpackXform) {\n var g = object.geometry;\n var t = g.unpackXform;\n if (t)\n _gl.uniform4f(p_uniforms.unpackXform, t.x, t.y, t.z, t.w);else\n\n _gl.uniform4f(p_uniforms.unpackXform, 1, 1, 0, 0);\n\n if (p_uniforms.tIdColor) {\n _gl.uniform2f(p_uniforms.vIdColorTexSize, g.vIdColorTexSize.x, g.vIdColorTexSize.y);\n\n var unit = getTextureUnit();\n _gl.uniform1i(p_uniforms.tIdColor, unit);\n _this.setTexture(g.tIdColor, unit);\n }\n\n }\n\n\n if (refreshMaterial) {\n\n // refresh uniforms common to several materials\n\n if (material instanceof THREE.MeshPhongMaterial ||\n material instanceof THREE.MeshLambertMaterial ||\n material.isPrismMaterial ||\n material.lights) {\n\n if (_lightsNeedUpdate) {\n\n refreshLights = true;\n setupLights(lights);\n _lightsNeedUpdate = false;\n\n }\n\n if (refreshLights) {\n refreshUniformsLights(m_uniforms, _lights);\n markUniformsLightsNeedsUpdate(m_uniforms, true);\n } else {\n markUniformsLightsNeedsUpdate(m_uniforms, false);\n }\n\n }\n\n if (material instanceof THREE.MeshBasicMaterial ||\n material instanceof THREE.MeshLambertMaterial ||\n material instanceof THREE.MeshPhongMaterial) {\n\n refreshUniformsCommon(m_uniforms, material);\n refreshUniformsIBL(m_uniforms, material);\n }\n\n // refresh single material specific uniforms\n\n if (material instanceof THREE.PointCloudMaterial) {\n\n refreshUniformsPointCloud(m_uniforms, material);\n\n } else if (material instanceof THREE.LineBasicMaterial) {\n\n refreshUniformsLine(m_uniforms, material);\n\n } else if (material instanceof THREE.LineDashedMaterial) {\n\n refreshUniformsLine(m_uniforms, material);\n refreshUniformsDash(m_uniforms, material);\n\n } else if (material instanceof THREE.MeshPhongMaterial) {\n\n refreshUniformsPhong(m_uniforms, material);\n\n } else if (material instanceof THREE.MeshLambertMaterial) {\n\n refreshUniformsLambert(m_uniforms, material);\n\n } else if (material instanceof THREE.MeshDepthMaterial) {\n\n m_uniforms.mNear.value = camera.near;\n m_uniforms.mFar.value = camera.far;\n m_uniforms.opacity.value = material.opacity;\n\n } else if (material instanceof THREE.MeshNormalMaterial) {\n\n m_uniforms.opacity.value = material.opacity;\n\n } else if (material.isPrismMaterial) {\n\n refreshUniformsPrism(m_uniforms, material);\n refreshUniformsIBL(m_uniforms, material);\n\n } else if (typeof material.refreshUniforms === 'function') {\n material.refreshUniforms(m_uniforms);\n\n }\n if (material.wideLines) {\n var width = object.geometry.lineWidth;\n if (material.linewidth !== undefined)\n width = material.linewidth;\n m_uniforms.view_size.value = new THREE.Vector2(_window.innerWidth / width, _window.innerHeight / width);\n }\n\n if (shadowmap.ShadowRender && material.shadowMap) {\n shadowmap.ShadowRender.RefreshUniformsShadow(m_uniforms, material);\n }\n\n // TODO_NOP: direct assignment dangerous?\n var ucp = m_uniforms.cutplanes;\n if (material.cutplanes && material.cutplanes.length > 0 && ucp) {\n ucp.value = material.cutplanes;\n // Currently, Prism is implemented as shader material, its uniform is just init for once.\n // Remove the array component if cutplanes's length changed so it can be re-init.\n if (ucp._array && ucp._array.length != 4 * material.cutplanes)\n ucp._array = undefined;\n }\n\n if (material.hatchParams && m_uniforms.hatchParams) {\n m_uniforms.hatchParams.value.copy(material.hatchParams);\n m_uniforms.hatchTintColor.value.copy(material.hatchTintColor);\n m_uniforms.hatchTintIntensity.value = material.hatchTintIntensity;\n }\n\n // load common uniforms\n\n loadUniformsGeneric(material.uniformsList);\n\n }\n\n loadUniformsMatrices(p_uniforms, object, camera);\n\n var dbId;\n if (p_uniforms.modelId) {\n\n if (p_uniforms.dbId) {\n dbId = object.dbId || object.fragId || 0;\n _gl.uniform3f(p_uniforms.dbId, (dbId & 0xff) / 255,\n (dbId >> 8 & 0xff) / 255,\n (dbId >> 16 & 0xff) / 255);\n }\n var modelId = object.modelId;\n _gl.uniform3f(p_uniforms.modelId, (modelId & 0xff) / 255,\n (modelId >> 8 & 0xff) / 255,\n //we can encode the highest bits of the ID here, since the model ID will not really need more than 2 bytes\n (dbId >> 24 & 0xff) / 255);\n\n } else if (p_uniforms.dbId !== null) {\n\n dbId = object.dbId || object.fragId || 0;\n\n //The dbId is rendered to an RGB target, so the\n //uppermost byte of the dbId is dropped. Use a modelId\n //target if the full range is desired\n _gl.uniform3f(p_uniforms.dbId, (dbId & 0xff) / 255,\n (dbId >> 8 & 0xff) / 255,\n (dbId >> 16 & 0xff) / 255 /*,\n ((dbId >> 24) & 0xff) / 255*/);\n\n }\n\n // If a theming color uniform is defined, get it from the mesh.\n // Note that theming colors are Vector4 (not THREE.Color), because we need alpha for intensity.\n if (p_uniforms.themingColor) {\n var color = object.themingColor;\n if (color instanceof THREE.Vector4) {\n _gl.uniform4f(p_uniforms.themingColor, color.x, color.y, color.z, color.w);\n } else {\n _gl.uniform4f(p_uniforms.themingColor, 0.0, 0.0, 0.0, 0.0);\n }\n }\n\n return program;\n\n }\n\n // Uniforms (refresh uniforms objects)\n\n function refreshUniformsCommon(uniforms, material) {\n\n uniforms.opacity.value = material.opacity;\n\n\n uniforms.diffuse.value.copy(material.color);\n\n\n uniforms.map.value = material.map;\n uniforms.lightMap.value = material.lightMap;\n uniforms.specularMap.value = material.specularMap;\n uniforms.alphaMap.value = material.alphaMap;\n\n if (material.bumpMap) {\n\n uniforms.bumpMap.value = material.bumpMap;\n uniforms.bumpScale.value = material.bumpScale;\n\n }\n\n if (material.normalMap) {\n\n uniforms.normalMap.value = material.normalMap;\n uniforms.normalScale.value.copy(material.normalScale);\n\n }\n\n // uv repeat and offset setting priorities\n //\t1. color map\n //\t2. specular map\n //\t3. normal map\n //\t4. bump map\n // 5. alpha map\n\n //NOTE: We deviate from Three.js in that we allow\n //separate scales for diffuse/specular, alpha, and bump\n\n function setTexTransforms(uniforms, texMatrix, texture) {\n var offset = texture.offset;\n var repeat = texture.repeat;\n\n if (texMatrix) {\n var uMatrix = texMatrix.value;\n\n if (texture.matrix)\n uMatrix.copy(texture.matrix);else\n\n uMatrix.identity();\n\n uMatrix.elements[6] += offset.x;\n uMatrix.elements[7] += offset.y;\n uMatrix.elements[0] *= repeat.x;\n uMatrix.elements[3] *= repeat.x;\n uMatrix.elements[1] *= repeat.y;\n uMatrix.elements[4] *= repeat.y;\n } else\n {\n uniforms.offsetRepeat.value.set(offset.x, offset.y, repeat.x, repeat.y);\n }\n }\n\n if (material.alphaMap) {\n setTexTransforms(uniforms, uniforms.texMatrixAlpha, material.alphaMap);\n }\n\n var uvScaleMapBump;\n if (material.normalMap) {\n uvScaleMapBump = material.normalMap;\n } else if (material.bumpMap) {\n uvScaleMapBump = material.bumpMap;\n }\n if (uvScaleMapBump !== undefined) {\n setTexTransforms(uniforms, uniforms.texMatrixBump, uvScaleMapBump);\n }\n\n var uvScaleMap;\n if (material.map) {\n uvScaleMap = material.map;\n } else if (material.specularMap) {\n uvScaleMap = material.specularMap;\n }\n if (uvScaleMap !== undefined) {\n setTexTransforms(uniforms, uniforms.texMatrix, uvScaleMap);\n }\n\n uniforms.envMap.value = material.envMap;\n //uniforms.flipEnvMap.value = ( material.envMap instanceof THREE.WebGLRenderTargetCube ) ? 1 : -1;\n if (uniforms.irradianceMap) {\n uniforms.irradianceMap.value = material.irradianceMap;\n }\n\n uniforms.reflectivity.value = material.reflectivity;\n\n\n uniforms.refractionRatio.value = material.refractionRatio;\n\n }\n\n function refreshUniformsPointCloud(uniforms, material) {\n\n refreshUniformsLine(uniforms, material);\n uniforms.point_size.value = material.size;\n uniforms.map.value = material.map;\n }\n\n function refreshUniformsLine(uniforms, material) {\n\n uniforms.diffuse.value = material.color;\n uniforms.opacity.value = material.opacity;\n\n }\n\n function refreshUniformsDash(uniforms, material) {\n\n uniforms.dashSize.value = material.dashSize;\n uniforms.totalSize.value = material.dashSize + material.gapSize;\n uniforms.scale.value = material.scale;\n\n }\n\n function refreshUniformsIBL(uniforms, material) {\n if (uniforms.envMap)\n uniforms.envMap.value = material.envMap;\n //uniforms.flipEnvMap.value = ( material.envMap instanceof THREE.WebGLRenderTargetCube ) ? 1 : -1;\n if (uniforms.irradianceMap)\n uniforms.irradianceMap.value = material.irradianceMap;\n if (uniforms.envMapExposure)\n uniforms.envMapExposure.value = material.envMapExposure;\n if (uniforms.envRotationSin && uniforms.envRotationCos) {\n uniforms.envRotationSin.value = material.envRotationSin;\n uniforms.envRotationCos.value = material.envRotationCos;\n }\n }\n\n function markUniformsIBLNeedsUpdate(uniforms, boolean) {\n\n if (uniforms.envMap)\n uniforms.envMap.needsUpdate = boolean;\n //uniforms.flipEnvMap.value = ( material.envMap instanceof THREE.WebGLRenderTargetCube ) ? 1 : -1;\n if (uniforms.irradianceMap)\n uniforms.irradianceMap.needsUpdate = boolean;\n if (uniforms.envMapExposure)\n uniforms.envMapExposure.needsUpdate = boolean;\n }\n\n\n function refreshUniformsPhong(uniforms, material) {\n\n uniforms.shininess.value = material.shininess;\n\n //The environment cube map is blurred with the assumption that\n //max shininess is 2048 and every mip drops that by a factor of 4\n //\"float MipmapIndex = log(shininess / 2048.0) / log(0.25);\",\n //The simplification below was given in the original source for this method.\n //However, it does not seem to match the equation above, so we use a corrected one.\n //\"float MipmapIndex = max(0.0, -1.66096404744368 * logShiny + 5.5);\",\n //NOTE: Once roughness maps are supported, the computation will have to move to the shader.\n if (uniforms.reflMipIndex) {\n var logShiny = Math.log(Math.max(1.0 + 1e-10, material.shininess));\n uniforms.reflMipIndex.value = Math.max(0.0, -0.72134752 * logShiny + 5.5);\n }\n\n if (uniforms.emissive)\n uniforms.emissive.value.copy(material.emissive);\n\n uniforms.specular.value.copy(material.specular);\n\n //Not used by LMV\n /*\n if ( material.wrapAround ) {\n uniforms.wrapRGB.value.copy( material.wrapRGB );\n }\n */\n\n\n\n if (uniforms.exposureBias)\n uniforms.exposureBias.value = material.exposureBias;\n }\n\n function refreshUniformsPrism(uniforms, material) {\n\n function refreshPrismMapUniforms(uniforms, material, mapName) {\n uniforms[mapName].value = material[mapName];\n // yes, we want \"!=\" here, not \"!==\", as we test for both undefined and null\n if (material[mapName] != null)\n {\n uniforms[mapName + \"_texMatrix\"].value = material[mapName].matrix;\n uniforms[mapName + \"_invert\"].value = material[mapName].invert;\n }\n }\n\n function refreshPrismBumpMapUniforms(uniforms, material, mapName) {\n uniforms[mapName].value = material[mapName];\n // yes, we want \"!=\" here, not \"!==\", as we test for both undefined and null\n if (material[mapName] != null)\n {\n uniforms[mapName + \"_texMatrix\"].value = material[mapName].matrix;\n uniforms[mapName + \"_bumpScale\"].value = material[mapName].bumpScale;\n uniforms[mapName + \"_bumpmapType\"].value = material[mapName].bumpmapType;\n }\n }\n\n uniforms.exposureBias.value = material.exposureBias;\n uniforms.opacity.value = material.opacity;\n\n //Prism common properties.\n uniforms.surface_albedo.value = material.surface_albedo;\n uniforms.surface_roughness.value = material.surface_roughness;\n uniforms.surface_anisotropy.value = material.surface_anisotropy;\n uniforms.surface_rotation.value = material.surface_rotation;\n\n refreshPrismMapUniforms(uniforms, material, \"surface_albedo_map\");\n refreshPrismMapUniforms(uniforms, material, \"surface_roughness_map\");\n refreshPrismMapUniforms(uniforms, material, \"surface_cutout_map\");\n refreshPrismMapUniforms(uniforms, material, \"surface_anisotropy_map\");\n refreshPrismMapUniforms(uniforms, material, \"surface_rotation_map\");\n\n refreshPrismBumpMapUniforms(uniforms, material, \"surface_normal_map\");\n\n //Update Prism properties according to the material type.\n switch (material.prismType) {\n case 'PrismOpaque':\n uniforms.opaque_albedo.value = material.opaque_albedo;\n uniforms.opaque_luminance_modifier.value = material.opaque_luminance_modifier;\n uniforms.opaque_f0.value = material.opaque_f0;\n uniforms.opaque_luminance.value = material.opaque_luminance;\n\n refreshPrismMapUniforms(uniforms, material, \"opaque_albedo_map\");\n refreshPrismMapUniforms(uniforms, material, \"opaque_luminance_modifier_map\");\n refreshPrismMapUniforms(uniforms, material, \"opaque_f0_map\");\n\n break;\n\n case 'PrismMetal':\n uniforms.metal_f0.value = material.metal_f0;\n\n refreshPrismMapUniforms(uniforms, material, \"metal_f0_map\");\n\n break;\n\n case 'PrismLayered':\n uniforms.layered_f0.value = material.layered_f0;\n uniforms.layered_diffuse.value = material.layered_diffuse;\n uniforms.layered_fraction.value = material.layered_fraction;\n uniforms.layered_bottom_f0.value = material.layered_bottom_f0;\n uniforms.layered_roughness.value = material.layered_roughness;\n uniforms.layered_anisotropy.value = material.layered_anisotropy;\n uniforms.layered_rotation.value = material.layered_rotation;\n\n refreshPrismMapUniforms(uniforms, material, \"layered_bottom_f0_map\");\n refreshPrismMapUniforms(uniforms, material, \"layered_f0_map\");\n refreshPrismMapUniforms(uniforms, material, \"layered_diffuse_map\");\n refreshPrismMapUniforms(uniforms, material, \"layered_fraction_map\");\n refreshPrismMapUniforms(uniforms, material, \"layered_roughness_map\");\n refreshPrismMapUniforms(uniforms, material, \"layered_anisotropy_map\");\n refreshPrismMapUniforms(uniforms, material, \"layered_rotation_map\");\n\n refreshPrismBumpMapUniforms(uniforms, material, \"layered_normal_map\");\n\n break;\n\n case 'PrismTransparent':\n uniforms.transparent_color.value = material.transparent_color;\n uniforms.transparent_distance.value = material.transparent_distance;\n uniforms.transparent_ior.value = material.transparent_ior;\n\n break;\n\n case 'PrismGlazing':\n uniforms.glazing_f0.value = material.glazing_f0;\n uniforms.glazing_transmission_color.value = material.glazing_transmission_color;\n uniforms.glazing_transmission_roughness.value = material.glazing_transmission_roughness;\n\n refreshPrismMapUniforms(uniforms, material, \"glazing_f0_map\");\n refreshPrismMapUniforms(uniforms, material, \"glazing_transmission_color_map\");\n refreshPrismMapUniforms(uniforms, material, \"glazing_transmission_roughness_map\");\n\n break;\n\n case 'PrismWood':\n uniforms.wood_fiber_cosine_enable.value = material.wood_fiber_cosine_enable;\n uniforms.wood_fiber_cosine_bands.value = material.wood_fiber_cosine_bands;\n uniforms.wood_fiber_cosine_weights.value = material.wood_fiber_cosine_weights;\n uniforms.wood_fiber_cosine_frequencies.value = material.wood_fiber_cosine_frequencies;\n\n uniforms.wood_fiber_perlin_enable.value = material.wood_fiber_perlin_enable;\n uniforms.wood_fiber_perlin_bands.value = material.wood_fiber_perlin_bands;\n uniforms.wood_fiber_perlin_weights.value = material.wood_fiber_perlin_weights;\n uniforms.wood_fiber_perlin_frequencies.value = material.wood_fiber_perlin_frequencies;\n uniforms.wood_fiber_perlin_scale_z.value = material.wood_fiber_perlin_scale_z;\n\n uniforms.wood_growth_perlin_enable.value = material.wood_growth_perlin_enable;\n uniforms.wood_growth_perlin_bands.value = material.wood_growth_perlin_bands;\n uniforms.wood_growth_perlin_weights.value = material.wood_growth_perlin_weights;\n uniforms.wood_growth_perlin_frequencies.value = material.wood_growth_perlin_frequencies;\n\n uniforms.wood_latewood_ratio.value = material.wood_latewood_ratio;\n uniforms.wood_earlywood_sharpness.value = material.wood_earlywood_sharpness;\n uniforms.wood_latewood_sharpness.value = material.wood_latewood_sharpness;\n uniforms.wood_ring_thickness.value = material.wood_ring_thickness;\n\n uniforms.wood_earlycolor_perlin_enable.value = material.wood_earlycolor_perlin_enable;\n uniforms.wood_earlycolor_perlin_bands.value = material.wood_earlycolor_perlin_bands;\n uniforms.wood_earlycolor_perlin_weights.value = material.wood_earlycolor_perlin_weights;\n uniforms.wood_earlycolor_perlin_frequencies.value = material.wood_earlycolor_perlin_frequencies;\n uniforms.wood_early_color.value = material.wood_early_color;\n\n uniforms.wood_use_manual_late_color.value = material.wood_use_manual_late_color;\n uniforms.wood_manual_late_color.value = material.wood_manual_late_color;\n\n uniforms.wood_latecolor_perlin_enable.value = material.wood_latecolor_perlin_enable;\n uniforms.wood_latecolor_perlin_bands.value = material.wood_latecolor_perlin_bands;\n uniforms.wood_latecolor_perlin_weights.value = material.wood_latecolor_perlin_weights;\n uniforms.wood_latecolor_perlin_frequencies.value = material.wood_latecolor_perlin_frequencies;\n uniforms.wood_late_color_power.value = material.wood_late_color_power;\n\n uniforms.wood_diffuse_perlin_enable.value = material.wood_diffuse_perlin_enable;\n uniforms.wood_diffuse_perlin_bands.value = material.wood_diffuse_perlin_bands;\n uniforms.wood_diffuse_perlin_weights.value = material.wood_diffuse_perlin_weights;\n uniforms.wood_diffuse_perlin_frequencies.value = material.wood_diffuse_perlin_frequencies;\n uniforms.wood_diffuse_perlin_scale_z.value = material.wood_diffuse_perlin_scale_z;\n\n uniforms.wood_use_pores.value = material.wood_use_pores;\n uniforms.wood_pore_type.value = material.wood_pore_type;\n uniforms.wood_pore_radius.value = material.wood_pore_radius;\n uniforms.wood_pore_cell_dim.value = material.wood_pore_cell_dim;\n uniforms.wood_pore_color_power.value = material.wood_pore_color_power;\n uniforms.wood_pore_depth.value = material.wood_pore_depth;\n\n uniforms.wood_use_rays.value = material.wood_use_rays;\n uniforms.wood_ray_color_power.value = material.wood_ray_color_power;\n uniforms.wood_ray_seg_length_z.value = material.wood_ray_seg_length_z;\n uniforms.wood_ray_num_slices.value = material.wood_ray_num_slices;\n uniforms.wood_ray_ellipse_z2x.value = material.wood_ray_ellipse_z2x;\n uniforms.wood_ray_ellipse_radius_x.value = material.wood_ray_ellipse_radius_x;\n\n uniforms.wood_use_latewood_bump.value = material.wood_use_latewood_bump;\n uniforms.wood_latewood_bump_depth.value = material.wood_latewood_bump_depth;\n\n uniforms.wood_use_groove_roughness.value = material.wood_use_groove_roughness;\n uniforms.wood_groove_roughness.value = material.wood_groove_roughness;\n uniforms.wood_diffuse_lobe_weight.value = material.wood_diffuse_lobe_weight;\n\n refreshPrismMapUniforms(uniforms, material, \"wood_curly_distortion_map\");\n if (uniforms[\"wood_curly_distortion_map\"].value != null)\n {\n // This map constains tree space position offsets\n uniforms[\"wood_curly_distortion_map\"].value.minFilter = THREE.NearestFilter;\n uniforms[\"wood_curly_distortion_map\"].value.magFilter = THREE.NearestFilter;\n uniforms.wood_curly_distortion_enable.value = material.wood_curly_distortion_enable;\n uniforms.wood_curly_distortion_scale.value = material.wood_curly_distortion_scale;\n }\n\n var earlyWood = 1.0 - material.wood_latewood_ratio;\n var earlyWoodSharpness = material.wood_earlywood_sharpness * earlyWood;\n var lateWoodSharpness = material.wood_latewood_sharpness * material.wood_latewood_ratio;\n var riseStart = earlyWood + lateWoodSharpness;\n uniforms.wood_ring_fraction.value = new THREE.Vector4(earlyWood, earlyWoodSharpness, lateWoodSharpness, riseStart);\n uniforms.wood_fall_rise.value = new THREE.Vector2(earlyWood - earlyWoodSharpness, material.wood_latewood_ratio - lateWoodSharpness);\n\n break;\n\n default:\n THREE.warn('Unknown prism type: ' + material.prismType);}\n\n\n if (material.useTiling) {\n uniforms.tilingOverallTransform.value = material.tilingOverallTransform;\n uniforms.TilingMap.value = material.TilingMap;\n uniforms.TilingMap_texMatrix.value = material.TilingMap_texMatrix;\n if (material.hasRoundCorner) {\n uniforms.TilingNormalMap.value = material.TilingNormalMap;\n uniforms.TilingNormalMap_texMatrix.value = material.TilingNormalMap_texMatrix;\n }\n if (material.useRandomOffset) {\n uniforms.TilingRandomMap.value = material.TilingRandomMap;\n uniforms.TilingRandomMap_texMatrix.value = material.TilingRandomMap_texMatrix;\n uniforms.tilingRandomAxisS.value = material.tilingRandomAxisS;\n uniforms.tilingRandomAxisT.value = material.tilingRandomAxisT;\n uniforms.tilingRandomAlignmentOffset.value = material.tilingRandomAlignmentOffset;\n }\n // note there is no \"invert\" property that gets set on the tiling MSDF texture, as it makes little sense\n uniforms.uv2tile.value = material.uv2tile;\n uniforms.tile2uv.value = material.tile2uv;\n // not needed here, as these are built in to the shader loops, due to WebGL needing fixed values for loops.\n //uniforms.tilingRepeatRange.value = material.tilingRepeatRange;\n uniforms.tileAlignOffset.value = material.tileAlignOffset;\n uniforms.tilingUVTransform.value = material.tilingUVTransform;\n }\n\n uniforms.envExponentMin.value = material.envExponentMin;\n uniforms.envExponentMax.value = material.envExponentMax;\n uniforms.envExponentCount.value = material.envExponentCount;\n }\n\n function refreshUniformsLambert(uniforms, material) {\n\n uniforms.emissive.value.copy(material.emissive);\n\n\n if (material.wrapAround) {\n\n uniforms.wrapRGB.value.copy(material.wrapRGB);\n\n }\n\n }\n\n function refreshUniformsLights(uniforms, lights) {\n\n uniforms.ambientLightColor.value = lights.ambient;\n\n uniforms.directionalLightColor.value = lights.directional.colors;\n uniforms.directionalLightDirection.value = lights.directional.positions;\n\n uniforms.pointLightColor.value = lights.point.colors;\n uniforms.pointLightPosition.value = lights.point.positions;\n uniforms.pointLightDistance.value = lights.point.distances;\n\n uniforms.spotLightColor.value = lights.spot.colors;\n uniforms.spotLightPosition.value = lights.spot.positions;\n uniforms.spotLightDistance.value = lights.spot.distances;\n uniforms.spotLightDirection.value = lights.spot.directions;\n uniforms.spotLightAngleCos.value = lights.spot.anglesCos;\n uniforms.spotLightExponent.value = lights.spot.exponents;\n\n uniforms.hemisphereLightSkyColor.value = lights.hemi.skyColors;\n uniforms.hemisphereLightGroundColor.value = lights.hemi.groundColors;\n uniforms.hemisphereLightDirection.value = lights.hemi.positions;\n\n }\n\n // If uniforms are marked as clean, they don't need to be loaded to the GPU.\n\n function markUniformsLightsNeedsUpdate(uniforms, boolean) {\n\n uniforms.ambientLightColor.needsUpdate = boolean;\n\n uniforms.directionalLightColor.needsUpdate = boolean;\n uniforms.directionalLightDirection.needsUpdate = boolean;\n\n uniforms.pointLightColor.needsUpdate = boolean;\n uniforms.pointLightPosition.needsUpdate = boolean;\n uniforms.pointLightDistance.needsUpdate = boolean;\n\n uniforms.spotLightColor.needsUpdate = boolean;\n uniforms.spotLightPosition.needsUpdate = boolean;\n uniforms.spotLightDistance.needsUpdate = boolean;\n uniforms.spotLightDirection.needsUpdate = boolean;\n uniforms.spotLightAngleCos.needsUpdate = boolean;\n uniforms.spotLightExponent.needsUpdate = boolean;\n\n uniforms.hemisphereLightSkyColor.needsUpdate = boolean;\n uniforms.hemisphereLightGroundColor.needsUpdate = boolean;\n uniforms.hemisphereLightDirection.needsUpdate = boolean;\n\n }\n\n // Uniforms (load to GPU)\n\n function loadUniformsMatrices(uniforms, object, camera) {\n\n _objectModelViewMatrix.multiplyMatrices(camera.matrixWorldInverse, object.matrixWorld);\n\n _gl.uniformMatrix4fv(uniforms.modelViewMatrix, false, _objectModelViewMatrix.elements);\n\n if (uniforms.normalMatrix) {\n\n _objectNormalMatrix.getNormalMatrix(_objectModelViewMatrix);\n\n _gl.uniformMatrix3fv(uniforms.normalMatrix, false, _objectNormalMatrix.elements);\n\n }\n\n if (uniforms.modelMatrix !== null) {\n\n _gl.uniformMatrix4fv(uniforms.modelMatrix, false, object.matrixWorld.elements);\n\n }\n\n }\n\n function getTextureUnit() {\n\n var textureUnit = _usedTextureUnits;\n\n if (textureUnit >= _maxTextures) {\n\n THREE.warn(\"WebGLRenderer: trying to use \" + textureUnit + \" texture units while this GPU supports only \" + _maxTextures);\n\n }\n\n _usedTextureUnits += 1;\n\n return textureUnit;\n\n }\n\n function loadUniformsGeneric(uniforms) {\n\n var texture, textureUnit, offset;\n\n for (var j = 0, jl = uniforms.length; j < jl; j++) {\n\n var uniform = uniforms[j][0];\n\n // needsUpdate property is not added to all uniforms.\n if (uniform.needsUpdate === false) continue;\n\n // needsUpdate property is not added to all uniforms.\n if (uniform.perObject)\n continue;\n\n var type = uniform.type;\n var value = uniform.value;\n var location = uniforms[j][1];\n\n var i, il;\n\n switch (type) {\n\n case '1i':\n _gl.uniform1i(location, value);\n break;\n\n case '1f':\n _gl.uniform1f(location, value);\n break;\n\n case '2f':\n _gl.uniform2f(location, value[0], value[1]);\n break;\n\n case '3f':\n _gl.uniform3f(location, value[0], value[1], value[2]);\n break;\n\n case '4f':\n _gl.uniform4f(location, value[0], value[1], value[2], value[3]);\n break;\n\n case '1iv':\n _gl.uniform1iv(location, value);\n break;\n\n case '3iv':\n _gl.uniform3iv(location, value);\n break;\n\n case '1fv':\n _gl.uniform1fv(location, value);\n break;\n\n case '2fv':\n _gl.uniform2fv(location, value);\n break;\n\n case '3fv':\n _gl.uniform3fv(location, value);\n break;\n\n case '4fv':\n _gl.uniform4fv(location, value);\n break;\n\n case 'Matrix3fv':\n _gl.uniformMatrix3fv(location, false, value);\n break;\n\n case 'Matrix4fv':\n _gl.uniformMatrix4fv(location, false, value);\n break;\n\n //\n\n case 'i':\n\n // single integer\n _gl.uniform1i(location, value);\n\n break;\n\n case 'f':\n\n // single float\n _gl.uniform1f(location, value);\n\n break;\n\n case 'v2':\n\n // single THREE.Vector2\n _gl.uniform2f(location, value.x, value.y);\n\n break;\n\n case 'v3':\n\n // single THREE.Vector3\n _gl.uniform3f(location, value.x, value.y, value.z);\n\n break;\n\n case 'v4':\n\n // single THREE.Vector4\n _gl.uniform4f(location, value.x, value.y, value.z, value.w);\n\n break;\n\n case 'c':\n\n // single THREE.Color\n _gl.uniform3f(location, value.r, value.g, value.b);\n\n break;\n\n case 'iv1':\n\n // flat array of integers (JS or typed array)\n _gl.uniform1iv(location, value);\n\n break;\n\n case 'iv':\n\n // flat array of integers with 3 x N size (JS or typed array)\n _gl.uniform3iv(location, value);\n\n break;\n\n case 'fv1':\n\n // flat array of floats (JS or typed array)\n _gl.uniform1fv(location, value);\n\n break;\n\n case 'fv':\n\n // flat array of floats with 3 x N size (JS or typed array)\n _gl.uniform3fv(location, value);\n\n break;\n\n case 'v2v':\n\n // array of THREE.Vector2\n\n if (uniform._array === undefined) {\n\n uniform._array = new Float32Array(2 * value.length);\n\n }\n\n for (i = 0, il = value.length; i < il; i++) {\n\n offset = i * 2;\n\n uniform._array[offset] = value[i].x;\n uniform._array[offset + 1] = value[i].y;\n\n }\n\n _gl.uniform2fv(location, uniform._array);\n\n break;\n\n case 'v3v':\n\n // array of THREE.Vector3\n\n if (uniform._array === undefined) {\n\n uniform._array = new Float32Array(3 * value.length);\n\n }\n\n for (i = 0, il = value.length; i < il; i++) {\n\n offset = i * 3;\n\n uniform._array[offset] = value[i].x;\n uniform._array[offset + 1] = value[i].y;\n uniform._array[offset + 2] = value[i].z;\n\n }\n\n _gl.uniform3fv(location, uniform._array);\n\n break;\n\n case 'v4v':\n\n // array of THREE.Vector4\n\n if (uniform._array === undefined) {\n\n uniform._array = new Float32Array(4 * value.length);\n\n }\n\n for (i = 0, il = value.length; i < il; i++) {\n\n offset = i * 4;\n\n uniform._array[offset] = value[i].x;\n uniform._array[offset + 1] = value[i].y;\n uniform._array[offset + 2] = value[i].z;\n uniform._array[offset + 3] = value[i].w;\n\n }\n\n _gl.uniform4fv(location, uniform._array);\n\n break;\n\n case 'm3':\n\n // single THREE.Matrix3\n _gl.uniformMatrix3fv(location, false, value.elements);\n\n break;\n\n case 'm3v':\n\n // array of THREE.Matrix3\n\n if (uniform._array === undefined) {\n\n uniform._array = new Float32Array(9 * value.length);\n\n }\n\n for (i = 0, il = value.length; i < il; i++) {\n\n value[i].flattenToArrayOffset(uniform._array, i * 9);\n\n }\n\n _gl.uniformMatrix3fv(location, false, uniform._array);\n\n break;\n\n case 'm4':\n\n // single THREE.Matrix4\n _gl.uniformMatrix4fv(location, false, value.elements);\n\n break;\n\n case 'm4v':\n\n // array of THREE.Matrix4\n\n if (uniform._array === undefined) {\n\n uniform._array = new Float32Array(16 * value.length);\n\n }\n\n for (i = 0, il = value.length; i < il; i++) {\n\n value[i].flattenToArrayOffset(uniform._array, i * 16);\n\n }\n\n _gl.uniformMatrix4fv(location, false, uniform._array);\n\n break;\n\n case 't':\n\n // single THREE.Texture (2d or cube)\n\n texture = value;\n textureUnit = getTextureUnit();\n\n _gl.uniform1i(location, textureUnit);\n\n if (!texture) {\n // Unbind whatever leftover texture might be in this slot.\n // The texture itself is not yet (or perhaps ever) assigned, so we want to avoid getting\n // some random leftover bound texture from another material. See https://jira.autodesk.com/browse/LMV-2993\n _gl.activeTexture(_gl.TEXTURE0 + textureUnit);\n _gl.bindTexture(_gl.TEXTURE_2D, _nullTexture.__webglTexture);\n continue;\n }\n\n if (Array.isArray(texture.image) && texture.image.length === 6 || // CompressedTexture can have Array in image :/\n texture instanceof THREE.CubeTexture) {\n\n if (!texture.needsUpdate) {\n _gl.activeTexture(_gl.TEXTURE0 + textureUnit);\n _gl.bindTexture(_gl.TEXTURE_CUBE_MAP, texture.__webglTextureCube);\n } else {\n setCubeTexture(texture, textureUnit);\n }\n\n } else if (texture instanceof THREE.WebGLRenderTargetCube) {\n\n setCubeTextureDynamic(texture, textureUnit);\n\n } else {\n\n _this.setTexture(texture, textureUnit);\n\n }\n\n break;\n\n case 'tv':\n\n // array of THREE.Texture (2d)\n\n if (uniform._array === undefined) {\n\n uniform._array = [];\n\n }\n\n for (i = 0, il = uniform.value.length; i < il; i++) {\n\n uniform._array[i] = getTextureUnit();\n\n }\n\n _gl.uniform1iv(location, uniform._array);\n\n for (i = 0, il = uniform.value.length; i < il; i++) {\n\n texture = uniform.value[i];\n textureUnit = uniform._array[i];\n\n if (!texture) continue;\n\n _this.setTexture(texture, textureUnit);\n\n }\n\n break;\n\n default:\n\n THREE.warn('THREE.WebGLRenderer: Unknown uniform type: ' + type);}\n\n\n\n }\n\n }\n\n //\n\n /* not used\n function setColorGamma( array, offset, color, intensitySq ) {\n array[ offset ] = color.r * color.r * intensitySq;\n array[ offset + 1 ] = color.g * color.g * intensitySq;\n array[ offset + 2 ] = color.b * color.b * intensitySq;\n }\n */\n\n\n\n function setColorLinear(array, offset, color, intensity) {\n\n array[offset] = color.r * intensity;\n array[offset + 1] = color.g * intensity;\n array[offset + 2] = color.b * intensity;\n\n }\n\n function setupLights(lights) {\n\n var l,ll,light,\n r = 0,g = 0,b = 0,\n color,skyColor,groundColor,\n intensity,\n distance,\n\n zlights = _lights,\n\n dirColors = zlights.directional.colors,\n dirPositions = zlights.directional.positions,\n\n pointColors = zlights.point.colors,\n pointPositions = zlights.point.positions,\n pointDistances = zlights.point.distances,\n\n spotColors = zlights.spot.colors,\n spotPositions = zlights.spot.positions,\n spotDistances = zlights.spot.distances,\n spotDirections = zlights.spot.directions,\n spotAnglesCos = zlights.spot.anglesCos,\n spotExponents = zlights.spot.exponents,\n\n hemiSkyColors = zlights.hemi.skyColors,\n hemiGroundColors = zlights.hemi.groundColors,\n hemiPositions = zlights.hemi.positions,\n\n dirLength = 0,\n pointLength = 0,\n spotLength = 0,\n hemiLength = 0,\n\n dirCount = 0,\n pointCount = 0,\n spotCount = 0,\n hemiCount = 0,\n\n dirOffset = 0,\n pointOffset = 0,\n spotOffset = 0,\n hemiOffset = 0;\n\n for (l = 0, ll = lights.length; l < ll; l++) {\n\n light = lights[l];\n\n if (light.onlyShadow) continue;\n\n color = light.color;\n intensity = light.intensity;\n distance = light.distance;\n\n if (light instanceof THREE.AmbientLight) {\n\n if (!light.visible) continue;\n\n r += color.r;\n g += color.g;\n b += color.b;\n\n } else if (light instanceof THREE.DirectionalLight) {\n\n dirCount += 1;\n\n if (!light.visible) continue;\n\n _direction.setFromMatrixPosition(light.matrixWorld);\n _vector3.setFromMatrixPosition(light.target.matrixWorld);\n _direction.sub(_vector3);\n _direction.normalize();\n\n dirOffset = dirLength * 3;\n\n dirPositions[dirOffset] = _direction.x;\n dirPositions[dirOffset + 1] = _direction.y;\n dirPositions[dirOffset + 2] = _direction.z;\n\n setColorLinear(dirColors, dirOffset, color, intensity);\n\n dirLength += 1;\n\n } else if (light instanceof THREE.PointLight) {\n\n pointCount += 1;\n\n if (!light.visible) continue;\n\n pointOffset = pointLength * 3;\n\n\n setColorLinear(pointColors, pointOffset, color, intensity);\n\n\n _vector3.setFromMatrixPosition(light.matrixWorld);\n\n pointPositions[pointOffset] = _vector3.x;\n pointPositions[pointOffset + 1] = _vector3.y;\n pointPositions[pointOffset + 2] = _vector3.z;\n\n pointDistances[pointLength] = distance;\n\n pointLength += 1;\n\n } else if (light instanceof THREE.SpotLight) {\n\n spotCount += 1;\n\n if (!light.visible) continue;\n\n spotOffset = spotLength * 3;\n\n setColorLinear(spotColors, spotOffset, color, intensity);\n\n _vector3.setFromMatrixPosition(light.matrixWorld);\n\n spotPositions[spotOffset] = _vector3.x;\n spotPositions[spotOffset + 1] = _vector3.y;\n spotPositions[spotOffset + 2] = _vector3.z;\n\n spotDistances[spotLength] = distance;\n\n _direction.copy(_vector3);\n _vector3.setFromMatrixPosition(light.target.matrixWorld);\n _direction.sub(_vector3);\n _direction.normalize();\n\n spotDirections[spotOffset] = _direction.x;\n spotDirections[spotOffset + 1] = _direction.y;\n spotDirections[spotOffset + 2] = _direction.z;\n\n spotAnglesCos[spotLength] = Math.cos(light.angle);\n spotExponents[spotLength] = light.exponent;\n\n spotLength += 1;\n\n } else if (light instanceof THREE.HemisphereLight) {\n\n hemiCount += 1;\n\n if (!light.visible) continue;\n\n _direction.setFromMatrixPosition(light.matrixWorld);\n _direction.normalize();\n\n hemiOffset = hemiLength * 3;\n\n hemiPositions[hemiOffset] = _direction.x;\n hemiPositions[hemiOffset + 1] = _direction.y;\n hemiPositions[hemiOffset + 2] = _direction.z;\n\n skyColor = light.color;\n groundColor = light.groundColor;\n\n setColorLinear(hemiSkyColors, hemiOffset, skyColor, intensity);\n setColorLinear(hemiGroundColors, hemiOffset, groundColor, intensity);\n\n hemiLength += 1;\n\n }\n\n }\n\n // null eventual remains from removed lights\n // (this is to avoid if in shader)\n\n for (l = dirLength * 3, ll = Math.max(dirColors.length, dirCount * 3); l < ll; l++) {dirColors[l] = 0.0;}\n for (l = pointLength * 3, ll = Math.max(pointColors.length, pointCount * 3); l < ll; l++) {pointColors[l] = 0.0;}\n for (l = spotLength * 3, ll = Math.max(spotColors.length, spotCount * 3); l < ll; l++) {spotColors[l] = 0.0;}\n for (l = hemiLength * 3, ll = Math.max(hemiSkyColors.length, hemiCount * 3); l < ll; l++) {hemiSkyColors[l] = 0.0;}\n for (l = hemiLength * 3, ll = Math.max(hemiGroundColors.length, hemiCount * 3); l < ll; l++) {hemiGroundColors[l] = 0.0;}\n\n zlights.directional.length = dirLength;\n zlights.point.length = pointLength;\n zlights.spot.length = spotLength;\n zlights.hemi.length = hemiLength;\n\n zlights.ambient[0] = r;\n zlights.ambient[1] = g;\n zlights.ambient[2] = b;\n\n }\n\n // GL state setting\n\n this.setFaceCulling = function (cullFace, frontFaceDirection) {\n\n if (cullFace === THREE.CullFaceNone) {\n\n _gl.disable(_gl.CULL_FACE);\n\n } else {\n\n if (frontFaceDirection === THREE.FrontFaceDirectionCW) {\n\n _gl.frontFace(_gl.CW);\n\n } else {\n\n _gl.frontFace(_gl.CCW);\n\n }\n\n if (cullFace === THREE.CullFaceBack) {\n\n _gl.cullFace(_gl.BACK);\n\n } else if (cullFace === THREE.CullFaceFront) {\n\n _gl.cullFace(_gl.FRONT);\n\n } else {\n\n _gl.cullFace(_gl.FRONT_AND_BACK);\n\n }\n\n _gl.enable(_gl.CULL_FACE);\n\n }\n\n };\n\n\n // NOTE: if you change the .side value of a material itself, you need to set\n // material.needsUpdate = true, so that the material's shaders are recompiled.\n // You definitely want to avoid this recompilation per frame; usually the\n // THREE.DoubleSided setting works fine for both back and front side display,\n // even if the colors of the sides are different (which are simply uniforms\n // being changed, not the programs themselves).\n this.setMaterialFaces = function (material) {\n\n state.setDoubleSided(material.side === THREE.DoubleSide);\n state.setFlipSided(material.side === THREE.BackSide);\n\n };\n\n // Textures\n\n\n function setTextureParameters(textureType, texture, isImagePowerOfTwo) {\n\n var extension;\n\n if (isImagePowerOfTwo) {\n\n _gl.texParameteri(textureType, _gl.TEXTURE_WRAP_S, paramThreeToGL(texture.wrapS));\n _gl.texParameteri(textureType, _gl.TEXTURE_WRAP_T, paramThreeToGL(texture.wrapT));\n\n _gl.texParameteri(textureType, _gl.TEXTURE_MAG_FILTER, paramThreeToGL(texture.magFilter));\n _gl.texParameteri(textureType, _gl.TEXTURE_MIN_FILTER, paramThreeToGL(texture.minFilter));\n\n } else {\n\n _gl.texParameteri(textureType, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE);\n _gl.texParameteri(textureType, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE);\n\n if (texture.wrapS !== THREE.ClampToEdgeWrapping || texture.wrapT !== THREE.ClampToEdgeWrapping) {\n\n THREE.warn('THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping. ( ' + texture.sourceFile + ' )');\n\n }\n\n _gl.texParameteri(textureType, _gl.TEXTURE_MAG_FILTER, filterFallback(texture.magFilter));\n _gl.texParameteri(textureType, _gl.TEXTURE_MIN_FILTER, filterFallback(texture.minFilter));\n\n if (texture.minFilter !== THREE.NearestFilter && texture.minFilter !== THREE.LinearFilter) {\n\n THREE.warn('THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter. ( ' + texture.sourceFile + ' )');\n\n }\n\n }\n\n extension = extensions.get('EXT_texture_filter_anisotropic');\n\n if (extension && texture.type !== THREE.FloatType && texture.type !== THREE.HalfFloatType) {\n\n if (texture.anisotropy > 1 || texture.__oldAnisotropy) {\n\n _gl.texParameterf(textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(texture.anisotropy, _this.getMaxAnisotropy()));\n texture.__oldAnisotropy = texture.anisotropy;\n\n }\n\n }\n\n }\n\n\n this.uploadTexture = function (texture) {\n\n if (texture.__webglInit === undefined) {\n\n texture.__webglInit = true;\n\n texture.addEventListener('dispose', onTextureDispose);\n\n texture.__webglTexture = _gl.createTexture();\n\n _this.info.memory.textures++;\n\n }\n\n _gl.bindTexture(_gl.TEXTURE_2D, texture.__webglTexture);\n\n _gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, texture.flipY);\n _gl.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha);\n _gl.pixelStorei(_gl.UNPACK_ALIGNMENT, texture.unpackAlignment);\n\n texture.image = clampToMaxSize(texture.image, _maxTextureSize);\n\n var image = texture.image,\n isImagePowerOfTwo = THREE.Math.isPowerOfTwo(image.width) && THREE.Math.isPowerOfTwo(image.height),\n glFormat = paramThreeToGL(texture.format),\n glType = paramThreeToGL(texture.type),\n glInternalFormat = paramToInternal(texture.format, texture.type);\n\n setTextureParameters(_gl.TEXTURE_2D, texture, isImagePowerOfTwo);\n\n var mipmap,mipmaps = texture.mipmaps;\n var i, il;\n\n if (texture instanceof THREE.DataTexture) {\n\n // use manually created mipmaps if available\n // if there are no manual mipmaps\n // set 0 level mipmap and then use GL to generate other mipmap levels\n\n if (mipmaps.length > 0 && isImagePowerOfTwo) {\n\n for (i = 0, il = mipmaps.length; i < il; i++) {\n\n mipmap = mipmaps[i];\n _gl.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);\n\n }\n\n texture.generateMipmaps = false;\n\n } else {\n\n _gl.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data);\n\n }\n\n } else if (texture instanceof THREE.CompressedTexture) {\n\n for (i = 0, il = mipmaps.length; i < il; i++) {\n\n mipmap = mipmaps[i];\n\n if (texture.format !== THREE.RGBAFormat && texture.format !== THREE.RGBFormat) {\n\n if (getCompressedTextureFormats().indexOf(glFormat) > -1) {\n\n _gl.compressedTexImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data);\n\n } else {\n\n THREE.warn(\"Attempt to load unsupported compressed texture format\");\n\n }\n\n } else {\n\n _gl.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);\n\n }\n }\n\n // make sure compressed texture pyramids are complete (i.e. include all levels\n // between what ever was the coarsest level in file and 1x1)\n if (mipmaps.length > 1 && getCompressedTextureFormats().indexOf(glFormat) > -1)\n {\n var w = mipmap.width >> 1,\n h = mipmap.height >> 1,\n l = mipmaps.length;\n\n var view;\n\n while (w >= 1 || h >= 1) {\n view = mipmap.width == 4 && mipmap.height == 4 ? mipmap.data : new DataView(\n mipmap.data.buffer,\n mipmap.data.byteOffset,\n mipmap.data.byteLength * (Math.max(w, 4) * Math.max(h, 4)) / (mipmap.width * mipmap.height));\n\n\n _gl.compressedTexImage2D(_gl.TEXTURE_2D, l, glInternalFormat, Math.max(w, 1), Math.max(h, 1), 0, view);\n w = w >> 1;\n h = h >> 1;\n ++l;\n }\n }\n\n } else {// regular Texture (image, video, canvas)\n\n // use manually created mipmaps if available\n // if there are no manual mipmaps\n // set 0 level mipmap and then use GL to generate other mipmap levels\n\n if (mipmaps.length > 0 && isImagePowerOfTwo) {\n\n for (i = 0, il = mipmaps.length; i < il; i++) {\n\n _gl.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, glFormat, glType, mipmaps[i]);\n\n }\n\n texture.generateMipmaps = false;\n\n } else {\n\n _gl.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, glFormat, glType, texture.image);\n\n }\n\n }\n\n if (texture.generateMipmaps && isImagePowerOfTwo) _gl.generateMipmap(_gl.TEXTURE_2D);\n\n texture.needsUpdate = false;\n\n if (texture.onUpdate) texture.onUpdate();\n\n };\n\n this.setTexture = function (texture, slot) {\n _gl.activeTexture(_gl.TEXTURE0 + slot);\n if (texture.needsUpdate) {\n _this.uploadTexture(texture);\n } else if (texture.__webglTexture) {\n _gl.bindTexture(_gl.TEXTURE_2D, texture.__webglTexture);\n } else {\n // No texture available, so don't \"use\" the texture unit, but make sure the uniform is assigned to something.\n // This avoids headaches where the texture is bound as output this pass, but was an input last pass\n // and is still bound to the given texture unit.\n // Note that Chrome will flag warnings if you bind to null but are \"using\" the sampler (even though you're not).\n // So we bind to this bogus texture instead.\n // TODO Better for us might be to not have the unused uniforms in our shaders.\n _gl.bindTexture(_gl.TEXTURE_2D, _nullTexture.__webglTexture);\n }\n };\n // This function is finally defined, so we can use it now.\n _this.uploadTexture(_nullTexture);\n\n function clampToMaxSize(image, maxSize) {\n\n if (image.width <= maxSize && image.height <= maxSize) {\n\n return image;\n\n }\n\n // Warning: Scaling through the canvas will only work with images that use\n // premultiplied alpha.\n\n var maxDimension = Math.max(image.width, image.height);\n var newWidth = Math.floor(image.width * maxSize / maxDimension);\n var newHeight = Math.floor(image.height * maxSize / maxDimension);\n\n var canvas = _document.createElement('canvas');\n canvas.width = newWidth;\n canvas.height = newHeight;\n\n var ctx = canvas.getContext(\"2d\");\n ctx.drawImage(image, 0, 0, image.width, image.height, 0, 0, newWidth, newHeight);\n\n return canvas;\n\n }\n\n function setCubeTexture(texture, slot) {\n\n if (texture.image.length === 6) {\n\n if (texture.needsUpdate) {\n\n if (!texture.__webglTextureCube) {\n\n texture.addEventListener('dispose', onTextureDispose);\n\n texture.__webglTextureCube = _gl.createTexture();\n\n _this.info.memory.textures++;\n\n }\n\n _gl.activeTexture(_gl.TEXTURE0 + slot);\n _gl.bindTexture(_gl.TEXTURE_CUBE_MAP, texture.__webglTextureCube);\n\n _gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, texture.flipY);\n\n var isCompressed = texture instanceof THREE.CompressedTexture;\n var isDataTexture = texture.image[0] instanceof THREE.DataTexture;\n\n var cubeImage = [];\n\n var i;\n\n for (i = 0; i < 6; i++) {\n\n if (_this.autoScaleCubemaps && !isCompressed && !isDataTexture) {\n\n cubeImage[i] = clampToMaxSize(texture.image[i], _maxCubemapSize);\n\n } else {\n\n cubeImage[i] = isDataTexture ? texture.image[i].image : texture.image[i];\n\n }\n\n }\n\n var image = cubeImage[0],\n isImagePowerOfTwo = THREE.Math.isPowerOfTwo(image.width) && THREE.Math.isPowerOfTwo(image.height),\n glFormat = paramThreeToGL(texture.format),\n glType = paramThreeToGL(texture.type);\n\n setTextureParameters(_gl.TEXTURE_CUBE_MAP, texture, isImagePowerOfTwo);\n\n for (i = 0; i < 6; i++) {\n\n if (!isCompressed) {\n\n if (isDataTexture) {\n\n _gl.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glFormat, cubeImage[i].width, cubeImage[i].height, 0, glFormat, glType, cubeImage[i].data);\n\n } else {\n\n _gl.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glFormat, glFormat, glType, cubeImage[i]);\n\n }\n\n } else {\n\n var mipmap,mipmaps = cubeImage[i].mipmaps;\n\n for (var j = 0, jl = mipmaps.length; j < jl; j++) {\n\n mipmap = mipmaps[j];\n\n if (texture.format !== THREE.RGBAFormat && texture.format !== THREE.RGBFormat) {\n\n if (getCompressedTextureFormats().indexOf(glFormat) > -1) {\n\n _gl.compressedTexImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glFormat, mipmap.width, mipmap.height, 0, mipmap.data);\n\n } else {\n\n THREE.warn(\"Attempt to load unsupported compressed texture format\");\n\n }\n\n } else {\n\n _gl.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);\n\n }\n\n }\n\n }\n\n }\n\n if (texture.generateMipmaps && isImagePowerOfTwo) {\n\n _gl.generateMipmap(_gl.TEXTURE_CUBE_MAP);\n\n }\n\n texture.needsUpdate = false;\n\n if (texture.onUpdate) texture.onUpdate();\n\n } else {\n\n _gl.activeTexture(_gl.TEXTURE0 + slot);\n _gl.bindTexture(_gl.TEXTURE_CUBE_MAP, texture.__webglTextureCube);\n\n }\n\n }\n\n }\n\n function setCubeTextureDynamic(texture, slot) {\n\n _gl.activeTexture(_gl.TEXTURE0 + slot);\n _gl.bindTexture(_gl.TEXTURE_CUBE_MAP, texture.__webglTexture);\n\n }\n\n // Render targets\n\n function bindDrawBuffers(renderTargets) {\n\n var attachment0 = _isWebGL2 ? _gl.COLOR_ATTACHMENT0 : _glExtensionDrawBuffers.COLOR_ATTACHMENT0_WEBGL;\n\n var bufs = [attachment0];\n for (i = 1; i < renderTargets.length; i++) {\n bufs.push(attachment0 + i);\n }\n _isWebGL2 ? _gl.drawBuffers(bufs) : _glExtensionDrawBuffers.drawBuffersWEBGL(bufs);\n }\n\n function createBackingTexture(rt) {\n\n var isTargetPowerOfTwo = THREE.Math.isPowerOfTwo(rt.width) && THREE.Math.isPowerOfTwo(rt.height),\n glFormat = paramThreeToGL(rt.format),\n glType = paramThreeToGL(rt.type),\n glInternalFormat = paramToInternal(rt.format, rt.type);\n\n rt.addEventListener('dispose', onRenderTargetDispose);\n\n rt.__webglTexture = _gl.createTexture();\n\n _this.info.memory.textures++;\n\n _gl.bindTexture(_gl.TEXTURE_2D, rt.__webglTexture);\n\n setTextureParameters(_gl.TEXTURE_2D, rt, isTargetPowerOfTwo);\n\n _gl.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, rt.width, rt.height, 0, glFormat, glType, null);\n\n if (isTargetPowerOfTwo && rt.generateMipmaps)\n _gl.generateMipmap(_gl.TEXTURE_2D);\n\n }\n\n function didColorAttachmentsChange(primaryTarget, renderTargets) {\n\n var bufs = primaryTarget.__webglBoundBuffers;\n\n if (!bufs) {\n return true;\n }\n\n if (bufs.length !== renderTargets.length) {\n return true;\n }\n\n for (var _i = 0; _i < renderTargets.length; _i++) {\n if (renderTargets[_i] !== bufs[_i]) {\n return true;\n }\n }\n\n return false;\n }\n\n\n this.initFrameBufferMRT = function (renderTargets, verifyFrameBufferWorks) {\n\n var primaryTarget = renderTargets[0];\n var clearState = false;\n\n //For MRT, the frame and depth buffer are owned\n //by the first target.\n if (primaryTarget && !primaryTarget.__webglFramebuffer) {\n\n if (primaryTarget.depthBuffer === undefined) primaryTarget.depthBuffer = true;\n if (primaryTarget.stencilBuffer === undefined) primaryTarget.stencilBuffer = true;\n\n primaryTarget.__webglFramebuffer = _gl.createFramebuffer();\n\n _gl.bindFramebuffer(_gl.FRAMEBUFFER, primaryTarget.__webglFramebuffer);\n\n var renderbuffer;\n\n //Allocate depth buffer if needed\n\n if (primaryTarget.shareDepthFrom) {\n\n renderbuffer = primaryTarget.__webglRenderbuffer = primaryTarget.shareDepthFrom.__webglRenderbuffer;\n\n } else {\n\n // Below we can delete the frame buffer from a render target without deleting the render buffer\n // Use the existing render buffer if it is present. This fixes problems with shared depth buffers.\n // The problem is that the color depth buffer could get changed after it was bound to the frame\n // buffer a target that shares the depth buffer. Using the existing depth buffer, keep it consistent.\n renderbuffer = primaryTarget.__webglRenderbuffer;\n\n if (primaryTarget.depthBuffer && !primaryTarget.stencilBuffer) {\n\n if (!renderbuffer) {\n renderbuffer = primaryTarget.__webglRenderbuffer = _gl.createRenderbuffer();\n }\n\n _gl.bindRenderbuffer(_gl.RENDERBUFFER, renderbuffer);\n\n _gl.renderbufferStorage(_gl.RENDERBUFFER, _isWebGL2 ? _gl.DEPTH_COMPONENT32F : _gl.DEPTH_COMPONENT16, primaryTarget.width, primaryTarget.height);\n\n } else if (primaryTarget.depthBuffer && primaryTarget.stencilBuffer) {\n\n if (!renderbuffer) {\n renderbuffer = primaryTarget.__webglRenderbuffer = _gl.createRenderbuffer();\n }\n\n _gl.bindRenderbuffer(_gl.RENDERBUFFER, renderbuffer);\n\n _gl.renderbufferStorage(_gl.RENDERBUFFER, _isWebGL2 ? _gl.DEPTH24_STENCIL8 : _gl.DEPTH_STENCIL, primaryTarget.width, primaryTarget.height);\n\n } else {\n\n //_gl.renderbufferStorage( _gl.RENDERBUFFER, _gl.RGBA4, primaryTarget.width, primaryTarget.height );\n\n }\n\n }\n\n //Bind depth buffer\n\n if (primaryTarget.depthBuffer && !primaryTarget.stencilBuffer) {\n\n _gl.framebufferRenderbuffer(_gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer);\n\n } else if (primaryTarget.depthBuffer && primaryTarget.stencilBuffer) {\n\n _gl.framebufferRenderbuffer(_gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer);\n\n }\n\n clearState = true;\n }\n\n var tmpBuf = _currentFramebuffer;\n\n _gl.bindFramebuffer(_gl.FRAMEBUFFER, primaryTarget.__webglFramebuffer);\n\n if (didColorAttachmentsChange(primaryTarget, renderTargets)) {\n //Create backing textures for all the targets and attach them\n //to the frame buffer.\n var i;\n for (i = 0; i < renderTargets.length; i++) {\n var rt = renderTargets[i];\n\n if (rt && !rt.__webglTexture) {\n createBackingTexture(rt);\n }\n\n _gl.framebufferTexture2D(_gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, rt && rt.__webglTexture, 0);\n }\n\n /*\n * Set remaining (any formerly bound) render targets to null\n * IMPORTANT: Up until recently, whenever we would switch from a framebuffer with 3 attachments\n * to a framebuffer with 2 attachments, we would just ignore the extraneous attachment, and it\n * worked fine.\n * As of Chrome version 54, we can no longer do that. If we try to keep the extra attachment\n * linked to the framebuffer, Chrome errors out with \"framebuffer incomplete\".\n */\n i = renderTargets.length;\n var maxBuffers = primaryTarget.__webglBoundBuffers && primaryTarget.__webglBoundBuffers.length || i;\n while (i < maxBuffers) {\n _gl.framebufferTexture2D(_gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, null, 0);\n i++;\n }\n\n primaryTarget.__webglBoundBuffers = renderTargets.slice();\n }\n\n if (this.supportsMRT()) {\n bindDrawBuffers(renderTargets);\n }\n\n if (verifyFrameBufferWorks) {\n var status = _gl.checkFramebufferStatus(_gl.FRAMEBUFFER);\n if (status !== _gl.FRAMEBUFFER_COMPLETE) {\n THREE.log(\"Can't use multiple render targets. Falling back to two passes. \" + status);\n // Delete the frame buffer before removing the __webglFramebuffer property.\n // I think you could keep the frame buffer if you just cleared the color attachments.\n if (tmpBuf === primaryTarget.__webglFramebuffer) {\n // Make sure we don't bind the delete frame buffer.\n tmpBuf = _currentFramebuffer = null;\n }\n // Bind the old frame buffer. Don't know if deleting a bound frame buffer is a good idea.\n _gl.bindFramebuffer(_gl.FRAMEBUFFER, tmpBuf);\n _gl.deleteFramebuffer(primaryTarget.__webglFramebuffer);\n delete primaryTarget.__webglFramebuffer;\n verifyFrameBufferWorks = false;\n }\n }\n\n _gl.bindFramebuffer(_gl.FRAMEBUFFER, tmpBuf);\n\n if (clearState) {\n // Release everything\n _gl.bindTexture(_gl.TEXTURE_2D, null);\n _gl.bindRenderbuffer(_gl.RENDERBUFFER, null);\n _gl.bindFramebuffer(_gl.FRAMEBUFFER, null);\n }\n\n return verifyFrameBufferWorks;\n };\n\n\n //[Firefly] This function is different from Three.js -- it adds\n //support for binding multiple render targets.\n this.setRenderTarget = function (renderTargets) {\n\n var renderTarget;\n\n // We need to be a little careful about how we handle the frameBuffer for\n // the render target. If we call this method with an array of render targets\n // and then later with the first render target in the array by itself we can\n // use the MRT __webglFrameBuffer when we needed to reinitialize it for the\n // render target alone. Use initForMRT on the render target to keep this from\n // happening. This was happening for the ghosting pass which follows the\n // beauty pass, but only caused errors when used with instanced draw calls.\n if (Array.isArray(renderTargets)) {\n this.initFrameBufferMRT(renderTargets);\n renderTarget = renderTargets[0];\n renderTarget.initForMRT = true;\n } else if (renderTargets) {\n var fb = renderTargets.__webglFramebuffer;\n if (!fb || _currentFramebuffer !== fb || renderTargets.initForMRT) {\n this.initFrameBufferMRT([renderTargets]);\n }\n renderTarget = renderTargets;\n renderTarget.initForMRT = false;\n }\n\n var framebuffer, width, height, vx, vy;\n\n // Consider current viewport when rendering to framebuffer or if enabled for offscreen targets. \n var useViewport = !renderTarget || _enableViewportOnOffscreenTargets;\n if (useViewport) {\n width = _viewportWidth;\n height = _viewportHeight;\n vx = _viewportX;\n vy = _viewportY;\n } else {\n width = renderTarget.width;\n height = renderTarget.height;\n vx = 0;\n vy = 0;\n }\n\n framebuffer = renderTarget ? renderTarget.__webglFramebuffer : null;\n\n if (framebuffer !== _currentFramebuffer) {\n\n _gl.bindFramebuffer(_gl.FRAMEBUFFER, framebuffer);\n _currentFramebuffer = framebuffer;\n\n }\n\n _gl.viewport(vx, vy, width, height);\n\n //_currentWidth = width;\n //_currentHeight = height;\n\n };\n\n\n //We need to use more than WebGL 1.0 technically allows -- we use\n //different bit depth sizes for the render targets, which is not\n //legal WebGL 1.0, but will work eventually and some platforms/browsers\n //already allow it. For others, we have to try, check for failure, and disable use of MRT dynamically.\n this.verifyMRTWorks = function (renderTargets) {\n if (this.supportsMRT()) {\n return this.initFrameBufferMRT(renderTargets, true);\n }\n return false;\n };\n\n\n this.readRenderTargetPixels = function (renderTarget, x, y, width, height, buffer) {\n\n if (!(renderTarget instanceof THREE.WebGLRenderTarget)) {\n\n THREE.error('THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.');\n return;\n\n }\n\n if (renderTarget.__webglFramebuffer) {\n\n //Just a rough sanity check -- different browsers support different combinations\n //The check is for the most restrictive implementation (ANGLE). It can be relaxed once\n //Chrome dumps ANGLE. Note that targets of format RGB and unsigned byte type can be read with readPixels using GL_RGBA\n //as the format parameter (apparently). But this is not the case for float targets -- for those you have\n //to change the code to readPixels with the correct format.\n if (renderTarget.format !== THREE.RGBAFormat &&\n renderTarget.format !== THREE.RGBFormat ||\n renderTarget.type !== THREE.UnsignedByteType) {\n\n THREE.error('THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not a readable format.');\n return;\n\n }\n\n var restore = false;\n\n if (renderTarget.__webglFramebuffer !== _currentFramebuffer) {\n\n _gl.bindFramebuffer(_gl.FRAMEBUFFER, renderTarget.__webglFramebuffer);\n\n restore = true;\n\n }\n\n if (renderTarget.canReadPixels || _gl.checkFramebufferStatus(_gl.FRAMEBUFFER) === _gl.FRAMEBUFFER_COMPLETE) {\n\n _gl.readPixels(x, y, width, height, _gl.RGBA, _gl.UNSIGNED_BYTE, buffer);\n\n } else {\n\n THREE.error('THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.');\n\n }\n\n if (restore) {\n\n _gl.bindFramebuffer(_gl.FRAMEBUFFER, _currentFramebuffer);\n\n }\n\n }\n };\n\n function updateRenderTargetMipmap(renderTarget) {\n\n _gl.bindTexture(_gl.TEXTURE_2D, renderTarget.__webglTexture);\n _gl.generateMipmap(_gl.TEXTURE_2D);\n _gl.bindTexture(_gl.TEXTURE_2D, null);\n\n }\n\n // Fallback filters for non-power-of-2 textures\n\n function filterFallback(f) {\n\n if (f === THREE.NearestFilter || f === THREE.NearestMipMapNearestFilter || f === THREE.NearestMipMapLinearFilter) {\n\n return _gl.NEAREST;\n\n }\n\n return _gl.LINEAR;\n\n }\n\n // Map three.js constants to WebGL constants\n\n function paramToInternal(format, type) {\n\n if (_isWebGL2) {\n if (format === THREE.RGBFormat) {\n switch (type) {\n case THREE.UnsignedByteType:return _gl.RGB8;\n case THREE.FloatType:return _gl.RGB32F;\n case THREE.HalfFloatType:return _gl.RGB16F;\n default:break;}\n\n } else if (format === THREE.RGBAFormat) {\n switch (type) {\n case THREE.UnsignedByteType:return _gl.RGBA8;\n case THREE.FloatType:return _gl.RGBA32F;\n case THREE.HalfFloatType:return _gl.RGBA16F;\n default:break;}\n\n } else if (format === THREE.LuminanceFormat) {\n switch (type) {\n case THREE.UnsignedByteType:return _gl.LUMINANCE; //TODO: There doesn't seem to be _gl.LUMINANCE8 defined?\n default:break;}\n\n }\n\n console.error(\"failed to map texture format and type to internalformat\");\n }\n\n return paramThreeToGL(format);\n }\n\n function paramThreeToGL(p) {\n\n var extension;\n\n if (p === THREE.RepeatWrapping) return _gl.REPEAT;\n if (p === THREE.ClampToEdgeWrapping) return _gl.CLAMP_TO_EDGE;\n if (p === THREE.MirroredRepeatWrapping) return _gl.MIRRORED_REPEAT;\n\n if (p === THREE.NearestFilter) return _gl.NEAREST;\n if (p === THREE.NearestMipMapNearestFilter) return _gl.NEAREST_MIPMAP_NEAREST;\n if (p === THREE.NearestMipMapLinearFilter) return _gl.NEAREST_MIPMAP_LINEAR;\n\n if (p === THREE.LinearFilter) return _gl.LINEAR;\n if (p === THREE.LinearMipMapNearestFilter) return _gl.LINEAR_MIPMAP_NEAREST;\n if (p === THREE.LinearMipMapLinearFilter) return _gl.LINEAR_MIPMAP_LINEAR;\n\n if (p === THREE.UnsignedByteType) return _gl.UNSIGNED_BYTE;\n if (p === THREE.UnsignedShort4444Type) return _gl.UNSIGNED_SHORT_4_4_4_4;\n if (p === THREE.UnsignedShort5551Type) return _gl.UNSIGNED_SHORT_5_5_5_1;\n if (p === THREE.UnsignedShort565Type) return _gl.UNSIGNED_SHORT_5_6_5;\n\n if (p === THREE.ByteType) return _gl.BYTE;\n if (p === THREE.ShortType) return _gl.SHORT;\n if (p === THREE.UnsignedShortType) return _gl.UNSIGNED_SHORT;\n if (p === THREE.IntType) return _gl.INT;\n if (p === THREE.UnsignedIntType) return _gl.UNSIGNED_INT;\n if (p === THREE.FloatType) return _gl.FLOAT;\n if (p === THREE.HalfFloatType) return _isWebGL2 ? _gl.HALF_FLOAT : 0x8D61; //_gl.HALF_FLOAT_OES;\n\n if (p === THREE.AlphaFormat) return _gl.ALPHA;\n if (p === THREE.RGBFormat) return _gl.RGB;\n if (p === THREE.RGBAFormat) return _gl.RGBA;\n if (p === THREE.LuminanceFormat) return _gl.LUMINANCE;\n if (p === THREE.LuminanceAlphaFormat) return _gl.LUMINANCE_ALPHA;\n\n if (p === THREE.AddEquation) return _gl.FUNC_ADD;\n if (p === THREE.MinEquation) return _gl.MIN;\n if (p === THREE.MaxEquation) return _gl.MAX;\n if (p === THREE.SubtractEquation) return _gl.FUNC_SUBTRACT;\n if (p === THREE.ReverseSubtractEquation) return _gl.FUNC_REVERSE_SUBTRACT;\n\n if (p === THREE.ZeroFactor) return _gl.ZERO;\n if (p === THREE.OneFactor) return _gl.ONE;\n if (p === THREE.SrcColorFactor) return _gl.SRC_COLOR;\n if (p === THREE.OneMinusSrcColorFactor) return _gl.ONE_MINUS_SRC_COLOR;\n if (p === THREE.SrcAlphaFactor) return _gl.SRC_ALPHA;\n if (p === THREE.OneMinusSrcAlphaFactor) return _gl.ONE_MINUS_SRC_ALPHA;\n if (p === THREE.DstAlphaFactor) return _gl.DST_ALPHA;\n if (p === THREE.OneMinusDstAlphaFactor) return _gl.ONE_MINUS_DST_ALPHA;\n\n if (p === THREE.DstColorFactor) return _gl.DST_COLOR;\n if (p === THREE.OneMinusDstColorFactor) return _gl.ONE_MINUS_DST_COLOR;\n if (p === THREE.SrcAlphaSaturateFactor) return _gl.SRC_ALPHA_SATURATE;\n\n extension = extensions.get('WEBGL_compressed_texture_s3tc');\n\n if (extension !== null) {\n\n if (p === THREE.RGB_S3TC_DXT1_Format) return extension.COMPRESSED_RGB_S3TC_DXT1_EXT;\n if (p === THREE.RGBA_S3TC_DXT1_Format) return extension.COMPRESSED_RGBA_S3TC_DXT1_EXT;\n if (p === THREE.RGBA_S3TC_DXT3_Format) return extension.COMPRESSED_RGBA_S3TC_DXT3_EXT;\n if (p === THREE.RGBA_S3TC_DXT5_Format) return extension.COMPRESSED_RGBA_S3TC_DXT5_EXT;\n\n }\n\n extension = extensions.get('WEBGL_compressed_texture_pvrtc');\n\n if (extension !== null) {\n\n if (p === THREE.RGB_PVRTC_4BPPV1_Format) return extension.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;\n if (p === THREE.RGB_PVRTC_2BPPV1_Format) return extension.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;\n if (p === THREE.RGBA_PVRTC_4BPPV1_Format) return extension.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;\n if (p === THREE.RGBA_PVRTC_2BPPV1_Format) return extension.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;\n\n }\n\n extension = extensions.get('EXT_blend_minmax');\n\n if (extension !== null) {\n\n if (p === THREE.MinEquation) return extension.MIN_EXT;\n if (p === THREE.MaxEquation) return extension.MAX_EXT;\n\n }\n\n return 0;\n\n }\n\n // Allocations\n\n function allocateLights(lights) {\n\n var dirLights = 0;\n var pointLights = 0;\n var spotLights = 0;\n var hemiLights = 0;\n\n for (var l = 0, ll = lights.length; l < ll; l++) {\n\n var light = lights[l];\n\n if (light.onlyShadow) continue;\n\n if (light instanceof THREE.DirectionalLight) dirLights++;\n if (light instanceof THREE.PointLight) pointLights++;\n if (light instanceof THREE.SpotLight) spotLights++;\n if (light instanceof THREE.HemisphereLight) hemiLights++;\n\n }\n\n return { 'directional': dirLights, 'point': pointLights, 'spot': spotLights, 'hemi': hemiLights };\n\n }\n\n};","import * as THREE from \"three\";\n\nvar addLineNumbers = function addLineNumbers(code) {\n var lines = code.split('\\n');\n for (var i = 0; i < lines.length; i++) {\n lines[i] = i + 1 + ': ' + lines[i];\n }\n return lines.join('\\n');\n};\n\nexport function WebGLShader(gl, type, code) {\n var shader = gl.createShader(type);\n gl.shaderSource(shader, code);\n gl.compileShader(shader);\n if (typeof DEBUG_SHADERS !== \"undefined\" && DEBUG_SHADERS) {\n if (gl.getShaderParameter(shader, gl.COMPILE_STATUS) === false) {\n THREE.error('THREE.WebGLShader: Shader couldn\\'t compile.');\n }\n\n if (gl.getShaderInfoLog(shader) !== '') {\n THREE.warn('THREE.WebGLShader: gl.getShaderInfoLog()', gl.getShaderInfoLog(shader), addLineNumbers(code));\n }\n }\n\n // --enable-privileged-webgl-extension\n // THREE.log( type, gl.getExtension( 'WEBGL_debug_shaders' ).getTranslatedShaderSource( shader ) );\n return shader;\n}","module.exports = \"#if NUM_CUTPLANES > 0\\nuniform vec4 cutplanes[NUM_CUTPLANES];\\nvoid checkCutPlanes(vec3 worldPosition) {\\n for (int i=0; i 0.0) {\\n discard;\\n }\\n }\\n}\\n#endif\\n\";","module.exports = \"uniform float point_size;\";","module.exports = \"\\nuniform sampler2D tDepth;\\nuniform vec4 projInfo;\\nuniform float isOrtho;\\nuniform mat4 worldMatrix_mainPass;\\nvec3 reconstructCSPosition(vec2 fragCoords, float z) {\\n return vec3((fragCoords * projInfo.xy + projInfo.zw) * mix(z, -1.0, isOrtho), z);\\n}\\nvec3 reconstructWorldPosition(vec2 fragCoords, vec2 screenUv) {\\n float zCam = texture2D(tDepth, screenUv).z;\\n vec3 csPos = reconstructCSPosition(fragCoords, zCam);\\n return (worldMatrix_mainPass * vec4(csPos, 1.0)).xyz;\\n}\\n\";","module.exports = \"\\nuniform float envRotationSin;\\nuniform float envRotationCos;\\nvec3 adjustLookupVector(in vec3 lookup) {\\n return vec3(\\n envRotationCos * lookup.x - envRotationSin * lookup.z,\\n lookup.y,\\n envRotationSin * lookup.x + envRotationCos * lookup.z);\\n}\\nvec3 RGBMDecode(in vec4 vRGBM, in float exposure) {\\n vec3 ret = vRGBM.rgb * (vRGBM.a * 16.0);\\n ret *= ret;\\n ret *= exposure;\\n return ret;\\n}\\nvec3 GammaDecode(in vec4 vRGBA, in float exposure) {\\n return vRGBA.xyz * vRGBA.xyz * exposure;\\n}\\nvec3 sampleIrradianceMap(vec3 dirWorld, samplerCube irrMap, float exposure) {\\n vec4 cubeColor4 = textureCube(irrMap, adjustLookupVector(dirWorld));\\n#ifdef IRR_GAMMA\\n vec3 indirectDiffuse = GammaDecode(cubeColor4, exposure);\\n#elif defined(IRR_RGBM)\\n vec3 indirectDiffuse = RGBMDecode(cubeColor4, exposure);\\n#else\\n vec3 indirectDiffuse = cubeColor4.xyz;\\n#ifdef GAMMA_INPUT\\n indirectDiffuse.xyz *= indirectDiffuse.xyz;\\n#endif\\n#endif\\n return indirectDiffuse;\\n}\\n\";","module.exports = \"#ifdef HATCH_PATTERN\\ngl_FragColor = calculateHatchPattern(hatchParams, gl_FragCoord.xy, gl_FragColor, hatchTintColor, hatchTintIntensity);\\n#endif\\n#ifdef MRT_NORMALS\\noutNormal = vec4(geomNormal.x, geomNormal.y, depth, gl_FragColor.a < 1.0 ? 0.0 : 1.0);\\n#endif\\n#include\\n\";","module.exports = \"float averageOfFloat3(in vec3 value) { \\n const float oneThird = 1.0 / 3.0; \\n return dot(value, vec3(oneThird, oneThird, oneThird)); \\n} \\n\";","module.exports = \"#ifdef HATCH_PATTERN\\nuniform vec2 hatchParams;\\nuniform vec3 hatchTintColor;\\nuniform float hatchTintIntensity;\\nfloat curveGaussian(float r, float invWidth) {\\n float amt = clamp(r * invWidth, 0.0, 1.0);\\n float exponent = amt * 3.5;\\n return exp(-exponent*exponent);\\n}\\nvec4 calculateHatchPattern(vec2 hatchParams, vec2 coord, vec4 fragColor, vec3 hatchTintColor, float hatchTintIntensity ) {\\n float hatchSlope = hatchParams.x;\\n float hatchPeriod = hatchParams.y;\\n if (abs(hatchSlope) <= 1.0) {\\n float hatchPhase = coord.y - hatchSlope * coord.x;\\n float dist = abs(mod((hatchPhase), (hatchPeriod)));\\n if (dist < 1.0) {\\n fragColor = vec4(0.0,0.0,0.0,1.0);\\n } else {\\n fragColor.xyz = mix(fragColor.xyz, hatchTintColor, hatchTintIntensity);\\n }\\n } else {\\n float hatchPhase = - coord.y / hatchSlope + coord.x;\\n float dist = abs(mod((hatchPhase), (hatchPeriod)));\\n if (dist < 1.0) {\\n fragColor = vec4(0.0,0.0,0.0,1.0);\\n } else {\\n fragColor.xyz = mix(fragColor.xyz, hatchTintColor, hatchTintIntensity);\\n }\\n }\\n return fragColor;\\n}\\n#endif\\n\";","module.exports = \"vec3 rgb2hsv(vec3 color)\\n{\\n float delta;\\n float colorMax, colorMin;\\n float h,s,v;\\n vec3 hsv;\\n colorMax = max(color.r,color.g);\\n colorMax = max(colorMax,color.b);\\n colorMin = min(color.r,color.g);\\n colorMin = min(colorMin,color.b);\\n v = colorMax;\\n if(colorMax != 0.0)\\n {\\n s = (colorMax - colorMin)/colorMax;\\n }\\n else\\n {\\n s = 0.0;\\n }\\n if(s != 0.0)\\n {\\n delta = colorMax-colorMin;\\n if (color.r == colorMax)\\n {\\n h = (color.g-color.b)/delta;\\n }\\n else if (color.g == colorMax)\\n {\\n h = 2.0 + (color.b-color.r) / delta;\\n }\\n else\\n {\\n h = 4.0 + (color.r-color.g)/delta;\\n }\\n h /= 6.0;\\n if( h < 0.0)\\n {\\n h +=1.0;\\n }\\n }\\n else\\n {\\n h = 0.0;\\n }\\n hsv = vec3(h,s,v);\\n return hsv;\\n}\\nvec3 hsv2rgb(vec3 hsv)\\n{\\n vec3 color;\\n float f,p,q,t;\\n float h,s,v;\\n float i,hi;\\n {\\n h = hsv.x*6.0;\\n s = hsv.y;\\n v = hsv.z;\\n i = floor(h);\\n f = h-i;\\n p = v * (1.0 - s);\\n q = v * (1.0 - (s * f));\\n t = v * (1.0 - (s * (1.0 - f)));\\n float r,g,b;\\n if (i == 0.0)\\n {\\n r = v;\\n g = t;\\n b = p;\\n }\\n else if (i == 1.0)\\n {\\n r = q;\\n g = v;\\n b = p;\\n }\\n else if (i == 2.0)\\n {\\n r = p;\\n g = v;\\n b = t;\\n }\\n else if (i == 3.0)\\n {\\n r = p;\\n g = q;\\n b = v;\\n }\\n else if (i == 4.0)\\n {\\n r = t;\\n g = p;\\n b = v;\\n }\\n else\\n {\\n r = v;\\n g = p;\\n b = q;\\n }\\n color = vec3(r,g,b);\\n }\\n return color;\\n}\";","module.exports = \"#if defined(MRT_NORMALS) || defined(MRT_ID_BUFFER)\\n varying highp float depth;\\n#endif\\n#if defined(MRT_ID_BUFFER) || defined(ID_COLOR)\\n #ifdef USE_VERTEX_ID\\n varying vec3 vId;\\n #elif defined(LINE_2D_SHADER)\\n varying vec4 dbId;\\n #else\\n uniform vec3 dbId;\\n #endif\\n#endif\\n#if defined(MRT_ID_BUFFER) || defined(MODEL_COLOR)\\n uniform vec3 modelId;\\n#endif\\n#ifdef _LMVWEBGL2_\\n #if defined(MRT_NORMALS)\\n layout(location = 1) out vec4 outNormal;\\n #if defined(MRT_ID_BUFFER)\\n layout(location = 2) out vec4 outId;\\n #if defined(MODEL_COLOR)\\n layout(location = 3) out vec4 outModelId;\\n #endif\\n #endif\\n #elif defined(MRT_ID_BUFFER)\\n layout(location = 1) out vec4 outId;\\n #if defined(MODEL_COLOR)\\n layout(location = 2) out vec4 outModelId;\\n #endif\\n #endif\\n#else\\n #define gl_FragColor gl_FragData[0]\\n #if defined(MRT_NORMALS)\\n #define outNormal gl_FragData[1]\\n #if defined(MRT_ID_BUFFER)\\n #define outId gl_FragData[2]\\n #if defined(MODEL_COLOR)\\n #define outModelId gl_FragData[3]\\n #endif\\n #endif\\n #elif defined(MRT_ID_BUFFER)\\n #define outId gl_FragData[1]\\n #if defined(MODEL_COLOR)\\n #define outModelId gl_FragData[2]\\n #endif\\n #endif\\n#endif\";","module.exports = \"#ifdef USE_VERTEX_ID\\nattribute vec3 id;\\nvarying vec3 vId;\\n#endif\\n\";","module.exports = \"\\n#if defined(USE_VERTEX_ID) && (defined(MRT_ID_BUFFER) || defined(ID_COLOR))\\n vec3 dbId = vId;\\n#endif\\n#ifdef MRT_ID_BUFFER\\n #ifndef ENABLE_ID_DISCARD\\n const float writeId = 1.0;\\n #endif\\n outId = vec4(dbId.rgb, writeId);\\n #ifdef MODEL_COLOR\\n outModelId = vec4(modelId.rgb, writeId);\\n #endif\\n#elif defined(ID_COLOR)\\n #ifdef ENABLE_ID_DISCARD\\n if (writeId==0.0) {\\n discard;\\n }\\n #endif\\n gl_FragColor = vec4(dbId.rgb, 1.0);\\n#elif defined(MODEL_COLOR)\\n #ifdef ENABLE_ID_DISCARD\\n if (writeId==0.0) {\\n discard;\\n }\\n #endif\\n gl_FragColor = vec4(modelId.rgb, 1.0);\\n#endif\\n\";","module.exports = \"\\n#ifdef USE_VERTEX_ID\\nvId = id;\\n#endif\\n\";","module.exports = \"\\n#ifdef USE_INSTANCING\\nattribute vec3 instOffset;\\nattribute vec4 instRotation;\\nattribute vec3 instScaling;\\nvec3 applyQuaternion(vec3 p, vec4 q) {\\n return p + 2.0 * cross(q.xyz, cross(q.xyz, p) + q.w * p);\\n}\\nvec3 getInstancePos(vec3 pos) {\\n return instOffset + applyQuaternion(instScaling * pos, instRotation);\\n}\\nvec3 getInstanceNormal(vec3 normal) {\\n return applyQuaternion(normal/instScaling, instRotation);\\n}\\n#else\\nvec3 getInstancePos(vec3 pos) { return pos; }\\nvec3 getInstanceNormal(vec3 normal) { return normal; }\\n#endif\\n\";","module.exports = \"\\n#define LINE_2D_SHADER 1\\n#define TAU 6.28318530718\\n#define PI 3.14159265358979\\n#define HALF_PI 1.57079632679\\n#define PI_0_5 HALF_PI\\n#define PI_1_5 4.71238898038\\n#define ENABLE_ID_DISCARD\\n#define VBB_GT_TRIANGLE_INDEXED 0.0\\n#define VBB_GT_LINE_SEGMENT 1.0\\n#define VBB_GT_ARC_CIRCULAR 2.0\\n#define VBB_GT_ARC_ELLIPTICAL 3.0\\n#define VBB_GT_TEX_QUAD 4.0\\n#define VBB_GT_ONE_TRIANGLE 5.0\\n#define VBB_GT_MSDF_TRIANGLE_INDEXED 6.0\\n#define VBB_INSTANCED_FLAG 0.0\\n#define VBB_SEG_START_RIGHT 0.0\\n#define VBB_SEG_START_LEFT 1.0\\n#define VBB_SEG_END_RIGHT 2.0\\n#define VBB_SEG_END_LEFT 3.0\\n#define LTSCALE 0.25\\nvarying vec4 fsColor;\\nvarying vec2 fsOffsetDirection;\\nvarying vec4 fsMultipurpose;\\nvarying float fsHalfWidth;\\nvarying vec2 fsVpTC;\\nvarying float fsGhosting;\\n#ifdef LOADING_ANIMATION\\nvarying float loadingProgress;\\n#endif\\n\";","module.exports = \"#if defined(USE_SURFACE_NORMAL_MAP) || defined( USE_LAYERED_NORMAL_MAP ) || defined( USE_TILING_NORMAL )\\nvoid heightMapTransform(\\n sampler2D bumpTexture,\\n vec2 uv,\\n mat3 transform,\\n vec2 bumpScale,\\n inout vec3 T,\\n inout vec3 B,\\n inout vec3 N\\n) {\\n vec2 st = (transform * vec3(uv, 1.0)).xy;\\n mat3 mtxTangent = mat3(T, B, N);\\n T = normalize(mtxTangent * (transform * vec3(1.0, 0.0, 0.0)));\\n B = normalize(mtxTangent * (transform * vec3(0.0, 1.0, 0.0)));\\n const float oneThird = 1.0 / 3.0;\\n vec3 avg = vec3(oneThird, oneThird, oneThird);\\n vec2 offset = fwidth(st);\\n float h0 = dot(texture2D(bumpTexture, st).xyz, avg);\\n float hx = dot(texture2D(bumpTexture, st + vec2(offset.x, 0.0)).xyz, avg);\\n float hy = dot(texture2D(bumpTexture, st + vec2(0.0, offset.y)).xyz, avg);\\n vec2 diff = vec2(h0 - hx, h0 - hy) / offset;\\n N = normalize(\\n N + (\\n diff.x * T * bumpScale.x +\\n diff.y * B * bumpScale.y\\n )\\n );\\n}\\nvoid normalMapTransform(\\n sampler2D bumpTexture,\\n vec2 uv,\\n mat3 transform,\\n vec2 bumpScale,\\n inout vec3 T,\\n inout vec3 B,\\n inout vec3 N\\n) {\\n vec2 st = (transform * vec3(uv, 1.0)).xy;\\n vec3 mapN = 2.0 * texture2D(bumpTexture, st).xyz - 1.0;\\n mapN.xy *= bumpScale.x;\\n mapN.z *= bumpScale.y;\\n vec3 v = vec3(mapN.y, -mapN.x, 0.0);\\n float c = -mapN.z;\\n mat3 skewV = mat3(\\n 0.0, v.z, -v.y,\\n -v.z, 0.0, v.x,\\n v.y, -v.x, 0.0\\n );\\n mat3 rot = mat3(1.0) + skewV + skewV*skewV * 1.0/(1.0-c);\\n N *= rot;\\n T *= rot;\\n B *= rot;\\n}\\n#endif\\n\";","module.exports = \"vec3 orderedDithering(vec3 col) {\\n const vec4 m0 = vec4( 1.0, 13.0, 4.0, 16.0);\\n const vec4 m1 = vec4( 9.0, 5.0, 12.0, 8.0);\\n const vec4 m2 = vec4( 3.0, 15.0, 2.0, 14.0);\\n const vec4 m3 = vec4(11.0, 7.0, 10.0, 6.0);\\n int i = int(mod(float(gl_FragCoord.x), 4.0));\\n int j = int(mod(float(gl_FragCoord.y), 4.0));\\n vec4 biasRow;\\n if (i==0) biasRow = m0;\\n else if (i==1) biasRow = m1;\\n else if (i==2) biasRow = m2;\\n else biasRow = m3;\\n float bias;\\n if (j==0) bias = biasRow.x;\\n else if (j==1) bias = biasRow.y;\\n else if (j==2) bias = biasRow.z;\\n else bias = biasRow.w;\\n return col + bias / 17.0 / 256.0;\\n}\\n\";","module.exports = \"\\nvec4 packDepth( const in float depth ) {\\n vec4 enc = vec4(1.0, 255.0, 65025.0, 160581375.0) * depth;\\n enc = fract(enc);\\n enc -= enc.yzww * vec4(1.0/255.0,1.0/255.0,1.0/255.0,0.0);\\n return enc;\\n}\\nfloat unpackDepth( const in vec4 rgba_depth ) {\\n return dot( rgba_depth, vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/160581375.0) );\\n}\\n\";","module.exports = \"\\n#define kPI 3.14159265358979\\nvec2 encodeNormal (vec3 n) {\\n return (vec2(atan(n.y,n.x)/kPI, n.z)+1.0)*0.5;\\n}\\nvec3 decodeNormal (vec2 enc) {\\n vec2 ang = enc * 2.0 - 1.0;\\n vec2 scth = vec2(sin(ang.x * kPI), cos(ang.x * kPI));\\n vec2 scphi = vec2(sqrt(1.0 - ang.y * ang.y), ang.y);\\n return vec3(scth.y * scphi.x, scth.x * scphi.x, scphi.y);\\n}\\n\";","module.exports = \"gl_PointSize = point_size;\";","module.exports = \"\\nvec3 TransmitAdjust(vec3 transmission, vec3 f0) \\n{ \\n vec3 limit = max(1.0 - f0, 0.00001); \\n return clamp(transmission, vec3(0.0, 0.0, 0.0), limit) / limit; \\n} \\nfloat ColorToIlluminance(in vec3 color) \\n{ \\n const vec3 rgb2grey = vec3(0.299, 0.587, 0.114); \\n float illuminance = dot(rgb2grey, color); \\n return illuminance; \\n} \\nvoid applyPrismGlazingOpacity(\\n inout vec4 color,\\n vec3 transmissionF,\\n float transmissionAlpha,\\n float NdotV,\\n float glazingIlluminace) \\n{\\n const float third = 1.0/3.0; \\n float transSurface = exp(-(transmissionAlpha + (transmissionAlpha < 0.0025 ? 0.0 : 0.25)) * NdotV * PI); \\n float opacity = 1.0- dot((1.0 - transmissionF), vec3(third,third,third)) * transSurface * glazingIlluminace; \\n opacity = clamp(opacity, 0.01, 0.99);\\n color.a *= opacity;\\n} \\n\";","module.exports = \"void applyPrismTransparency(\\n inout vec4 color,\\n vec3 transparentColor,\\n float transparentIor\\n) {\\n float fsLevel = max(max(color.r, color.g), color.b);\\n color = vec4(color.rgb/fsLevel, fsLevel);\\n float transLevel = min(min(transparentColor.r, transparentColor.g), transparentColor.b);\\n transLevel = min( (1.0 - surface_roughness), transLevel );\\n float transAlpha = (1.0 - transLevel) * 0.4 + surface_roughness * 0.55;\\n vec3 tr_g_color = sqrt(transparentColor);\\n vec4 transColor = vec4(0.5 * vec3(tr_g_color), transAlpha);\\n float strength = 1.0 - (1.0 - fsLevel) * (1.0 - fsLevel);\\n color = mix(transColor, color, strength);\\n color.a = max(color.a, 0.05);\\n if (transparentIor == 1.0 && tr_g_color == vec3(1.0)) {\\n color.a = 0.0;\\n }\\n}\";","module.exports = \"#if defined( PRISMWOOD )\\n#define ONE 0.00390625\\nfloat GetIndexedValue(vec4 array, int index)\\n{\\n if (index == 0)\\n return array[0];\\n else if (index == 1)\\n return array[1];\\n else if (index == 2)\\n return array[2];\\n else if (index == 3)\\n return array[3];\\n else\\n return 0.0;\\n}\\nint GetIndexedValue(ivec2 array, int index)\\n{\\n if (index == 0)\\n return array[0];\\n else if (index == 1)\\n return array[1];\\n else\\n return 0;\\n}\\n#if defined( USE_WOOD_CURLY_DISTORTION_MAP )\\nfloat SampleCurlyPattern(vec2 uv)\\n{\\n vec2 uv_wood_curly_distortion_map = (wood_curly_distortion_map_texMatrix * vec3(uv, 1.0)).xy;\\n WOOD_CURLY_DISTORTION_CLAMP_TEST;\\n vec3 curlyDistortion = texture2D(wood_curly_distortion_map, uv_wood_curly_distortion_map).xyz;\\n if(wood_curly_distortion_map_invert) curlyDistortion = vec3(1.0) - curlyDistortion;\\n return curlyDistortion.r;\\n}\\nvec3 DistortCurly(vec3 p)\\n{\\n if (!wood_curly_distortion_enable) return p;\\n float r = length(p.xy);\\n if (r < 0.00001) return p;\\n const float INV_ANGLE_INTERVAL = 1.27323954;\\n const float NUM_INTERVAL = 8.0;\\n float theta = atan(p.y, p.x);\\n if (theta < 0.0)\\n theta += PI2;\\n float intIdx = theta * INV_ANGLE_INTERVAL;\\n int idx0 = int(mod(floor(intIdx), NUM_INTERVAL));\\n int idx1 = int(mod(ceil(intIdx), NUM_INTERVAL));\\n const vec4 HASH_TABLE1 = vec4(0.450572,0.114598, 0.886043, 0.315119);\\n const vec4 HASH_TABLE2 = vec4(0.216133,0.306264, 0.685616, 0.317907);\\n float offset0 = idx0 < 4 ? GetIndexedValue(HASH_TABLE1, idx0) : GetIndexedValue(HASH_TABLE2, idx0-4);\\n float offset1 = idx1 < 4 ? GetIndexedValue(HASH_TABLE1, idx1) : GetIndexedValue(HASH_TABLE2, idx1-4);\\n const float maxOffset = 100.0;\\n offset0 = (offset0 - 0.5) * maxOffset;\\n offset1 = (offset1 - 0.5) * maxOffset;\\n vec2 uv0 = vec2(p.z + offset0, r);\\n float shiftWeight0 = SampleCurlyPattern(uv0);\\n vec2 uv1 = vec2(p.z + offset1, r);\\n float shiftWeight1 = SampleCurlyPattern(uv1);\\n float interpWeight = fract(intIdx);\\n float shiftWeight = mix(shiftWeight0, shiftWeight1, interpWeight);\\n const float INV_MIN_RADIUS = 2.0;\\n float shiftWeightAdjust = smoothstep(0.0, 1.0, r * INV_MIN_RADIUS);\\n r -= wood_curly_distortion_scale * (shiftWeight * shiftWeightAdjust);\\n float thetaNew = atan(p.y, p.x);\\n vec3 pNew = p;\\n pNew.x = r * cos(thetaNew);\\n pNew.y = r * sin(thetaNew);\\n return pNew;\\n}\\n#endif\\nvec3 un2sn(vec3 range)\\n{\\n return range * 2.0 - 1.0;\\n}\\nfloat inoise(vec3 p)\\n{\\n vec3 modp = mod(floor(p), 256.0);\\n modp.xy = modp.xy * ONE;\\n vec4 AA = texture2D(perm2DMap, vec2(modp.x, modp.y), 0.0) * 255.0;\\n AA = AA + modp.z;\\n AA = mod(floor(AA), 256.0);\\n AA *= ONE;\\n vec3 gradx1 = un2sn(texture2D(permGradMap,vec2(AA.x,0.0),0.0).xyz);\\n vec3 grady1 = un2sn(texture2D(permGradMap,vec2(AA.y,0.0),0.0).xyz);\\n vec3 gradz1 = un2sn(texture2D(permGradMap,vec2(AA.z,0.0),0.0).xyz);\\n vec3 gradw1 = un2sn(texture2D(permGradMap,vec2(AA.w,0.0),0.0).xyz);\\n vec3 gradx2 = un2sn(texture2D(permGradMap,vec2(AA.x + ONE,0.0),0.0).xyz);\\n vec3 grady2 = un2sn(texture2D(permGradMap,vec2(AA.y + ONE,0.0),0.0).xyz);\\n vec3 gradz2 = un2sn(texture2D(permGradMap,vec2(AA.z + ONE,0.0),0.0).xyz);\\n vec3 gradw2 = un2sn(texture2D(permGradMap,vec2(AA.w + ONE,0.0),0.0).xyz);\\n p -= floor(p);\\n vec3 fadep = p * p * p * (p * (p * 6.0 - 15.0) + 10.0);\\n return mix( mix( mix( dot(gradx1, p ),\\n dot(gradz1, p + vec3(-1.0, 0.0, 0.0)), fadep.x),\\n mix( dot(grady1, p + vec3(0.0, -1.0, 0.0)),\\n dot(gradw1, p + vec3(-1.0, -1.0, 0.0)), fadep.x), fadep.y),\\n mix( mix( dot(gradx2, p + vec3(0.0, 0.0, -1.0)),\\n dot(gradz2, p + vec3(-1.0, 0.0, -1.0)), fadep.x),\\n mix( dot(grady2, p + vec3(0.0, -1.0, -1.0)),\\n dot(gradw2, p + vec3(-1.0, -1.0, -1.0)), fadep.x), fadep.y), fadep.z);\\n}\\nfloat inoise(float p)\\n{\\n float modp = mod(floor(p), 256.0);\\n modp = (modp + 256.0) * ONE;\\n float permx = texture2D(permutationMap, vec2(modp, 0.0), 0.0).r;\\n float gradx = texture2D(gradientMap, vec2(permx, 0.0), 0.0).r*2.0-1.0;\\n float permy = texture2D(permutationMap, vec2(modp + ONE, 0.0), 0.0).r;\\n float grady = texture2D(gradientMap, vec2(permy, 0.0), 0.0).r*2.0-1.0;\\n p -= floor(p);\\n float fadep = p * p * p * (p * (p * 6.0 - 15.0) + 10.0);\\n return mix(gradx * p, grady * (p - 1.0), fadep);\\n}\\nfloat multiband_inoise(vec3 p, int bands, vec4 w, vec4 f)\\n{\\n float noise = 0.0;\\n for(int i = 0; i < 4; ++i)\\n {\\n if (i >= bands) break;\\n noise += GetIndexedValue(w, i) * inoise(p * GetIndexedValue(f, i));\\n }\\n return noise;\\n}\\nfloat multiband_inoise(float p, int bands, vec4 w, vec4 f)\\n{\\n float noise = 0.0;\\n for(int i = 0; i < 4; ++i)\\n {\\n if (i >= bands) break;\\n noise += GetIndexedValue(w, i) * inoise(p * GetIndexedValue(f, i));\\n }\\n return noise;\\n}\\nvec3 Distort3DCosineRadialDir(vec3 p)\\n{\\n float radius = length(p.xy);\\n if (radius < 0.00001) return p;\\n vec2 theta = p.xy / radius;\\n float radiusShift = 0.0;\\n for (int i = 0; i < 4; ++i)\\n {\\n if (i >= wood_fiber_cosine_bands) break;\\n radiusShift += GetIndexedValue(wood_fiber_cosine_weights, i) * cos(p.z * RECIPROCAL_PI2 * GetIndexedValue(wood_fiber_cosine_frequencies, i));\\n }\\n const float MIN_RADIUS = 1.5;\\n float weight = clamp(radius / MIN_RADIUS, 0.0, 1.0);\\n if(weight >= 0.5)\\n weight = weight * weight * (3.0 - (weight + weight));\\n p.xy += theta * radiusShift * weight;\\n return p;\\n}\\nvec3 Distort3DPerlin(vec3 p)\\n{\\n vec3 pAniso = vec3(p.xy, p.z * wood_fiber_perlin_scale_z);\\n p.xy += multiband_inoise(pAniso, wood_fiber_perlin_bands, wood_fiber_perlin_weights, wood_fiber_perlin_frequencies);\\n return p;\\n}\\nvec3 Distort(vec3 p)\\n{\\n if(wood_fiber_cosine_enable)\\n p = Distort3DCosineRadialDir(p);\\n if(wood_fiber_perlin_enable)\\n p = Distort3DPerlin(p);\\n return p;\\n}\\nfloat DistortRadiusLength(float radiusLength)\\n{\\n radiusLength += multiband_inoise(radiusLength, wood_growth_perlin_bands, wood_growth_perlin_weights, wood_growth_perlin_frequencies);\\n if (radiusLength < 0.0) radiusLength = 0.0;\\n return radiusLength;\\n}\\nfloat ComputeEarlyWoodRatio(float radiusLength)\\n{\\n float fraction = mod(radiusLength, wood_ring_thickness) / wood_ring_thickness;\\n if (fraction <= wood_ring_fraction.y)\\n return 1.0;\\n else if(fraction <= wood_ring_fraction.x)\\n return (1.0 - (fraction - wood_ring_fraction.y) / wood_fall_rise.x);\\n else if(fraction <= wood_ring_fraction.w)\\n return 0.0;\\n else\\n return ((fraction - wood_ring_fraction.w) / wood_fall_rise.y);\\n}\\nvec3 DistortEarlyColor(vec3 earlyColor, float radiusLength)\\n{\\n float expValue = 1.0 + multiband_inoise(radiusLength,wood_earlycolor_perlin_bands,wood_earlycolor_perlin_weights,wood_earlycolor_perlin_frequencies);\\n earlyColor = pow(abs(earlyColor), vec3(expValue));\\n return earlyColor;\\n}\\nvec3 DistortLateColor(vec3 lateColor, float radiusLength)\\n{\\n float expValue = 1.0 + multiband_inoise(radiusLength,wood_latecolor_perlin_bands,wood_latecolor_perlin_weights,wood_latecolor_perlin_frequencies);\\n lateColor = pow(abs(lateColor), vec3(expValue));\\n return lateColor;\\n}\\nvec3 DistortDiffuseColor(vec3 diffAlbedo, vec3 p)\\n{\\n p.z *= wood_diffuse_perlin_scale_z;\\n float expValue = 1.0 + multiband_inoise(p, wood_diffuse_perlin_bands, wood_diffuse_perlin_weights, wood_diffuse_perlin_frequencies);\\n diffAlbedo = pow(abs(diffAlbedo), vec3(expValue));\\n return diffAlbedo;\\n}\\nfloat LayerRoughnessVar(float roughness, float earlyWoodRatio)\\n{\\n return earlyWoodRatio * wood_groove_roughness + (1.0 - earlyWoodRatio) * roughness;\\n}\\nfloat hashword(vec2 k)\\n{\\n k = mod(k, vec2(256.0)) * ONE;\\n float a = texture2D(permutationMap, vec2(k.x, 0.0)).x + k.y ;\\n a = texture2D(permutationMap, vec2(a, 0.0)).x ;\\n return a*255.0;\\n}\\nfloat wyvillsq(float rsq)\\n{\\n if (rsq >= 1.0) return 0.0;\\n float tmp = 1.0 - rsq;\\n return tmp*tmp*tmp;\\n}\\nfloat Weight2DNeighborImpulses(vec3 p, float woodWeight)\\n{\\n if(woodWeight <= 0.0) return 0.0;\\n float poreRadius = wood_pore_radius * woodWeight;\\n vec2 left = floor((p.xy - poreRadius) / wood_pore_cell_dim);\\n vec2 right = floor((p.xy + poreRadius) / wood_pore_cell_dim);\\n float weight = 0.0;\\n float invRsq = 1.0 / (poreRadius * poreRadius);\\n const float norm = 1.0 / 15.0;\\n for (int j = 0; j <= 4; j++)\\n {\\n if (j > int(right.y - left.y)) continue;\\n for (int i = 0; i <= 4; i++)\\n {\\n if (i > int(right.x - left.x)) continue;\\n vec2 pij = vec2(float(i) + left.x,float(j) + left.y);\\n float hRNum = hashword(pij);\\n float impPosX = mod(hRNum, 16.0) * norm;\\n float impPosY = floor(hRNum / 16.0) * norm;\\n impPosX = (pij.x + impPosX)* wood_pore_cell_dim;\\n impPosY = (pij.y + impPosY)* wood_pore_cell_dim;\\n float dsq = (p.x - impPosX) * (p.x - impPosX) + (p.y - impPosY) * (p.y - impPosY);\\n weight += wyvillsq(dsq * invRsq);\\n }\\n }\\n return weight;\\n}\\nfloat Weight3DRayImpulses(vec3 p)\\n{\\n int segIdx = int(floor(p.z / wood_ray_seg_length_z));\\n float factor = p.z / wood_ray_seg_length_z - float(segIdx);\\n int segIdx1 = segIdx - 1;\\n if ( factor > 0.5 )\\n segIdx1 = segIdx + 1;\\n float theta = atan(p.y, p.x);\\n float sliceIdx = floor(((theta + PI) * RECIPROCAL_PI2) * wood_ray_num_slices);\\n if ( sliceIdx == wood_ray_num_slices)\\n sliceIdx-=1.0;\\n ivec2 arrSegs = ivec2(segIdx, segIdx1);\\n float weight = 0.0;\\n const float norm = 1.0 / 15.0;\\n float radialOffset = 5.0;\\n float radialLength = length(p.xy);\\n for (int seg = 0; seg < 2; seg++)\\n {\\n float hRNum = hashword(vec2(sliceIdx, GetIndexedValue(arrSegs, seg)));\\n float rn1 = mod(hRNum,16.0) * norm;\\n if (radialLength < radialOffset * rn1)\\n continue;\\n float rayTheta = rn1;\\n rayTheta = ( ( sliceIdx + rayTheta ) / wood_ray_num_slices ) * ( 2.0 * PI ) - PI;\\n float rayPosZ = (hRNum/16.0)* norm;\\n rayPosZ = ( float(GetIndexedValue(arrSegs, seg)) + rayPosZ ) * wood_ray_seg_length_z;\\n vec3 pt1 = vec3(0.0);\\n vec3 pt2 = vec3(cos(rayTheta), sin(rayTheta), 0.0);\\n vec3 p1 = p;\\n p1.z -= rayPosZ;\\n p1.z /= wood_ray_ellipse_z2x;\\n vec3 v1 = pt2 - pt1;\\n vec3 v2 = pt1 - p1;\\n v2 = cross(v1, v2);\\n float dist = length(v2) / length(v1);\\n float invRsq = 1.0 / ( wood_ray_ellipse_radius_x * wood_ray_ellipse_radius_x);\\n weight += wyvillsq( (dist * dist) * invRsq );\\n }\\n return weight;\\n}\\nvec3 DarkenColorWithPores(vec3 p, vec3 diffColor, float woodWeight)\\n{\\n float poresWeight = Weight2DNeighborImpulses(p, woodWeight);\\n float a = wood_pore_color_power - 1.0;\\n float b = 1.0;\\n float y = a * poresWeight + b;\\n return pow(abs(diffColor), vec3(y));\\n}\\nvec3 DarkenColorWithRays(vec3 p, vec3 diffColor)\\n{\\n float raysWeight = Weight3DRayImpulses(p);\\n float a = wood_ray_color_power - 1.0;\\n float b = 1.0;\\n float y = a * raysWeight + b;\\n return pow(abs(diffColor), vec3(y));\\n}\\nfloat ComputeWoodWeight(float earlyWoodRatio)\\n{\\n float woodWeight = 0.0;\\n if (wood_pore_type == 0)\\n woodWeight = 1.0;\\n else if (wood_pore_type == 1)\\n woodWeight = earlyWoodRatio;\\n else if (wood_pore_type == 2)\\n woodWeight = 1.0 - earlyWoodRatio;\\n else\\n woodWeight = -1.0;\\n return woodWeight;\\n}\\n#if defined( PRISMWOODBUMP )\\nfloat ComputeEarlyWoodRatioAA(float radiusLength, float invUnitExt)\\n{\\n float transPixels = min(wood_fall_rise.x, wood_fall_rise.y) * wood_ring_thickness * invUnitExt;\\n float samplesf = clamp(4.0 / transPixels, 1.0, 4.0);\\n int samples = int(samplesf);\\n float inverseSamples = 1.0 / float(samples);\\n vec2 rdelta = vec2(dFdx(radiusLength), dFdy(radiusLength)) * inverseSamples;\\n float earlywoodRatio = 0.0;\\n for (int i = 0; i < 4; ++i)\\n {\\n if (i >= samples) break;\\n for (int j = 0; j < 4; ++j)\\n {\\n if (j >= samples) break;\\n float r = radiusLength + dot(vec2(i, j), rdelta);\\n earlywoodRatio += ComputeEarlyWoodRatio(r);\\n }\\n }\\n return earlywoodRatio * (inverseSamples * inverseSamples);\\n}\\nfloat LatewoodDepthVariation(float invUnitExt)\\n{\\n float transPixels = min(wood_fall_rise.x, wood_fall_rise.y) * wood_ring_thickness * invUnitExt;\\n return clamp(transPixels * 0.5, 0.0, 1.0);\\n}\\nfloat LatewoodHeightVariation(float earlyWoodRatio, float latewoodBumpDepth,\\n float depthVar)\\n{\\n return ( 1.0 - earlyWoodRatio ) * latewoodBumpDepth * depthVar;\\n}\\nfloat PoreDepthVariation(float woodWeight, float invUnitExt)\\n{\\n float porePixels = woodWeight * wood_pore_radius * invUnitExt;\\n return clamp(porePixels, 0.0, 1.0);\\n}\\nfloat PoreHeightVariation(float earlyWoodRatio, float poresWeight, float poreDepth,\\n float depthVar)\\n{\\n return poresWeight * (-1.0 * poreDepth) * depthVar;\\n}\\nvoid ComputeTangents(vec3 normal, out vec3 u, out vec3 v)\\n{\\n float scale = normal.z < 0.0 ? -1.0 : 1.0;\\n vec3 temp = scale * normal;\\n float e = temp.z;\\n float h = 1.0/(1.0 + e);\\n float hvx = h * temp.y;\\n float hvxy = hvx * -temp.x;\\n u = vec3(e + hvx * temp.y, hvxy, -temp.x);\\n v = vec3(hvxy, e + h * temp.x * temp.x, -temp.y);\\n u *= scale;\\n v *= scale;\\n}\\nvec3 WoodBumpHeight(float heightLeft, float heightRight, float heightBack, float heightFront)\\n{\\n const float epsilon = 0.001;\\n float heightDeltaX = heightRight - heightLeft;\\n vec3 Tu = vec3(2.0 * epsilon, 0.0, heightDeltaX);\\n float heightDeltaY = heightFront - heightBack;\\n vec3 Tv = vec3(0.0, 2.0 * epsilon, heightDeltaY);\\n return cross(Tu, Tv);\\n}\\nvec3 SelectNormal(vec3 N, vec3 bumpN, vec3 V)\\n{\\n float bumpNdotV = dot(bumpN, V);\\n if(bumpNdotV > 0.0)\\n return bumpN;\\n else return N;\\n}\\nfloat MinInverseUnitExtent(vec3 p)\\n{\\n return 1.0 / max(max(length(dFdx(p.xy)), length(dFdy(p.xy))), 0.000001);\\n}\\nfloat HeightVariation(vec3 pos)\\n{\\n vec3 p = Distort(pos);\\n float radiusLength = length(p.xy);\\n if (wood_growth_perlin_enable)\\n radiusLength = DistortRadiusLength(radiusLength);\\n float invUnitExt = MinInverseUnitExtent(p);\\n float earlyWoodRatio = ComputeEarlyWoodRatioAA(radiusLength, invUnitExt);\\n float woodWeight = ComputeWoodWeight(earlyWoodRatio);\\n float poresWeight = Weight2DNeighborImpulses(p, woodWeight);\\n float depthVar = PoreDepthVariation(woodWeight, invUnitExt);\\n float poreHeightVariation = -1.0 * poresWeight * wood_pore_depth * depthVar;\\n float latewoodHeightVariation = 0.0;\\n if (wood_use_latewood_bump)\\n {\\n float latewoodDepthVar = LatewoodDepthVariation(invUnitExt);\\n latewoodHeightVariation = (1.0 - earlyWoodRatio) * wood_latewood_bump_depth * latewoodDepthVar;\\n }\\n float sumHeightVariation = poreHeightVariation + latewoodHeightVariation;\\n return sumHeightVariation;\\n}\\n#endif\\nvec3 NoiseWood(vec3 p, inout float roughness)\\n{\\n p = Distort(p);\\n float radiusLength = length(p.xy);\\n if(wood_growth_perlin_enable)\\n radiusLength = DistortRadiusLength(radiusLength);\\n#if defined( PRISMWOODBUMP )\\n float invUnitExt = MinInverseUnitExtent( p );\\n float earlyWoodRatio = ComputeEarlyWoodRatioAA(radiusLength, invUnitExt);\\n#else\\n float earlyWoodRatio = ComputeEarlyWoodRatio(radiusLength);\\n#endif\\n vec3 earlyColor = wood_early_color;\\n if (wood_earlycolor_perlin_enable)\\n earlyColor = DistortEarlyColor(earlyColor, radiusLength);\\n vec3 lateColor;\\n if (wood_use_manual_late_color)\\n lateColor = wood_manual_late_color;\\n else\\n lateColor = pow(abs(earlyColor), vec3(wood_late_color_power));\\n if(wood_latecolor_perlin_enable)\\n lateColor = DistortLateColor(lateColor, radiusLength);\\n vec3 diffAlbedo = earlyWoodRatio * earlyColor + (1.0 - earlyWoodRatio) * lateColor;\\n if(wood_diffuse_perlin_enable)\\n diffAlbedo = DistortDiffuseColor(diffAlbedo, p);\\n if (wood_use_pores)\\n {\\n float woodWeight = ComputeWoodWeight(earlyWoodRatio);\\n diffAlbedo = DarkenColorWithPores(p, diffAlbedo, woodWeight);\\n }\\n if (wood_use_rays)\\n diffAlbedo = DarkenColorWithRays(p, diffAlbedo);\\n if(wood_use_groove_roughness)\\n roughness = LayerRoughnessVar(roughness, earlyWoodRatio);\\n return clamp(diffAlbedo, vec3(0.0), vec3(1.0));\\n}\\n#if defined(PRISMWOODBUMP)\\nvoid getFinalWoodContext(\\n inout vec3 N, vec3 V, inout vec3 Tu, inout vec3 Tv, vec3 p,\\n vec3 geoNormal, vec3 tNormal, mat3 normalMatrix\\n) {\\n vec3 offsetTuLeft = p - 0.001 * Tu;\\n vec3 offsetTuRight = p + 0.001 * Tu;\\n vec3 offsetTvLeft = p - 0.001 * Tv;\\n vec3 offsetTvRight = p + 0.001 * Tv;\\n float heightVariationTuLeft = HeightVariation(offsetTuLeft);\\n float heightVariationTuRight = HeightVariation(offsetTuRight);\\n float heightVariationTvLeft = HeightVariation(offsetTvLeft);\\n float heightVariationTvRight = HeightVariation(offsetTvRight);\\n vec3 bumpHeight = WoodBumpHeight(heightVariationTuLeft, heightVariationTuRight, heightVariationTvLeft, heightVariationTvRight);\\n vec3 newNormal = normalize(bumpHeight.x * Tu + bumpHeight.y * Tv + bumpHeight.z * vtNormal);\\n vec3 newNormalView = normalize(vNormalMatrix * newNormal);\\n vec3 selectedNormal = SelectNormal(geoNormal, newNormalView, V);\\n ComputeTangents(selectedNormal, Tu, Tv);\\n Tu = normalize(Tu);\\n Tv = normalize(Tv);\\n N = faceforward(selectedNormal, -V, selectedNormal);\\n}\\n#endif\\n#endif\\n\";","module.exports = \"\\nuniform float shadowESMConstant;\\nuniform float shadowMapRangeMin;\\nuniform float shadowMapRangeSize;\\n\";","module.exports = \"\\n#ifdef USE_SHADOWMAP\\nuniform sampler2D shadowMap;\\nuniform vec2 shadowMapSize;\\nuniform float shadowDarkness;\\nuniform float shadowBias;\\nuniform vec3 shadowLightDir;\\nvarying vec4 vShadowCoord;\\n#include\\nfloat getShadowValue() {\\n float fDepth;\\n vec3 shadowColor = vec3( 1.0 );\\n vec3 shadowCoord = vShadowCoord.xyz / vShadowCoord.w;\\n shadowCoord.xyz = 0.5 * (shadowCoord.xyz + vec3(1.0, 1.0, 1.0));\\n bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\\n bool inFrustum = all( inFrustumVec );\\n float shadowValue = 1.0;\\n if (inFrustum) {\\n shadowCoord.z = min(0.999, shadowCoord.z);\\n shadowCoord.z -= shadowBias;\\n#ifdef USE_HARD_SHADOWS\\n vec4 rgbaDepth = texture2D( shadowMap, shadowCoord.xy );\\n float fDepth = rgbaDepth.r;\\n if ( fDepth < shadowCoord.z ) {\\n shadowValue = 1.0 - shadowDarkness;\\n }\\n#else\\n vec4 rgbaDepth = texture2D( shadowMap, shadowCoord.xy );\\n float shadowMapValue = rgbaDepth.r;\\n shadowValue = exp(-shadowESMConstant * shadowCoord.z) * shadowMapValue;\\n shadowValue = min(shadowValue, 1.0);\\n shadowValue = mix(1.0 - shadowDarkness, 1.0, shadowValue);\\n#endif\\n }\\n return shadowValue;\\n}\\n#else\\nfloat getShadowValue() { return 1.0; }\\n#endif\\nvec3 applyEnvShadow(vec3 colorWithoutShadow, vec3 worldNormal) {\\n#if defined(USE_SHADOWMAP)\\n float dp = dot(shadowLightDir, worldNormal);\\n float dpValue = (dp + 1.0) / 2.0;\\n dpValue = min(1.0, dpValue * 1.5);\\n float sv = getShadowValue();\\n vec3 result = colorWithoutShadow * min(sv, dpValue);\\n return result;\\n#else\\n return colorWithoutShadow;\\n#endif\\n}\\n\";","module.exports = \"\\n#ifdef USE_SHADOWMAP\\nvarying vec4 vShadowCoord;\\nuniform mat4 shadowMatrix;\\n#endif\\n\";","module.exports = \"\\n#ifdef USE_SHADOWMAP\\n{\\n vec4 worldPosition = modelMatrix * vec4( position, 1.0 );\\n vShadowCoord = shadowMatrix * worldPosition;\\n}\\n#endif\\n\";","module.exports = \"uniform vec4 themingColor;\\n\";","module.exports = \"gl_FragColor.rgb = mix(gl_FragColor.rgb, themingColor.rgb, themingColor.a);\\n\";","module.exports = \"\\nfloat luminance_post(vec3 rgb) {\\n return dot(rgb, vec3(0.299, 0.587, 0.114));\\n}\\nfloat luminance_pre(vec3 rgb) {\\n return dot(rgb, vec3(0.212671, 0.715160, 0.072169));\\n}\\nvec3 xyz2rgb(vec3 xyz) {\\n vec3 R = vec3( 3.240479, -1.537150, -0.498535);\\n vec3 G = vec3(-0.969256, 1.875992, 0.041556);\\n vec3 B = vec3( 0.055648, -0.204043, 1.057311);\\n vec3 rgb;\\n rgb.b = dot(xyz, B);\\n rgb.g = dot(xyz, G);\\n rgb.r = dot(xyz, R);\\n return rgb;\\n}\\nvec3 rgb2xyz(vec3 rgb) {\\n vec3 X = vec3(0.412453, 0.35758, 0.180423);\\n vec3 Y = vec3(0.212671, 0.71516, 0.0721688);\\n vec3 Z = vec3(0.0193338, 0.119194, 0.950227);\\n vec3 xyz;\\n xyz.x = dot(rgb, X);\\n xyz.y = dot(rgb, Y);\\n xyz.z = dot(rgb, Z);\\n return xyz;\\n}\\nvec3 xyz2xyY(vec3 xyz) {\\n float sum = xyz.x + xyz.y + xyz.z;\\n sum = 1.0 / sum;\\n vec3 xyY;\\n xyY.z = xyz.y;\\n xyY.x = xyz.x * sum;\\n xyY.y = xyz.y * sum;\\n return xyY;\\n}\\nvec3 xyY2xyz(vec3 xyY) {\\n float x = xyY.x;\\n float y = xyY.y;\\n float Y = xyY.z;\\n vec3 xyz;\\n xyz.y = Y;\\n xyz.x = x * (Y / y);\\n xyz.z = (1.0 - x - y) * (Y / y);\\n return xyz;\\n}\\nfloat toneMapCanon_T(float x)\\n{\\n float xpow = pow(x, 1.60525727);\\n float tmp = ((1.05542877*4.68037409)*xpow) / (4.68037409*xpow + 1.0);\\n return clamp(tmp, 0.0, 1.0);\\n}\\nconst float Shift = 1.0 / 0.18;\\nfloat toneMapCanonFilmic_NoGamma(float x) {\\n x *= Shift;\\n const float A = 0.2;\\n const float B = 0.34;\\n const float C = 0.002;\\n const float D = 1.68;\\n const float E = 0.0005;\\n const float F = 0.252;\\n const float scale = 1.0/0.833837;\\n return (((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F) * scale;\\n}\\nvec3 toneMapCanonFilmic_WithGamma(vec3 x) {\\n x *= Shift;\\n const float A = 0.27;\\n const float B = 0.29;\\n const float C = 0.052;\\n const float D = 0.2;\\n const float F = 0.18;\\n const float scale = 1.0/0.897105;\\n return (((x*(A*x+C*B))/(x*(A*x+B)+D*F))) * scale;\\n}\\nvec3 toneMapCanonOGS_WithGamma_WithColorPerserving(vec3 x) {\\n vec3 outColor = x.rgb;\\n outColor = min(outColor, vec3(3.0));\\n float inLum = luminance_pre(outColor);\\n if (inLum > 0.0) {\\n float outLum = toneMapCanon_T(inLum);\\n outColor = outColor * (outLum / inLum);\\n outColor = clamp(outColor, vec3(0.0), vec3(1.0));\\n }\\n float gamma = 1.0/2.2;\\n outColor = pow(outColor, vec3(gamma));\\n return outColor;\\n}\\n\";","module.exports = \"\\n#ifdef WIDE_LINES\\nattribute vec3 prev;\\nattribute vec3 next;\\nattribute float side;\\nuniform vec2 view_size;\\nvec2 to2d(vec4 i) {\\n return i.xy / i.w;\\n}\\n#endif\\n\";","module.exports = \"\\n#ifdef WIDE_LINES\\nvec4 mvpPosition = projectionMatrix * mvPosition; \\nmat3 vectorMatrix = mat3(modelViewMatrix);\\nvec2 _pos = to2d(mvpPosition) * view_size;\\nvec2 _prev = to2d(projectionMatrix * vec4(mvPosition.xyz + vectorMatrix * (prev * 0.01), 1.0)) * view_size;\\nvec2 _next = to2d(projectionMatrix * vec4(mvPosition.xyz - vectorMatrix * (next * 0.01), 1.0)) * view_size;\\nvec2 dir1 = _pos - _next;\\nvec2 dir2 = _prev - _pos;\\ndir2 = (length(dir2) > 0.0000001) ? normalize(dir2) : vec2(0.0, 0.0);\\ndir1 = (length(dir1) > 0.0000001) ? normalize(dir1) : dir2;\\nvec2 dir_sharp = normalize(dir1 + dir2);\\nvec2 dir = normalize(dir1 + dir_sharp);\\nvec2 offset = vec2(-dir.y, dir.x);\\nfloat len = 1.0 / cross(vec3(offset, 0), vec3(dir1, 0)).z;\\noffset *= len;\\noffset /= view_size;\\noffset *= side;\\noffset *= mvpPosition.w;\\nmvpPosition.xy += offset;\\ngl_Position = mvpPosition;\\n#endif\\n\";","module.exports = \"varying vec3 vColor;\\nvarying vec2 vUv;\\nuniform samplerCube envMap;\\nuniform vec3 uCamDir;\\nuniform vec3 uCamUp;\\nuniform vec2 uResolution;\\nuniform float uHalfFovTan;\\nuniform float opacity;\\nuniform bool envMapBackground;\\n#include\\nconst int bloomRange = 4;\\n#include\\nuniform float envMapExposure;\\n#if TONEMAP_OUTPUT > 0\\nuniform float exposureBias;\\n#include\\n#endif\\nvec3 rayDir(in vec2 vUv) {\\n vec3 A = (uResolution.x/uResolution.y)*normalize(cross(uCamDir,uCamUp)) * (uHalfFovTan * 2.0);\\n vec3 B = normalize(uCamUp) * (uHalfFovTan * 2.0);\\n vec3 C = normalize(uCamDir);\\n vec3 ray = normalize( C + (2.0*vUv.x-1.0)*A + (2.0*vUv.y-1.0)*B );\\n return ray;\\n}\\nvec3 getColor(in vec3 rd) {\\n return RGBMDecode(textureCube(envMap, adjustLookupVector(rd)), envMapExposure);\\n}\\nvoid main() {\\n vec3 rd = rayDir(vUv);\\n vec3 outColor;\\n if (envMapBackground) {\\n outColor = getColor(rd);\\n#if TONEMAP_OUTPUT == 1\\n outColor = toneMapCanonOGS_WithGamma_WithColorPerserving(exposureBias * outColor);\\n#elif TONEMAP_OUTPUT == 2\\n outColor = toneMapCanonFilmic_WithGamma(exposureBias * outColor);\\n#endif\\n }\\n else {\\n outColor = vColor;\\n }\\n gl_FragColor = vec4(orderedDithering(outColor), opacity);\\n}\\n\";","module.exports = \"uniform vec3 color1;\\nuniform vec3 color2;\\nvarying vec2 vUv;\\nvarying vec3 vColor;\\nvoid main() {\\n if (uv.y == 0.0)\\n vColor = color2;\\n else\\n vColor = color1;\\n vUv = uv;\\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\\n}\\n\";","module.exports = \"uniform vec3 diffuse;\\nuniform float opacity;\\n#include\\n#include\\n#include\\n#include\\n#include\\n#include\\n#include\\n#if NUM_CUTPLANES > 0\\nvarying highp vec3 vWorldPosition;\\n#endif\\n#if defined( PARTICLE_UV )\\nvarying highp vec4 vUVp;\\n#endif\\n#if defined ( PARTICLE_FLAGS )\\nvarying float vFlagp;\\n#endif\\n#include\\n#include\\n#include\\nvoid main() {\\n#if NUM_CUTPLANES > 0\\n checkCutPlanes(vWorldPosition);\\n#endif\\n vec3 outgoingLight = vec3( 0.0 );\\n vec4 diffuseColor = vec4( diffuse, opacity );\\n#if defined( USE_MAP ) && defined ( PARTICLE_FRAGMENT )\\n #if defined( PARTICLE_UV )\\n vec2 uv3 = mix( vUVp.xy, vUVp.zw, gl_PointCoord );\\n diffuseColor = texture2D( map, uv3);\\n #else\\n \\tdiffuseColor = texture2D( map, gl_PointCoord );\\n #endif\\n#else\\n #include\\n#endif\\n#include\\n#include\\n#include\\n#include\\n outgoingLight = diffuseColor.rgb;\\n#include\\n#include\\n#include\\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\\n vec3 geomNormal = vec3(0.0,0.0,0.0);\\n float depth = 0.0;\\n#include\\n#if defined (DEPTH_OCCLUSION)\\n gl_FragDepth = gl_FragCoord.z * float(DEPTH_OCCLUSION);\\n#endif\\n#if defined ( PARTICLE_FLAGS )\\n if( vFlagp == 0. ) {\\n discard;\\n } else {\\n gl_FragColor.rgba *= vec4(0.4, 0.6, 1., 1.);\\n }\\n#endif\\n#include\\n}\\n\";","module.exports = \"#include\\n#include\\n#include\\n#include\\n#include\\n#include\\n#include\\n#include\\n#include\\n#ifdef USE_INSTANCING\\n #include\\n#endif\\n#if defined( PARTICLE_UV )\\nattribute vec4 uvp;\\nvarying highp vec4 vUVp;\\n#endif\\n#if defined (PARTICLE_FLAGS)\\nattribute float flagp;\\nvarying float vFlagp;\\n#endif\\n#if NUM_CUTPLANES > 0\\nvarying vec3 vWorldPosition;\\n#endif\\nvoid main() {\\n#ifdef USE_INSTANCING\\n vec3 instancePosition = getInstancePos(position);\\n #define position instancePosition\\n#endif\\n#if defined(USE_ENVMAP) && (defined(UNPACK_NORMALS) || defined(USE_INSTANCE))\\n vec3 correctNormal;\\n #ifdef UNPACK_NORMALS\\n correctNormal = decodeNormal(normal);\\n #else\\n correctNormal = normal;\\n #endif\\n #ifdef USE_INSTANCING\\n correctNormal = getInstanceNormal(correctNormal);\\n #endif\\n #define normal correctNormal\\n#endif\\n#include\\n#include\\n#include\\n#ifdef USE_ENVMAP\\n#include\\n#endif\\n#include\\n#include\\n#include\\n#if NUM_CUTPLANES > 0\\n vec4 _worldPosition = modelMatrix * vec4( position, 1.0 );\\n vWorldPosition = _worldPosition.xyz;\\n#endif\\n#if defined( PARTICLE_UV )\\n vUVp = uvp;\\n#endif\\n#include\\n#include\\n#include\\n#if defined (PARTICLE_FLAGS) \\n vFlagp = flagp;\\n gl_PointSize *= mix(1., 4./3., flagp);\\n#endif\\n}\\n\";","module.exports = \"uniform sampler2D tDiffuse;\\nuniform sampler2D tAO;\\nuniform int useAO;\\nuniform float aoOpacity;\\nuniform sampler2D tOverlay;\\nuniform int useOverlay;\\nuniform int useOverlayAlpha;\\nuniform vec2 resolution;\\nuniform vec4 objIDv4;\\nuniform sampler2D tID;\\nuniform vec4 edgeObjIDv4;\\n#if defined(USE_MODEL_ID)\\n#if defined(HIGHLIGHT_MODEL_ID_COUNT)\\nuniform vec2 modelIDsv2v[HIGHLIGHT_MODEL_ID_COUNT];\\n#else\\nuniform vec2 modelIDv2;\\n#endif\\nuniform sampler2D tID2;\\nuniform vec2 edgeModelIDv2;\\n#endif\\nuniform float highlightIntensity;\\nuniform vec3 selectionColor;\\nuniform float highlightFullModel;\\nuniform vec3 highlightColor;\\n#ifdef IS_2D\\nuniform float expand2dSelection;\\n#endif\\nuniform sampler2D tCrossFadeTex0;\\nuniform sampler2D tCrossFadeTex1;\\nuniform float crossFadeOpacity0;\\nuniform float crossFadeOpacity1;\\nvarying vec2 vUv;\\n#ifdef SPATIAL_FILTER\\n#include\\n#endif\\n#include\\n#ifdef USE_IDBUFFER_SELECTION\\nbool isSelection(vec2 vUv, float I, float J) {\\n vec4 idAtPixel = texture2D(tID, vUv+resolution*vec2(I,J));\\n if (idAtPixel.rgb == vec3(0.0))\\n return false;\\n#if defined(USE_MODEL_ID)\\n vec4 modelAtPixel = texture2D(tID2, vUv+resolution*vec2(I,J));\\n idAtPixel.a = modelAtPixel.b;\\n vec4 idDelta = abs(idAtPixel.rgba - edgeObjIDv4.rgba);\\n vec2 modelDelta = abs(modelAtPixel.rg - edgeModelIDv2.rg);\\n#else\\n vec4 idDelta = vec4(abs(idAtPixel.rgb - edgeObjIDv4.rgb), 0.0);\\n vec2 modelDelta = vec2(0.0, 0.0);\\n#endif\\n if (max(max(modelDelta.r, modelDelta.g), max(max(idDelta.r, idDelta.g), max(idDelta.b, idDelta.a))) < 1e-3) {\\n return true;\\n } else {\\n return false;\\n }\\n}\\n#else\\nbool isSelected(vec3 C) {\\n float minS = min(selectionColor.r, min(selectionColor.g, selectionColor.b));\\n float maxS = max(selectionColor.r, max(selectionColor.g, selectionColor.b));\\n float satS = maxS - minS;\\n float minC = min(C.r, min(C.g, C.b));\\n float maxC = max(C.r, max(C.g, C.b));\\n float satC = maxC - minC;\\n if (satC < .01 || satS < .01)\\n return false;\\n vec3 S = (selectionColor - minS) / satS;\\n vec3 H = (C - minC) / satC;\\n vec3 D = H - S;\\n float eps = .15;\\n return (abs(D.r) + abs(D.g) + abs(D.b) < eps)\\n || (maxC >= (1.0 - eps) && D.r >= -eps && D.g >= -eps && D.b >= -eps);\\n}\\n#define IS_SELECTION(C) isSelected((C).rgb)\\n#endif\\nvec4 overlayEdgeDetect(vec2 vUv) {\\n#ifdef IS_2D\\n#define MAX_ALPHA(c)\\n#define SUM_ALPHA(c, w) sumAlpha += c.a * w; sumWeight += w;\\n#else\\n#define MAX_ALPHA(c) maxAlpha = max(maxAlpha, c.a);\\n#define SUM_ALPHA(c, w) \\n#endif\\n#ifdef USE_IDBUFFER_SELECTION\\n#define CHECK_EDGE_ALPHA(I, J, W) { vec4 c = texture2D( tOverlay, vUv+resolution*vec2((I),(J)) ); MAX_ALPHA(c) if (c.a > 0.0 && isSelection(vUv, I, J)) { hasEdge++; SUM_ALPHA(c, W) selectionPixel = c; } }\\n#else\\n#define CHECK_EDGE_ALPHA(I, J, W) { vec4 c = texture2D( tOverlay, vUv+resolution*vec2((I),(J)) ); MAX_ALPHA(c) if (c.a > 0.0 && IS_SELECTION(c)) { hasEdge++; SUM_ALPHA(c, W) selectionPixel = c; } }\\n#endif\\n#ifndef IS_2D\\n#define CHECK_EDGE_SELECTION(I, J) { vec4 c = texture2D( tOverlay, vUv+resolution*vec2((I),(J)) ); MAX_ALPHA(c) if (c.a <= 0.0) hasEdge++; }\\n#endif\\n int hasEdge = 0;\\n vec4 center = texture2D(tOverlay, vUv);\\n vec4 selectionPixel = vec4(0.0);\\n#ifdef IS_2D\\n float sumAlpha = 0.0, sumWeight = 0.0;\\n#else\\n float maxAlpha = 0.0;\\n bool paintOutline = false;\\n#endif\\n if (center.a <= 0.0) {\\n CHECK_EDGE_ALPHA(-1.0,-1.0, 1.0);\\n CHECK_EDGE_ALPHA( 0.0,-1.0, 2.0);\\n CHECK_EDGE_ALPHA( 1.0,-1.0, 1.0);\\n CHECK_EDGE_ALPHA(-1.0, 0.0, 2.0);\\n CHECK_EDGE_ALPHA( 1.0, 0.0, 2.0);\\n CHECK_EDGE_ALPHA(-1.0, 1.0, 1.0);\\n CHECK_EDGE_ALPHA( 0.0, 1.0, 2.0);\\n CHECK_EDGE_ALPHA( 1.0, 1.0, 1.0);\\n if (hasEdge != 0) {\\n#ifdef IS_2D\\n center.a = -clamp(expand2dSelection - 1.0 + sumAlpha / sumWeight, 0.0, 1.0);\\n center.rgb = center.a < 0.0 ? selectionPixel.rgb : center.rgb;\\n#else\\n center = selectionPixel;\\n paintOutline = true;\\n#endif\\n }\\n }\\n#ifdef USE_IDBUFFER_SELECTION\\n else if (center.a > 0.0 && isSelection(vUv, 0.0, 0.0)) {\\n#else\\n else if (center.a > 0.0 && IS_SELECTION(center)) {\\n#endif\\n#ifdef IS_2D\\n center.a = -clamp(center.a + expand2dSelection, 0.0, 1.0);\\n#else\\n CHECK_EDGE_SELECTION(-1.0,-1.0);\\n CHECK_EDGE_SELECTION( 0.0,-1.0);\\n CHECK_EDGE_SELECTION( 1.0,-1.0);\\n CHECK_EDGE_SELECTION(-1.0, 0.0);\\n CHECK_EDGE_SELECTION( 1.0, 0.0);\\n CHECK_EDGE_SELECTION(-1.0, 1.0);\\n CHECK_EDGE_SELECTION( 0.0, 1.0);\\n CHECK_EDGE_SELECTION( 1.0, 1.0);\\n if (hasEdge != 0)\\n paintOutline = true;\\n else\\n center.a = -center.a;\\n#endif\\n }\\n#ifndef IS_2D\\n if (paintOutline) {\\n float maxComponent = max(center.r, max(center.g, center.b));\\n center.rgb /= maxComponent;\\n center.rgb = sqrt(center.rgb);\\n center.a = 0.5 + 0.5 * maxAlpha * 0.125 * float(hasEdge);\\n }\\n#endif\\n return center;\\n}\\n#ifdef SPATIAL_FILTER\\nSPATIAL_FILTER\\n#endif\\nvec4 sampleColor() {\\n return texture2D( tDiffuse, vUv );\\n}\\nfloat sampleAO() {\\n return (useAO != 0) ? sqrt(texture2D(tAO, vUv).r) : 1.0;\\n}\\nvec3 applyCrossFade(vec3 srcColor, sampler2D fadeTex, float opacity, vec2 vUv) {\\n vec4 blendCol = texture2D(fadeTex, vUv);\\n return mix(srcColor.rgb, blendCol.rgb, blendCol.a * opacity);\\n}\\nvoid applyHighlighting(inout vec3 rgb, float filterValue) {\\n#ifdef IS_2D\\n rgb = mix(rgb, vec3(1.0,1.0,0.0), filterValue * highlightIntensity * 0.25);\\n#else\\n rgb += highlightColor * filterValue * highlightIntensity * 0.20;\\n#endif\\n}\\n#ifdef USE_MODEL_ID\\nfloat getModelIdDelta(vec2 a, vec2 b) {\\n vec2 delta = abs(a-b);\\n return max(delta.r, delta.g);\\n}\\nfloat getModelIdDelta(vec2 modelAtPixel) {\\n \\n#ifdef HIGHLIGHT_MODEL_ID_COUNT\\n float delta = 1.0;\\n for (int i=0; i 1)\\n #if (TARGET_FADE_MODE == 0)\\n texel.rgb = applyCrossFade(texel.rgb, tCrossFadeTex0, crossFadeOpacity0, vUv);\\n texel.rgb = applyCrossFade(texel.rgb, tCrossFadeTex1, crossFadeOpacity1, vUv);\\n #else\\n vec4 t0 = texture2D(tCrossFadeTex0, vUv);\\n vec4 t1 = texture2D(tCrossFadeTex1, vUv);\\n vec4 mixed = mix(t0, t1, crossFadeOpacity1);\\n texel.rgb = mix(texel.rgb, mixed.rgb, mixed.a);\\n float aoGamma = 1.0 + 3.0 * (1.0 - 2.0 * abs(crossFadeOpacity1 - 0.5));\\n if (aoGamma == 0.0)\\n aoGamma = 1.0;\\n ao = pow(ao, 1.0 / aoGamma);\\n #endif\\n #else\\n vec4 mixed = texture2D(tCrossFadeTex0, vUv);\\n texel.rgb = mix(texel.rgb, mixed.rgb, mixed.a);\\n #endif\\n #else\\n #endif\\n ao = 1.0 - (1.0 - ao) * aoOpacity;\\n texel.rgb *= ao;\\n if (useOverlay != 0) {\\n vec4 overlay = overlayEdgeDetect(vUv);\\n if (overlay.a < 0.0) {\\n overlay.a = -overlay.a;\\n#ifdef IS_2D\\n overlay.a *= 0.6;\\n#else\\n if (overlay.a >= 0.99) {\\n overlay.a = 0.75;\\n texel.rgb = vec3(luminance_post(texel.rgb));\\n }\\n#endif\\n }\\n#ifdef IS_2D\\n texel.rgb = texel.rgb * (1.0 - overlay.a) + overlay.rgb;\\n#else\\n texel.rgb = texel.rgb * (1.0 - overlay.a) + sqrt(overlay.rgb * overlay.a);\\n#endif\\n if (useOverlayAlpha != 0) {\\n texel.a += overlay.a * (1.0 - texel.a);\\n }\\n }\\n if (objIDv4 != vec4(0.0)) {\\n vec4 idAtPixel = texture2D(tID, vUv);\\n #ifdef SPATIAL_FILTER\\n vec3 worldPos = reconstructWorldPosition(gl_FragCoord.xy, vUv);\\n float filterValue = (spatialFilter(worldPos) ? 1.0 : 0.0);\\n if (idAtPixel != vec4(1,1,1,1)) {\\n applyHighlighting(texel.rgb, filterValue);\\n }\\n #else\\n #if defined(USE_MODEL_ID)\\n vec4 modelAtPixel = texture2D(tID2, vUv);\\n idAtPixel.a = modelAtPixel.b;\\n vec4 idDelta = abs(idAtPixel.rgba - objIDv4.rgba) * (1.0 - highlightFullModel);\\n float modelDelta = getModelIdDelta(modelAtPixel.rg);\\n #else\\n vec4 idDelta = vec4(abs(idAtPixel.rgb - objIDv4.rgb), 0.0);\\n float modelDelta = 0.0;\\n #endif\\n if (max(modelDelta, max(max(idDelta.r, idDelta.g), max(idDelta.b, idDelta.a))) < 1e-3) {\\n applyHighlighting(texel.rgb, 1.0);\\n }\\n #endif\\n }\\n gl_FragColor = texel;\\n}\\n\";","module.exports = \"\\n#include\\nuniform sampler2D tDiffuse;\\nuniform sampler2D tID;\\nuniform vec2 resolution;\\nuniform float cameraNear;\\nuniform float cameraFar;\\nuniform sampler2D tFill;\\nuniform sampler2D tPaper;\\nuniform int style;\\nuniform int idEdges;\\nuniform int normalEdges;\\nuniform int depthEdges;\\nuniform float brightness;\\nuniform float contrast;\\nuniform int grayscale;\\nuniform int preserveColor;\\nuniform int outlineNoise;\\nuniform float levels;\\nuniform float repeats;\\nuniform float rotation;\\nuniform float outlineRadius;\\nuniform sampler2D tGraphite1;\\nuniform sampler2D tGraphite2;\\nuniform sampler2D tGraphite3;\\nuniform sampler2D tGraphite4;\\nuniform sampler2D tGraphite5;\\nuniform sampler2D tGraphite6;\\nuniform sampler2D tGraphite7;\\nuniform sampler2D tGraphite8;\\nvarying vec2 vUv;\\nvec4 recoverNZ(vec4 nrmz) {\\n float z = sqrt(1.0 - dot(nrmz.xy, nrmz.xy));\\n nrmz.w = -(nrmz.z + cameraNear) / (cameraFar - cameraNear);\\n nrmz.z = z;\\n return nrmz;\\n}\\n#include\\n#include\\nvec3 quantize(vec3 c) {\\n float L = max(c.r, max(c.g, c.b));\\n c *= floor(L * (levels-1.0) + 0.5) / (L * (levels-1.0));\\n return c;\\n}\\nvec3 quantizeRGB(vec3 c) {\\n c *= c;\\n c *= floor(c * levels * 0.9999) / (levels-1.0);\\n return sqrt(c);\\n}\\nvec3 clampHue(vec3 c, float hues, float sats, float vals) {\\n vec3 hsv = rgb2hsv(c);\\n hsv.x = floor(hsv.x * hues + 0.5) / hues;\\n hsv.y = floor(hsv.y * sats + 0.5) / sats;\\n hsv.z = floor(hsv.z * vals + 0.5) / vals;\\n vec3 col = hsv2rgb(hsv);\\n return col;\\n}\\nvec3 reconstructCSFaceNormal(vec3 C) {\\n return normalize(cross(dFdy(C), dFdx(C)));\\n}\\nvec3 getPosition(ivec2 ssP, float depth) {\\n vec3 P;\\n P = reconstructCSPosition(vec2(ssP) + vec2(0.5), depth);\\n return P;\\n}\\nint isObjectEdge() {\\n vec2 uv = vUv;\\n if (outlineNoise == 1) {\\n vec4 noise = texture2D(tGraphite7, vUv);\\n uv = vUv + 0.02 * (noise.xy - vec2(0.25));\\n }\\n vec4 MM = texture2D(tID, uv);\\n vec4 LL = texture2D(tID, uv + vec2(-outlineRadius, -outlineRadius) * resolution);\\n if (MM != LL) return 1;\\n vec4 LM = texture2D(tID, uv + vec2( 0.0, -outlineRadius) * resolution);\\n if (MM != LM) return 1;\\n vec4 LR = texture2D(tID, uv + vec2( outlineRadius, -outlineRadius) * resolution);\\n if (MM != LR) return 1;\\n vec4 ML = texture2D(tID, uv + vec2(-outlineRadius, 0.0) * resolution);\\n if (MM != ML) return 1;\\n vec4 MR = texture2D(tID, uv + vec2( outlineRadius, 0.0) * resolution);\\n if (MM != MR) return 1;\\n vec4 UL = texture2D(tID, uv + vec2(-outlineRadius, outlineRadius) * resolution);\\n if (MM != UL) return 1;\\n vec4 UM = texture2D(tID, uv + vec2( 0.0, outlineRadius) * resolution);\\n if (MM != UM) return 1;\\n vec4 UR = texture2D(tID, uv + vec2( outlineRadius, outlineRadius) * resolution);\\n if (MM != UR) return 1;\\n return (MM.x + MM.y + MM.z + MM.w) >= 4.0 ? 0 : -1;\\n}\\nfloat normalDiff(vec3 n1, vec3 n2) {\\n float d = dot(n1.xyz, n2.xyz);\\n return acos(clamp(d, -1.0, 1.0));\\n}\\nint isNormalDepthEdge() {\\n ivec2 ssC = ivec2(gl_FragCoord.xy);\\n vec2 uv = vUv;\\n if (outlineNoise == 1) {\\n vec4 noise = texture2D(tGraphite7, vUv);\\n uv = vUv + 0.02 * (noise.xy - vec2(0.25));\\n }\\n vec4 MM = texture2D(tDepth, uv);\\n vec4 LL = texture2D(tDepth, uv + vec2(-outlineRadius, -outlineRadius) * resolution);\\n vec4 LM = texture2D(tDepth, uv + vec2( 0.0, -outlineRadius) * resolution);\\n vec4 LR = texture2D(tDepth, uv + vec2( outlineRadius, -outlineRadius) * resolution);\\n \\n vec4 ML = texture2D(tDepth, uv + vec2(-outlineRadius, 0.0) * resolution);\\n vec4 MR = texture2D(tDepth, uv + vec2( outlineRadius, 0.0) * resolution);\\n vec4 UL = texture2D(tDepth, uv + vec2(-outlineRadius, outlineRadius) * resolution);\\n vec4 UM = texture2D(tDepth, uv + vec2( 0.0, outlineRadius) * resolution);\\n vec4 UR = texture2D(tDepth, uv + vec2( outlineRadius, outlineRadius) * resolution);\\n LL = recoverNZ(LL);\\n LM = recoverNZ(LM);\\n LR = recoverNZ(LR);\\n ML = recoverNZ(ML);\\n MM = recoverNZ(MM);\\n MR = recoverNZ(MR);\\n UL = recoverNZ(UL);\\n UM = recoverNZ(UM);\\n UR = recoverNZ(UR);\\n float dd = 0.0;\\n if ( depthEdges == 1 ) {\\n float G = (abs(UL.w - MM.w) + 2.0 * abs(UM.w - MM.w) + abs(UR.w - MM.w) + 2.0 * abs(ML.w - MM.w) + 2.0 * abs(MR.w - MM.w) + abs(LL.w - MM.w) + 2.0 * abs(LM.w - MM.w) + abs(LR.w - MM.w));\\n dd = abs(dFdx(G)) + abs(dFdy(G));\\n }\\n float Gn = 0.0;\\n if ( normalEdges == 1 ) {\\n float pLL = normalDiff(LL.xyz, MM.xyz);\\n float pLM = normalDiff(LM.xyz, MM.xyz);\\n float pLR = normalDiff(LR.xyz, MM.xyz);\\n float pML = normalDiff(ML.xyz, MM.xyz);\\n float pMM = normalDiff(MM.xyz, MM.xyz);\\n float pMR = normalDiff(MR.xyz, MM.xyz);\\n float pUL = normalDiff(UL.xyz, MM.xyz);\\n float pUM = normalDiff(UM.xyz, MM.xyz);\\n float pUR = normalDiff(UR.xyz, MM.xyz);\\n Gn = (abs(pUL - pMM) + 2.0 * abs(pUM - pMM) + abs(pUR - pMM) + 2.0 * abs(pML - pMM) + 2.0 * abs(pMR - pMM) + abs(pLL - pMM) + 2.0 * abs(pLM - pMM) + abs(pLR - pMM));\\n }\\n \\n return (dd > 0.004 || Gn > 2.0) ? 1 : 0;\\n}\\nvec3 computeGraphite( vec3 color, vec2 loc ) {\\n float lum = 0.299 * color.r + 0.587 * color.g + 0.114 * color.b;\\n float offset;\\n vec3 col1, col2;\\n if ( lum > 6.0/7.0 ) {\\n col1 = texture2D(tGraphite1, loc ).xyz;\\n col2 = texture2D(tGraphite2, loc ).xyz;\\n offset = 6.0/7.0;\\n } else if ( lum > 5.0/7.0 ) {\\n col1 = texture2D(tGraphite2, loc ).xyz;\\n col2 = texture2D(tGraphite3, loc ).xyz;\\n offset = 5.0/7.0;\\n } else if ( lum > 4.0/7.0 ) {\\n col1 = texture2D(tGraphite3, loc ).xyz;\\n col2 = texture2D(tGraphite4, loc ).xyz;\\n offset = 4.0/7.0;\\n } else if ( lum > 3.0/7.0 ) {\\n col1 = texture2D(tGraphite4, loc ).xyz;\\n col2 = texture2D(tGraphite5, loc ).xyz;\\n offset = 3.0/7.0;\\n } else if ( lum > 2.0/7.0 ) {\\n col1 = texture2D(tGraphite5, loc ).xyz;\\n col2 = texture2D(tGraphite6, loc ).xyz;\\n offset = 2.0/7.0;\\n } else if ( lum > 1.0/7.0 ) {\\n col1 = texture2D(tGraphite6, loc ).xyz;\\n col2 = texture2D(tGraphite7, loc ).xyz;\\n offset = 1.0/7.0;\\n } else {\\n col1 = texture2D(tGraphite7, loc ).xyz;\\n col2 = texture2D(tGraphite8, loc ).xyz;\\n offset = 0.0;\\n }\\n if ( col1.r == 0.0 && col2.r == 0.0 ) {\\n return vec3(lum,lum,lum);\\n }\\n float t = (lum-offset)*7.0;\\n return (col1 * t + col2 * (1.0 - t));\\n}\\nvec3 colorWithAdjustments() {\\n vec3 sceneRGB = texture2D(tDiffuse, vUv).xyz;\\n if ( brightness != 0.0 || contrast != 0.0) {\\n if ( brightness < 0.0 )\\n {\\n sceneRGB = sceneRGB * (1.0 + brightness);\\n }\\n else\\n {\\n sceneRGB = sceneRGB + ((1.0 - sceneRGB) * brightness);\\n }\\n float slant = tan(( clamp(contrast,-1.0,1.0) + 1.0) * 3.141592/4.001);\\n sceneRGB = (sceneRGB - 0.5) * slant + 0.5;\\n if ( preserveColor == 1 )\\n {\\n float maxval = max( sceneRGB.r, sceneRGB.g );\\n maxval = max( maxval, sceneRGB.b );\\n if ( maxval > 1.0 )\\n {\\n sceneRGB /= maxval;\\n }\\n }\\n sceneRGB = clamp(sceneRGB,0.0,1.0);\\n }\\n if ( grayscale == 1 ) {\\n sceneRGB.rgb = vec3(luminance_post(sceneRGB.rgb));\\n }\\n return sceneRGB;\\n}\\nvoid main() {\\n int foundEdge = 0;\\n foundEdge = ( idEdges == 1 && isObjectEdge() == 1 ) ? 1 : 0;\\n if ( foundEdge == 0 && (normalEdges == 1 || depthEdges == 1) ) {\\n foundEdge = isNormalDepthEdge();\\n }\\n vec2 loc = vec2((vUv.x-0.5)*(resolution.y/resolution.x),vUv.y-0.5)*repeats;\\n if ( style > 2 && rotation != 0.0 ) {\\n float rot = 3.14159*rotation;\\n float sinr = sin(rot);\\n float cosr = cos(rot);\\n loc = vec2(loc.x*cosr + -loc.y*sinr, loc.x*sinr + loc.y*cosr);\\n }\\n loc += vec2(0.5,0.5);\\n vec3 color;\\n if ( style == 2 ) {\\n if ( foundEdge == 1 ) {\\n gl_FragColor = vec4(0.0,0.0,0.0,1.0);\\n } else {\\n gl_FragColor = vec4(quantize(colorWithAdjustments()),1.0);\\n }\\n } else if ( style == 3 ) {\\n color = colorWithAdjustments();\\n vec3 graphColor = computeGraphite( color, loc );\\n if ( foundEdge == 1 ) {\\n gl_FragColor = vec4(0.16,0.16,0.16,1.0) + vec4(0.18 * graphColor,0.0);\\n } else {\\n gl_FragColor = vec4(graphColor,1.0);\\n }\\n return;\\n } else if ( style == 4 ) {\\n float fill = texture2D(tFill, loc ).r;\\n float paperStrength = 0.3;\\n vec3 paper = texture2D(tPaper, loc ).rgb;\\n paper = paperStrength * paper + (1.0-paperStrength)*vec3(1.0,1.0,1.0);\\n if ( foundEdge == 1 ) {\\n gl_FragColor = 0.75 * vec4(paper * fill, 1.0);\\n } else {\\n fill = pow(fill,1.6);\\n gl_FragColor = vec4(colorWithAdjustments() * (1.0 - fill) + paper * fill, 1.0);\\n }\\n } else {\\n if ( foundEdge == 1 ) {\\n gl_FragColor = vec4(0.0,0.0,0.0,1.0);\\n } else {\\n gl_FragColor = vec4(colorWithAdjustments(),1.0);\\n }\\n return; \\n }\\n}\\n\";","module.exports = \"uniform sampler2D tDiffuse;\\nvarying vec2 vUv;\\nvoid main() {\\n gl_FragColor = texture2D(tDiffuse, vUv);\\n}\\n\";","module.exports = \"\\n#if NUM_CUTPLANES > 0\\nvarying vec3 vWorldPosition;\\n#endif\\n#include\\nuniform vec4 color;\\n#include\\nvoid main() {\\n#if NUM_CUTPLANES > 0\\n checkCutPlanes(vWorldPosition);\\n#endif\\n gl_FragColor = color;\\n#ifdef MRT_NORMALS\\noutNormal = vec4(0.0);\\n#endif\\n#ifdef MRT_ID_BUFFER\\n outId = vec4(0.0);\\n #ifdef MODEL_COLOR\\n outModelId = vec4(0.0);\\n #endif\\n#elif defined(ID_COLOR)\\n gl_FragColor = vec4(0.0);\\n#elif defined(MODEL_COLOR)\\n gl_FragColor = vec4(0.0);\\n#endif\\n}\";","module.exports = \"\\n#if NUM_CUTPLANES > 0\\nvarying vec3 vWorldPosition;\\n#endif\\n#include\\nvoid main() {\\n vec3 instPos = getInstancePos(position);\\n#if NUM_CUTPLANES > 0\\n vec4 worldPosition = modelMatrix * vec4( instPos, 1.0 );\\n vWorldPosition = worldPosition.xyz;\\n#endif\\n vec4 mvPosition = modelViewMatrix * vec4( instPos, 1.0 );\\n vec4 p_Position = projectionMatrix * mvPosition;\\n gl_Position = p_Position;\\n}\";","module.exports = \"#define FXAA_EDGE_SHARPNESS (8.0)\\n#define FXAA_EDGE_THRESHOLD (0.125)\\n#define FXAA_EDGE_THRESHOLD_MIN (0.05)\\n#define FXAA_RCP_FRAME_OPT (0.50)\\n#define FXAA_RCP_FRAME_OPT2 (2.0)\\nuniform sampler2D tDiffuse;\\nuniform highp vec2 uResolution;\\nvarying vec2 vPos;\\nvarying vec4 vPosPos;\\nfloat FxaaLuma(vec3 rgb) {\\n return dot(rgb, vec3(0.299, 0.587, 0.114));\\n}\\nvoid main() {\\n float lumaNw = FxaaLuma(texture2D(tDiffuse, vPosPos.xy).rgb);\\n float lumaSw = FxaaLuma(texture2D(tDiffuse, vPosPos.xw).rgb);\\n float lumaNe = FxaaLuma(texture2D(tDiffuse, vPosPos.zy).rgb) + 1.0/384.0;\\n float lumaSe = FxaaLuma(texture2D(tDiffuse, vPosPos.zw).rgb);\\n vec4 rgbaM = texture2D(tDiffuse, vPos.xy); \\n float lumaM = FxaaLuma(rgbaM.rgb);\\n float lumaMax = max(max(lumaNe, lumaSe), max(lumaNw, lumaSw));\\n float lumaMin = min(min(lumaNe, lumaSe), min(lumaNw, lumaSw));\\n float lumaMaxSubMinM = max(lumaMax, lumaM) - min(lumaMin, lumaM);\\n float lumaMaxScaledClamped = max(FXAA_EDGE_THRESHOLD_MIN, lumaMax * FXAA_EDGE_THRESHOLD);\\n if (lumaMaxSubMinM < lumaMaxScaledClamped) {\\n gl_FragColor = rgbaM;\\n return;\\n }\\n float dirSwMinusNe = lumaSw - lumaNe;\\n float dirSeMinusNw = lumaSe - lumaNw;\\n vec2 dir1 = normalize(vec2(dirSwMinusNe + dirSeMinusNw, dirSwMinusNe - dirSeMinusNw));\\n vec3 rgbN1 = texture2D(tDiffuse, vPos.xy - dir1 * FXAA_RCP_FRAME_OPT*uResolution).rgb;\\n vec3 rgbP1 = texture2D(tDiffuse, vPos.xy + dir1 * FXAA_RCP_FRAME_OPT*uResolution).rgb;\\n float dirAbsMinTimesC = min(abs(dir1.x), abs(dir1.y)) * FXAA_EDGE_SHARPNESS;\\n vec2 dir2 = clamp(dir1.xy / dirAbsMinTimesC, -2.0, 2.0);\\n vec3 rgbN2 = texture2D(tDiffuse, vPos.xy - dir2 * FXAA_RCP_FRAME_OPT2*uResolution).rgb;\\n vec3 rgbP2 = texture2D(tDiffuse, vPos.xy + dir2 * FXAA_RCP_FRAME_OPT2*uResolution).rgb;\\n vec3 rgbA = rgbN1 + rgbP1;\\n vec3 rgbB = ((rgbN2 + rgbP2) * 0.25) + (rgbA * 0.25);\\n float lumaB = FxaaLuma(rgbB);\\n float alpha = rgbaM.a;\\n if ((lumaB < lumaMin) || (lumaB > lumaMax))\\n gl_FragColor = vec4(rgbA * 0.5, rgbaM.a);\\n else\\n gl_FragColor = vec4(rgbB, rgbaM.a);\\n}\\n\";","module.exports = \"uniform vec2 uResolution;\\nvarying vec2 vPos;\\nvarying vec4 vPosPos;\\nvoid main() {\\n vPos = uv;\\n vPosPos.xy = uv + vec2(-0.5, -0.5) * uResolution;\\n vPosPos.zw = uv + vec2( 0.5, 0.5) * uResolution;\\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\\n}\\n\";","module.exports = \"uniform sampler2D tDiffuse;\\nuniform vec4 uColor;\\nvarying vec2 vUv;\\n#ifdef HORIZONTAL\\n#define GET_UV(X) vec2(vUv.x + KERNEL_SCALE_H*(X), vUv.y)\\n#else\\n#define GET_UV(Y) vec2(vUv.x, vUv.y + KERNEL_SCALE_V*(Y))\\n#endif\\n#define PI 3.14159265358979\\n#define SIGMA ((KERNEL_RADIUS+KERNEL_RADIUS+1.0) / 6.0)\\n#define SIGMASQ2 (2.0 * SIGMA * SIGMA)\\n#define GAUSSIAN(X) ( (1.0 / sqrt(PI * SIGMASQ2)) * exp(-(X)*(X)/SIGMASQ2) )\\nvoid main() {\\n vec4 texColSum = vec4(0.0);\\n float gaussSum = 0.0;\\n for (float x=-KERNEL_RADIUS; x<=KERNEL_RADIUS; x+=1.0) {\\n float gauss = GAUSSIAN(x);\\n vec4 texCol = texture2D(tDiffuse, GET_UV(x));\\n#ifdef HAS_ALPHA\\n texCol.rgb *= texCol.a;\\n#endif\\n texColSum += texCol * gauss;\\n gaussSum += gauss;\\n }\\n#ifdef HAS_ALPHA\\n texColSum.rgb /= (texColSum.a == 0.0 ? 0.0001 : texColSum.a);\\n#endif\\n#ifdef HORIZONTAL\\n gl_FragColor = texColSum/gaussSum;\\n#else\\n gl_FragColor = texColSum/gaussSum * uColor;\\n#endif\\n}\\n\";","module.exports = \"varying vec2 vUv;\\nvoid main() {\\n#if defined(HORIZONTAL) && defined(FLIP_UV)\\n vUv = vec2(uv.x, 1.0-uv.y);\\n#else\\n vUv = vec2(uv.x, uv.y);\\n#endif\\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\\n}\\n\";","module.exports = \"uniform sampler2D tDiffuse;\\nvarying vec2 vUv;\\nvoid main() {\\n vec4 texel = texture2D( tDiffuse, vUv );\\n gl_FragColor = texel;\\n}\\n\";","module.exports = \"#define NUM_SAMPLES 29.0\\n#define NUM_SPIRAL_TURNS 7.0\\nuniform sampler2D tDepth;\\nuniform vec3 worldSize;\\nvarying vec2 vUv;\\n#ifdef PRESET_2\\n#define SAMPLE_RADIUS 0.3\\n#define AO_GAMMA 1.0\\n#define AO_INTENSITY 1.0\\n#else\\n#define SAMPLE_RADIUS 0.2\\n#define AO_GAMMA 3.0\\n#define AO_INTENSITY 0.8\\n#endif\\n#include\\n#define PI 3.14159265358979\\nfloat rand(vec2 co) {\\n return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);\\n}\\nfloat getRandomAngle(vec2 pos) {\\n return rand(pos) * (2.0 * PI);\\n}\\nvec2 tapLocation(float sampleNumber, float spinAngle, out float ssR){\\n float alpha = float(sampleNumber + 0.5) * (1.0 / NUM_SAMPLES);\\n float angle = alpha * (NUM_SPIRAL_TURNS * PI * 2.0) + spinAngle;\\n ssR = alpha;\\n return vec2(cos(angle), sin(angle));\\n}\\nvec2 sampleAO(vec2 unitDirection, float radius) {\\n vec2 sampleOffset = unitDirection * radius;\\n float idepth = unpackDepth(texture2D(tDepth, vUv + sampleOffset));\\n float depth = 1.0 - idepth;\\n if (depth < 1e-6) {\\n if (radius == 0.0)\\n return vec2(1.0, 1.0);\\n else\\n return vec2(0.0, 1.0);\\n }\\n vec3 dir = vec3(sampleOffset.x, depth, sampleOffset.y) * worldSize;\\n float distance2 = dot(dir,dir);\\n float idistance = 1.0 / sqrt(distance2);\\n vec3 ndir = dir * idistance;\\n#ifdef PRESET_2\\n float importance = ndir.y * idistance;\\n#else\\n float importance = ndir.y / distance2;\\n#endif\\n vec2 ret;\\n ret.x = (idepth == 0.0) ? 0.0 : importance;\\n ret.y = importance;\\n return ret;\\n}\\nvoid main() {\\n vec2 sum = vec2(0.0);\\n float angle = getRandomAngle(vUv);\\n for (float i = 0.0; i\\n#define PI 3.14159265358979\\n#define SIGMA ((2.0 * KERNEL_RADIUS+1.0) / 6.0)\\n#define SIGMASQ2 (2.0 * SIGMA * SIGMA)\\n#ifdef BOX\\n#define KERNEL_VAL(X) 1.0\\n#else\\n#define KERNEL_VAL(X) ( (1.0 / sqrt(PI * SIGMASQ2)) * exp(-(X)*(X)/SIGMASQ2) )\\n#endif\\nvoid main() {\\n float depthVal = 0.0;\\n float sum = 0.0;\\n for (float x=-KERNEL_RADIUS; x<=KERNEL_RADIUS; x+=1.0) {\\n depthVal += unpackDepth(texture2D(tDepth, GET_UV(x))) * KERNEL_VAL(x);\\n sum += KERNEL_VAL(x);\\n }\\n gl_FragColor = packDepth(depthVal/sum);\\n}\\n\";","module.exports = \"uniform sampler2D tDepth;\\nuniform vec4 uShadowColor;\\nvarying vec2 vUv;\\n#include\\nvoid main() {\\n float depthVal = unpackDepth(texture2D(tDepth, vUv));\\n gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * depthVal);\\n}\\n\";","module.exports = \"#include\\n#if NUM_CUTPLANES > 0\\nvarying vec3 vWorldPosition;\\n#endif\\n#include\\nvoid main() {\\n#if NUM_CUTPLANES > 0\\n checkCutPlanes(vWorldPosition);\\n#endif\\n float depth = gl_FragCoord.z / gl_FragCoord.w;\\n depth = 1.0 - depth;\\n gl_FragColor = packDepth(depth);\\n}\\n\";","module.exports = \"#if NUM_CUTPLANES > 0\\nvarying vec3 vWorldPosition;\\n#endif\\nvoid main() {\\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );;\\n#if NUM_CUTPLANES > 0\\n vec4 worldPosition = modelMatrix * vec4( position, 1.0 );\\n vWorldPosition = worldPosition.xyz;\\n#endif\\n}\\n\";","module.exports = \"\\r\\n\\r\\n\\r\\n#include\\r\\n#include\\r\\n\\r\\nuniform highp float pixelsPerUnit;\\r\\nuniform highp float aaRange;\\r\\n\\r\\nuniform float opacity;\\r\\nuniform highp float viewportId;\\r\\nuniform highp float swap;\\r\\nuniform highp float grayscale;\\r\\n\\r\\n#ifdef HAS_RASTER_QUADS\\r\\nuniform sampler2D tRaster;\\r\\n#endif\\r\\n\\r\\n#ifdef HAS_LINESTYLES\\r\\nuniform sampler2D tLineStyle;\\r\\nuniform vec2 vLineStyleTexSize;\\r\\n#endif\\r\\n\\r\\n#ifdef VIEWPORT_CLIPPING\\r\\nuniform highp vec4 viewportBounds;\\r\\nvarying highp vec2 vPosition;\\r\\n#endif\\r\\n\\r\\n#ifdef IMAGE_UV_TEXTURE\\r\\nvarying highp vec2 vuv;\\r\\nuniform sampler2D tRaster;\\r\\n#endif\\r\\n\\r\\n\\r\\nfloat curveGaussian(float r, float invWidth) {\\r\\n float amt = clamp(r * invWidth, 0.0, 1.0);\\r\\n\\r\\n float exponent = amt * 2.0;\\r\\n\\r\\n return exp(-exponent*exponent);\\r\\n\\r\\n\\r\\n\\r\\n}\\r\\n\\r\\n#ifdef HAS_LINESTYLES\\r\\nfloat getLinePatternPixel(int i, int j) {\\r\\n\\r\\n return texture2D(tLineStyle, (vec2(i, j) + 0.5) / vLineStyleTexSize).x * 255.0;\\r\\n}\\r\\n\\r\\nfloat getPatternLength(int whichPattern) {\\r\\n float p1 = getLinePatternPixel(0, whichPattern);\\r\\n float p2 = getLinePatternPixel(1, whichPattern);\\r\\n return (p2 * 256.0 + p1);\\r\\n}\\r\\n#endif\\r\\n\\r\\n\\r\\nvoid fillLineSegment() {\\r\\n\\r\\n float radius = abs(fsHalfWidth);\\r\\n float parametricDistance = fsMultipurpose.x;\\r\\n float segmentLength = fsMultipurpose.y;\\r\\n float totalDistance = fsMultipurpose.z;\\r\\n\\r\\n#ifdef LOADING_ANIMATION\\r\\n float distFromStart = parametricDistance / segmentLength;\\r\\n if (loadingProgress < 1.0 && distFromStart > loadingProgress) {\\r\\n discard;\\r\\n }\\r\\n#endif\\r\\n\\r\\n\\r\\n#ifdef HAS_LINESTYLES\\r\\n int whichPattern = int(fsMultipurpose.w);\\r\\n\\r\\n if (whichPattern > 0) {\\r\\n const float TEX_TO_UNIT = 1.0 / 96.0;\\r\\n\\r\\n float patternScale;\\r\\n\\r\\n\\r\\n\\r\\n if (fsHalfWidth < 0.0) {\\r\\n patternScale = LTSCALE;\\r\\n } else {\\r\\n patternScale = LTSCALE * TEX_TO_UNIT * pixelsPerUnit;\\r\\n }\\r\\n\\r\\n float patLen = patternScale * getPatternLength(whichPattern);\\r\\n float phase = mod((totalDistance + parametricDistance) * pixelsPerUnit, patLen);\\r\\n\\r\\n bool onPixel = true;\\r\\n float radiusPixels = radius * pixelsPerUnit;\\r\\n\\r\\n for (int i=2; i aaRange) {\\r\\n discard;\\r\\n }\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n gl_FragColor = fsColor;\\r\\n gl_FragColor.a *= curveGaussian(range+aaRange, pixelsPerUnit);\\r\\n}\\r\\n\\r\\n#ifdef HAS_CIRCLES\\r\\nvoid fillCircularArc() {\\r\\n\\r\\n float dist = length(fsOffsetDirection);\\r\\n vec2 angles = fsMultipurpose.xz;\\r\\n float radius = abs(fsMultipurpose.y);\\r\\n float range = abs(dist - radius);\\r\\n range -= fsHalfWidth;\\r\\n\\r\\n\\r\\n\\r\\n if (range > aaRange) {\\r\\n discard;\\r\\n }\\r\\n\\r\\n vec2 direction = fsOffsetDirection;\\r\\n float angle = atan(direction.y, direction.x);\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n if (angles.x > angles.y) {\\r\\n\\r\\n if (angle > angles.x && angle < PI) {\\r\\n angle -= TAU;\\r\\n }\\r\\n angles.x -= TAU;\\r\\n\\r\\n\\r\\n\\r\\n if (angle < angles.x ) {\\r\\n angle += TAU;\\r\\n }\\r\\n }\\r\\n else if (angle < 0.0)\\r\\n angle += TAU;\\r\\n\\r\\n#ifdef LOADING_ANIMATION\\r\\n if ((angle - angles.x) / (angles.y - angles.x) > loadingProgress) {\\r\\n discard;\\r\\n }\\r\\n#endif\\r\\n\\r\\n\\r\\n if (angle > angles.x && angle < angles.y) {\\r\\n gl_FragColor = fsColor;\\r\\n gl_FragColor.a *= curveGaussian(range+aaRange, pixelsPerUnit);\\r\\n }\\r\\n else {\\r\\n discard;\\r\\n }\\r\\n\\r\\n}\\r\\n#endif\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n#ifdef HAS_ELLIPTICALS\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\nfloat EllipticalApprox(\\r\\n const int iters,\\r\\n inout float t0, inout float t1,\\r\\n const vec2 y, out vec2 x,\\r\\n const vec2 e, const vec2 ey, const vec2 esqr\\r\\n ) {\\r\\n vec2 r;\\r\\n for (int i = 0; i < 10; ++i) {\\r\\n if(i >= iters) break;\\r\\n\\r\\n float t = mix(t0, t1, 0.5);\\r\\n r = ey / (vec2(t) + esqr);\\r\\n\\r\\n vec2 rsq = r * r;\\r\\n float f = rsq.x + rsq.y - 1.0;\\r\\n\\r\\n if(f > 0.0) { t0 = t; } else { t1 = t; }\\r\\n }\\r\\n\\r\\n x = e * r;\\r\\n return distance(x, y);\\r\\n}\\r\\n\\r\\nfloat DistancePointEllipseSpecial (vec2 e, vec2 y, out vec2 x, float width, float aaRange) {\\r\\n float dist;\\r\\n\\r\\n\\r\\n vec2 esqr = e * e;\\r\\n vec2 ey = e * y;\\r\\n float t0 = -esqr[1] + ey[1];\\r\\n float t1 = -esqr[1] + length(ey);\\r\\n\\r\\n\\r\\n\\r\\n dist = EllipticalApprox(6, t0, t1, y, x, e, ey, esqr);\\r\\n\\r\\n\\r\\n if (dist > max(2.0 * (width + aaRange), e[0] * 0.05))\\r\\n return dist;\\r\\n\\r\\n\\r\\n dist = EllipticalApprox(6, t0, t1, y, x, e, ey, esqr);\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n float ecc = 1.0 + 0.1 * e[0] / e[1];\\r\\n\\r\\n if (dist > max(ecc * (width + aaRange), e[0] * 0.001))\\r\\n return dist;\\r\\n if (dist < (width - aaRange) / ecc)\\r\\n return dist;\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n dist = EllipticalApprox(10, t0, t1, y, x, e, ey, esqr);\\r\\n return dist;\\r\\n}\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\nfloat DistancePointEllipse(vec2 e, vec2 y, out vec2 locX, float width, float aaRange) {\\r\\n vec2 locE, locY;\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n float diff = sign(e[0] - e[1]);\\r\\n vec2 swizzle = vec2(max(diff, 0.0), -min(diff, 0.0));\\r\\n locE.x = dot(e, swizzle.xy);\\r\\n locE.y = dot(e, swizzle.yx);\\r\\n locY.x = dot(y, swizzle.xy);\\r\\n locY.y = dot(y, swizzle.yx);\\r\\n\\r\\n\\r\\n vec2 refl = sign(locY);\\r\\n locY *= refl;\\r\\n\\r\\n vec2 x;\\r\\n float distance = DistancePointEllipseSpecial(locE, locY, x, width, aaRange);\\r\\n\\r\\n x *= refl;\\r\\n\\r\\n locX.x = dot(x, swizzle.xy);\\r\\n locX.y = dot(x, swizzle.yx);\\r\\n\\r\\n return distance;\\r\\n}\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\nvoid fillEllipticalArc() {\\r\\n vec2 angles = fsMultipurpose.xz;\\r\\n vec2 radii = abs(fsMultipurpose.yw);\\r\\n vec2 dir = fsOffsetDirection;\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n vec2 pos;\\r\\n float range = DistancePointEllipse(radii, dir, pos, fsHalfWidth, aaRange);\\r\\n range -= fsHalfWidth;\\r\\n\\r\\n if (range > aaRange)\\r\\n discard;\\r\\n\\r\\n float ar = radii[0] / radii[1];\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n float angle = atan(ar * pos.y, pos.x);\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n if (angles.x > angles.y) {\\r\\n\\r\\n if (angle > angles.x && angle < PI) {\\r\\n angle -= TAU;\\r\\n }\\r\\n angles.x -= TAU;\\r\\n\\r\\n\\r\\n\\r\\n if (angle < angles.x ) {\\r\\n angle += TAU;\\r\\n }\\r\\n }\\r\\n else if (angle < 0.0)\\r\\n angle += TAU;\\r\\n\\r\\n#ifdef LOADING_ANIMATION\\r\\n if ((angle - angles.x) / (angles.y - angles.x) > loadingProgress) {\\r\\n discard;\\r\\n }\\r\\n#endif\\r\\n\\r\\n\\r\\n if (angle > angles.x && angle < angles.y) {\\r\\n gl_FragColor = fsColor;\\r\\n gl_FragColor.a *= curveGaussian(range+aaRange, pixelsPerUnit);\\r\\n }\\r\\n else {\\r\\n discard;\\r\\n }\\r\\n}\\r\\n#endif\\r\\n\\r\\n#ifdef HAS_RASTER_QUADS\\r\\n void fillTexQuad() {\\r\\n gl_FragColor = texture2D(tRaster, fsMultipurpose.xy);\\r\\n #ifdef LOADING_ANIMATION\\r\\n gl_FragColor.a *= loadingProgress;\\r\\n #endif\\r\\n }\\r\\n#endif\\r\\n\\r\\nvoid fillTriangle() {\\r\\n#ifdef IMAGE_UV_TEXTURE\\r\\n gl_FragColor = texture2D(tRaster, fract(vuv));\\r\\n#else\\r\\n gl_FragColor = fsColor;\\r\\n#endif\\r\\n\\r\\n#ifdef LOADING_ANIMATION\\r\\n gl_FragColor.a *= loadingProgress;\\r\\n#endif\\r\\n}\\r\\n\\r\\n#if NUM_CUTPLANES > 0\\r\\nvarying highp vec3 vWorldPosition;\\r\\n#endif\\r\\n\\r\\n#ifdef MSDF_TEXTURE_FONT\\r\\nvarying highp vec2 vuv;\\r\\nvarying float isMSDFQuards;\\r\\nuniform sampler2D tRaster;\\r\\nfloat median(float r, float g, float b) {\\r\\n return max(min(r, g), min(max(r, g), b));\\r\\n}\\r\\n\\r\\n#endif\\r\\n\\r\\n#include\\r\\n\\r\\nvoid main() {\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n if (fsColor == vec4(0.0)) {\\r\\n discard;\\r\\n }\\r\\n\\r\\n\\r\\n#ifdef VIEWPORT_CLIPPING\\r\\n if(vPosition.x < viewportBounds.x || vPosition.x > viewportBounds.z || vPosition.y < viewportBounds.y || vPosition.y > viewportBounds.w) {\\r\\n discard;\\r\\n }\\r\\n#endif\\r\\n\\r\\n#ifdef MSDF_TEXTURE_FONT\\r\\n vec4 msdfColor = texture2D(tRaster, vuv);\\r\\n float dist = median(msdfColor.r, msdfColor.g, msdfColor.b);\\r\\n\\r\\n\\r\\n float delta = mix(0.25, 0.5, 1.0 - fwidth(dist));\\r\\n\\r\\n float sigDist = dist - delta;\\r\\n float msdfAlpha = clamp(sigDist/fwidth(sigDist) + delta, 0.0, 1.0);\\r\\n\\r\\n msdfAlpha = smoothstep(0., 1., msdfAlpha);\\r\\n gl_FragColor.a = mix(msdfAlpha, 1., 1.-isMSDFQuards);\\r\\n if (gl_FragColor.a < 0.0001) discard;\\r\\n\\r\\n#endif\\r\\n\\r\\n\\r\\n if (fsHalfWidth == 0.0) {\\r\\n#ifdef HAS_RASTER_QUADS\\r\\n if (fsMultipurpose.z != 0.0)\\r\\n fillTexQuad();\\r\\n else\\r\\n#endif\\r\\n fillTriangle();\\r\\n }\\r\\n else if (fsMultipurpose.y < 0.0) {\\r\\n#ifdef HAS_CIRCLES\\r\\n#ifdef HAS_ELLIPTICALS\\r\\n if (abs(fsMultipurpose.y) == fsMultipurpose.w)\\r\\n#endif\\r\\n fillCircularArc();\\r\\n#endif\\r\\n#ifdef HAS_ELLIPTICALS\\r\\n#ifdef HAS_CIRCLES\\r\\n else\\r\\n#endif\\r\\n fillEllipticalArc();\\r\\n#endif\\r\\n }\\r\\n else\\r\\n fillLineSegment();\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n float writeId = 1.0;\\r\\n \\r\\n gl_FragColor.a *= opacity;\\r\\n\\r\\n if (gl_FragColor.a == 0.0) {\\r\\n discard;\\r\\n }\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n if (fsGhosting != 0.0 || \\r\\n ((viewportId != 0.0) && (abs(fsVpTC.x * 255.0 + fsVpTC.y) >= 0.5 && abs(fsVpTC.x * 255.0 + fsVpTC.y - viewportId) >= 0.5))) {\\r\\n\\r\\n writeId = 0.0;\\r\\n\\r\\n\\r\\n\\r\\n gl_FragColor.a *= ((swap == 1.0) ? 0.21 : 0.1);\\r\\n }\\r\\n\\r\\n#ifndef SELECTION_RENDERER\\r\\n\\r\\n if (grayscale != 0.0) {\\r\\n const vec3 rgb2grey = vec3(0.299, 0.587, 0.114);\\r\\n float gray = dot(gl_FragColor.rgb, rgb2grey);\\r\\n gl_FragColor.rgb = vec3(gray);\\r\\n }\\r\\n#endif\\r\\n\\r\\n#if NUM_CUTPLANES > 0\\r\\n checkCutPlanes(vWorldPosition);\\r\\n#endif\\r\\n\\r\\n#ifdef MRT_NORMALS\\r\\n\\r\\n outNormal = vec4(0.0, 0.0, 0.0, 1.0);\\r\\n#endif\\r\\n#include\\r\\n}\\r\\n\";","module.exports = \"\\r\\n\\r\\n#include\\r\\n\\r\\nattribute vec2 fields1;\\r\\nattribute vec4 fields2;\\r\\nattribute vec4 flags4b;\\r\\nattribute vec4 layerVp4b;\\r\\n\\r\\n#ifdef HAS_ELLIPTICALS\\r\\nattribute vec3 extraParams;\\r\\n#endif\\r\\n\\r\\n#ifdef USE_INSTANCING\\r\\nattribute vec4 instFlags4b;\\r\\n#endif\\r\\n\\r\\n#ifdef MSDF_TEXTURE_FONT\\r\\nvarying highp vec2 vuv;\\r\\nvarying float isMSDFQuards;\\r\\n#endif\\r\\n\\r\\n#ifdef IMAGE_UV_TEXTURE\\r\\nvarying highp vec2 vuv;\\r\\n#endif\\r\\n\\r\\n#ifdef VIEWPORT_CLIPPING\\r\\nvarying vec2 vPosition;\\r\\n#endif\\r\\n\\r\\nuniform mat4 mvpMatrix;\\r\\n\\r\\nuniform float pixelsPerUnit;\\r\\nuniform float aaRange;\\r\\nuniform float viewportId;\\r\\nuniform float swap;\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n#ifdef HAS_LAYERS\\r\\nuniform sampler2D tLayerMask;\\r\\n#endif\\r\\n\\r\\n#ifdef SELECTION_RENDERER\\r\\nuniform sampler2D tSelectionTexture;\\r\\nuniform vec2 vSelTexSize;\\r\\n#endif\\r\\n\\r\\n#ifdef SELECTION_RENDERER\\r\\nuniform vec4 selectionColor;\\r\\n#endif\\r\\n\\r\\n#ifdef LOADING_ANIMATION\\r\\nuniform float meshAnimTime;\\r\\n#endif\\r\\n\\r\\n#if NUM_CUTPLANES > 0\\r\\nvarying vec3 vWorldPosition;\\r\\n#endif\\r\\n\\r\\nvarying vec4 dbId;\\r\\n\\r\\n#ifdef UNPACK_POSITIONS\\r\\nuniform sampler2D tIdColor;\\r\\nuniform vec2 vIdColorTexSize;\\r\\nuniform vec4 unpackXform;\\r\\nattribute vec2 uvIdColor;\\r\\nfloat unpackLineWeight(float w) {\\r\\n if (w > 0.5) {\\r\\n return - (w - 0.5) * 1024.0;\\r\\n } else {\\r\\n return w * max(unpackXform.x, unpackXform.y) * 2.0;\\r\\n }\\r\\n}\\r\\nvec4 getVertexColor() {\\r\\n float u = (uvIdColor.x + 0.5) / vIdColorTexSize.x;\\r\\n return texture2D(tIdColor, vec2(u, 0.5));\\r\\n}\\r\\nvec4 getDbId() {\\r\\n float u = (uvIdColor.y + 0.5) / vIdColorTexSize.x;\\r\\n vec4 normDbId = texture2D(tIdColor, vec2(u, 0.5));\\r\\n return normDbId * 255.0;\\r\\n}\\r\\n#else\\r\\nattribute vec4 color4b;\\r\\nattribute vec4 dbId4b;\\r\\nvec4 unpackXform;\\r\\nfloat unpackLineWeight(float w) {\\r\\n return w;\\r\\n}\\r\\nvec4 getVertexColor() {\\r\\n return color4b;\\r\\n}\\r\\nvec4 getDbId() {\\r\\n return dbId4b;\\r\\n}\\r\\n#endif\\r\\n\\r\\n\\r\\nvec2 centralVertex;\\r\\nvec2 offsetPosition;\\r\\n\\r\\nvec2 cos_sin(const float angle) { return vec2(cos(angle), sin(angle)); }\\r\\n\\r\\nvoid min_max(inout vec2 minPt, inout vec2 maxPt, const vec2 p) {\\r\\n minPt = min(minPt, p);\\r\\n maxPt = max(maxPt, p);\\r\\n}\\r\\n\\r\\n#if defined(USE_INSTANCING)\\r\\nfloat getVertexId() { return instFlags4b.x; }\\r\\n#else\\r\\nfloat getVertexId() { return flags4b.x; }\\r\\n#endif\\r\\n\\r\\nbool isStartVertex() { return (getVertexId() < VBB_SEG_END_RIGHT); }\\r\\nbool isLeftVertex() { float id = getVertexId(); return ((id == VBB_SEG_END_LEFT || id == VBB_SEG_START_LEFT)); }\\r\\n\\r\\nstruct SegmentData { float angle, distAlong, distTotal, lineWidthHalf, lineType; };\\r\\nvoid decodeSegmentData(out SegmentData seg) {\\r\\n seg.angle = fields2.x * TAU - PI;\\r\\n seg.distAlong = fields2.y * max(unpackXform.x, unpackXform.y);\\r\\n seg.distTotal = fields2.w;\\r\\n seg.lineWidthHalf = unpackLineWeight(fields2.z);\\r\\n seg.lineType = flags4b.z;\\r\\n}\\r\\n\\r\\nvoid strokeLineSegment() {\\r\\n SegmentData seg; decodeSegmentData(seg);\\r\\n\\r\\n float isStartCapVertex = isStartVertex() ? -1.0 : 1.0;\\r\\n float isLeftSide = isLeftVertex( ) ? 1.0 : -1.0;\\r\\n\\r\\n\\r\\n float angleTransverse = seg.angle + isLeftSide * HALF_PI;\\r\\n float lwAdjustment = fsHalfWidth + aaRange;\\r\\n vec2 transverseOffset = cos_sin(angleTransverse) * lwAdjustment;\\r\\n offsetPosition.xy += transverseOffset;\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n float distanceFromStart = max(isStartCapVertex, 0.0) * seg.distAlong;\\r\\n vec2 along = distanceFromStart * cos_sin(seg.angle);\\r\\n offsetPosition.xy += along;\\r\\n centralVertex.xy += along;\\r\\n\\r\\n\\r\\n vec2 moveOffset = isStartCapVertex * isLeftSide * vec2(-transverseOffset.y, transverseOffset.x);\\r\\n offsetPosition.xy -= moveOffset;\\r\\n centralVertex.xy -= moveOffset;\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n fsMultipurpose.x = (isStartCapVertex * lwAdjustment) + distanceFromStart;\\r\\n fsMultipurpose.y = seg.distAlong;\\r\\n fsMultipurpose.z = seg.distTotal;\\r\\n fsMultipurpose.w = seg.lineType;\\r\\n\\r\\n if (seg.lineWidthHalf < 0.0)\\r\\n fsHalfWidth = -fsHalfWidth;\\r\\n}\\r\\n\\r\\n\\r\\n#ifdef HAS_TRIANGLE_GEOMS\\r\\nstruct TriangleData { vec2 p0, p1, p2; };\\r\\nvoid decodeTriangleData(out TriangleData tri) {\\r\\n\\r\\n tri.p1 = vec2(fields2.x, fields2.y) * unpackXform.xy + unpackXform.zw;\\r\\n tri.p2 = fields2.zw * unpackXform.xy + unpackXform.zw;\\r\\n}\\r\\n\\r\\nvoid strokeOneTriangle() {\\r\\n TriangleData tri; decodeTriangleData(tri);\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n fsHalfWidth = 0.0;\\r\\n fsMultipurpose.z = 0.0;\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n float vertexId = getVertexId();\\r\\n if (vertexId == VBB_SEG_END_RIGHT)\\r\\n offsetPosition.xy = tri.p1;\\r\\n else if (vertexId == VBB_SEG_END_LEFT)\\r\\n offsetPosition.xy = tri.p2;\\r\\n}\\r\\n#endif\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n#ifdef HAS_RASTER_QUADS\\r\\nstruct TexQuadData { float angle; vec2 size; };\\r\\nvoid decodeTexQuadData(out TexQuadData quad) {\\r\\n quad.angle = fields2.x * TAU;\\r\\n quad.size = fields2.yz * max(unpackXform.x, unpackXform.y);\\r\\n}\\r\\n\\r\\nvoid strokeTexQuad() {\\r\\n TexQuadData quad; decodeTexQuadData(quad);\\r\\n\\r\\n vec2 corner = vec2(isLeftVertex() ? -1.0 : 1.0, isStartVertex() ? -1.0 : 1.0);\\r\\n\\r\\n vec2 p = 0.5 * corner * quad.size;\\r\\n vec2 rot = cos_sin(quad.angle);\\r\\n vec2 offset = vec2(p.x * rot.x - p.y * rot.y, p.x * rot.y + p.y * rot.x);\\r\\n\\r\\n offsetPosition.xy += offset;\\r\\n\\r\\n fsMultipurpose.xy = max(vec2(0.0), corner);\\r\\n\\r\\n\\r\\n fsMultipurpose.z = 1.0;\\r\\n fsHalfWidth = 0.0;\\r\\n}\\r\\n#endif\\r\\n\\r\\n#if defined(HAS_CIRCLES) || defined(HAS_ELLIPTICALS)\\r\\nstruct ArcData { vec2 c; float start, end, major, minor, tilt; };\\r\\nvoid decodeArcData(out ArcData arc) {\\r\\n arc.c = fields1.xy * unpackXform.xy + unpackXform.zw;\\r\\n arc.start = fields2.x * TAU;\\r\\n arc.end = fields2.y * TAU;\\r\\n arc.major = fields2.w * max(unpackXform.x, unpackXform.y);\\r\\n#if defined(HAS_ELLIPTICALS)\\r\\n arc.minor = extraParams.x;\\r\\n arc.tilt = extraParams.y * TAU;\\r\\n#endif\\r\\n}\\r\\n\\r\\nvoid strokeArc(const ArcData arc) {\\r\\n\\r\\n\\r\\n float isStart = isStartVertex() ? -1.0 : 1.0;\\r\\n float isLeft = isLeftVertex() ? -1.0 : 1.0;\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n vec2 minPt;\\r\\n vec2 maxPt;\\r\\n\\r\\n vec2 angles = vec2(arc.start, arc.end);\\r\\n vec2 endsX = vec2(arc.c.x) + arc.major * cos(angles);\\r\\n vec2 endsY = vec2(arc.c.y) + arc.minor * sin(angles);\\r\\n minPt = maxPt = vec2(endsX.x, endsY.x);\\r\\n min_max(minPt, maxPt, vec2(endsX.y, endsY.y));\\r\\n\\r\\n if (arc.end > arc.start) {\\r\\n if (arc.start < PI_0_5 && arc.end > PI_0_5) {\\r\\n min_max(minPt, maxPt, vec2(arc.c.x, arc.c.y + arc.minor));\\r\\n }\\r\\n if (arc.start < PI && arc.end > PI) {\\r\\n min_max(minPt, maxPt, vec2(arc.c.x - arc.major, arc.c.y));\\r\\n }\\r\\n if (arc.start < PI_1_5 && arc.end > PI_1_5) {\\r\\n min_max(minPt, maxPt, vec2(arc.c.x, arc.c.y - arc.minor));\\r\\n }\\r\\n } else {\\r\\n\\r\\n min_max(minPt, maxPt, vec2(arc.c.x + arc.major, arc.c.y));\\r\\n\\r\\n\\r\\n\\r\\n if (arc.start < PI_0_5 || arc.end > PI_0_5) {\\r\\n min_max(minPt, maxPt, vec2(arc.c.x, arc.c.y + arc.minor));\\r\\n }\\r\\n if (arc.start < PI || arc.end > PI) {\\r\\n min_max(minPt, maxPt, vec2(arc.c.x - arc.major, arc.c.y));\\r\\n }\\r\\n if (arc.start < PI_1_5 || arc.end > PI_1_5) {\\r\\n min_max(minPt, maxPt, vec2(arc.c.x, arc.c.y - arc.minor));\\r\\n }\\r\\n }\\r\\n\\r\\n minPt -= fsHalfWidth + aaRange;\\r\\n maxPt += fsHalfWidth + aaRange;\\r\\n\\r\\n offsetPosition.x = (isStart < 0.0) ? minPt.x : maxPt.x;\\r\\n offsetPosition.y = (isLeft < 0.0) ? minPt.y : maxPt.y;\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n fsMultipurpose.x = arc.start;\\r\\n fsMultipurpose.y = -arc.major;\\r\\n fsMultipurpose.z = arc.end;\\r\\n fsMultipurpose.w = arc.minor;\\r\\n}\\r\\n#endif\\r\\n\\r\\n#if defined(HAS_CIRCLES)\\r\\n\\r\\nvoid strokeCircularArc() {\\r\\n ArcData arc; decodeArcData(arc);\\r\\n\\r\\n float r = arc.major;\\r\\n if (r * pixelsPerUnit < 0.125)\\r\\n r = 0.25 * aaRange;\\r\\n arc.major = arc.minor = r;\\r\\n\\r\\n strokeArc(arc);\\r\\n}\\r\\n\\r\\n#endif\\r\\n\\r\\n#if defined(HAS_ELLIPTICALS)\\r\\nvoid strokeEllipticalArc() {\\r\\n ArcData arc; decodeArcData(arc);\\r\\n strokeArc(arc);\\r\\n}\\r\\n#endif\\r\\n\\r\\nstruct CommonAttribs { vec2 pos; vec4 color; vec2 layerTC, vpTC; float lineWidthHalf, geomType, ghosting; };\\r\\nvoid decodeCommonAttribs(out CommonAttribs attribs) {\\r\\n attribs.pos = fields1.xy * unpackXform.xy + unpackXform.zw;\\r\\n attribs.color = getVertexColor();\\r\\n attribs.geomType = flags4b.y;\\r\\n attribs.layerTC = layerVp4b.xy / 255.0;\\r\\n attribs.vpTC = layerVp4b.zw / 255.0;\\r\\n attribs.lineWidthHalf = unpackLineWeight(fields2.z);\\r\\n attribs.ghosting = flags4b.w;\\r\\n}\\r\\n\\r\\nvoid strokeIndexedTriangle() {\\r\\n\\r\\n fsHalfWidth = 0.0;\\r\\n fsMultipurpose.z = 0.0;\\r\\n}\\r\\n\\r\\n#ifdef SELECTION_RENDERER\\r\\nbool isSelected(const CommonAttribs attribs) {\\r\\n\\r\\n\\r\\n vec3 oid = getDbId().rgb;\\r\\n\\r\\n\\r\\n float id01 = oid.r + oid.g * 256.0;\\r\\n float t = (id01 + 0.5) * (1.0 / 4096.0);\\r\\n float flrt = floor(t);\\r\\n float texU = t - flrt;\\r\\n\\r\\n\\r\\n float id23 = oid.b * (65536.0 / 4096.0) + flrt;\\r\\n t = (id23 + 0.5) / vSelTexSize.y;\\r\\n float texV = fract(t);\\r\\n\\r\\n vec4 selBit = texture2D(tSelectionTexture, vec2(texU, texV));\\r\\n return selBit.r == 1.0;\\r\\n}\\r\\n#endif\\r\\n\\r\\nbool isLayerOff(const CommonAttribs attribs) {\\r\\n#ifdef HAS_LAYERS\\r\\n vec4 layerBit = texture2D(tLayerMask, attribs.layerTC);\\r\\n return (layerBit.r == 0.0);\\r\\n#else\\r\\n return false;\\r\\n#endif\\r\\n}\\r\\n\\r\\nvec4 getColor(const CommonAttribs attribs) {\\r\\n\\r\\n if (isLayerOff(attribs)) { return vec4(0.0); }\\r\\n\\r\\n#ifdef SELECTION_RENDERER\\r\\n if (isSelected(attribs)) { return selectionColor; }\\r\\n return vec4(0.0);\\r\\n#else\\r\\n return attribs.color;\\r\\n#endif\\r\\n}\\r\\n\\r\\n#ifdef GAMMA_INPUT\\r\\nvec4 inputToLinear(vec4 c) {\\r\\n return vec4(vec3(c*c), c.a);\\r\\n}\\r\\n#endif\\r\\n\\r\\nvoid main() {\\r\\n#ifndef UNPACK_POSITIONS\\r\\n unpackXform = vec4(1.0, 1.0, 0.0, 0.0);\\r\\n#endif\\r\\n\\r\\n CommonAttribs attribs; decodeCommonAttribs(attribs);\\r\\n#ifdef MSDF_TEXTURE_FONT\\r\\n vuv = fields2.xy;\\r\\n isMSDFQuards = 1.0 - abs(sign(attribs.geomType - VBB_GT_MSDF_TRIANGLE_INDEXED));\\r\\n#endif\\r\\n\\r\\n#ifdef IMAGE_UV_TEXTURE\\r\\n vuv = fields2.xy;\\r\\n#endif\\r\\n\\r\\n fsColor = getColor(attribs);\\r\\n\\r\\n #ifdef GAMMA_INPUT\\r\\n fsColor = inputToLinear(fsColor);\\r\\n #endif\\r\\n\\r\\n\\r\\n if (swap != 0.0 ) {\\r\\n\\r\\n if ( fsColor.r == 0.0 && fsColor.g == 0.0 && fsColor.b == 0.0 )\\r\\n fsColor.rgb = vec3(1.0,1.0,1.0);\\r\\n\\r\\n else if ( fsColor.r == 1.0 && fsColor.g == 1.0 && fsColor.b == 1.0 )\\r\\n fsColor.rgb = vec3(0.0,0.0,0.0);\\r\\n }\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n centralVertex = offsetPosition = attribs.pos;\\r\\n\\r\\n float lineWeight = attribs.lineWidthHalf;\\r\\n if (lineWeight > 0.0) {\\r\\n\\r\\n\\r\\n if(lineWeight < 0.5 / pixelsPerUnit) {\\r\\n lineWeight = 0.5 / pixelsPerUnit;\\r\\n }\\r\\n }\\r\\n else {\\r\\n\\r\\n\\r\\n lineWeight = abs(lineWeight) / pixelsPerUnit;\\r\\n }\\r\\n\\r\\n fsHalfWidth = lineWeight;\\r\\n\\r\\n dbId = getDbId() / 255.0;\\r\\n\\r\\n fsVpTC = attribs.vpTC;\\r\\n fsGhosting = attribs.ghosting;\\r\\n\\r\\n if (attribs.geomType == VBB_GT_LINE_SEGMENT) strokeLineSegment();\\r\\n#ifdef HAS_CIRCLES\\r\\n else if (attribs.geomType == VBB_GT_ARC_CIRCULAR) strokeCircularArc();\\r\\n#endif\\r\\n#ifdef HAS_ELLIPTICALS\\r\\n else if (attribs.geomType == VBB_GT_ARC_ELLIPTICAL) strokeEllipticalArc();\\r\\n#endif\\r\\n#ifdef HAS_RASTER_QUADS\\r\\n else if (attribs.geomType == VBB_GT_TEX_QUAD) strokeTexQuad();\\r\\n#endif\\r\\n#ifdef HAS_TRIANGLE_GEOMS\\r\\n else if (attribs.geomType == VBB_GT_ONE_TRIANGLE) strokeOneTriangle();\\r\\n#endif\\r\\n else if (attribs.geomType == VBB_GT_TRIANGLE_INDEXED) strokeIndexedTriangle();\\r\\n\\r\\n\\r\\n\\r\\n fsOffsetDirection = offsetPosition - centralVertex;\\r\\n\\r\\n\\r\\n gl_Position = mvpMatrix * modelMatrix * vec4( offsetPosition.xy, 0.0, 1.0 );\\r\\n\\r\\n#ifdef LOADING_ANIMATION\\r\\n\\r\\n if (dbId.rgb == vec3(1.0)) {\\r\\n loadingProgress = 1.0;\\r\\n } else {\\r\\n loadingProgress = smoothstep(0.0, 1.0, meshAnimTime);\\r\\n }\\r\\n#endif\\r\\n\\r\\n#ifdef IMAGE_UV_TEXTURE\\r\\n fsHalfWidth = 0.0;\\r\\n#endif\\r\\n\\r\\n\\r\\n#if NUM_CUTPLANES > 0\\r\\n vec4 worldPosition = modelMatrix * vec4( offsetPosition.xy, 0.0, 1.0 );\\r\\n vWorldPosition = worldPosition.xyz;\\r\\n#endif\\r\\n\\r\\n#ifdef VIEWPORT_CLIPPING\\r\\n vPosition = offsetPosition.xy;\\r\\n#endif\\r\\n}\\r\\n\";","module.exports = \"\\n#include\\n#include\\nuniform highp float pixelsPerUnit;\\nuniform highp float aaRange;\\nuniform float opacity;\\nuniform highp float viewportId;\\nuniform highp float swap;\\nuniform highp float grayscale;\\n#ifdef HAS_LINESTYLES\\nuniform sampler2D tLineStyle;\\nuniform vec2 vLineStyleTexSize;\\n#endif\\n#ifdef VIEWPORT_CLIPPING\\nuniform highp vec4 viewportBounds;\\nvarying highp vec2 vPosition;\\nuniform mat4 mvpMatrix;\\nuniform mat4 modelMatrix;\\n#endif\\nfloat curveGaussian(float r, float width) {\\n float amt = clamp(abs(r / (width * 1.0)), 0.0, 1.0);\\n amt = max(amt - 0.0, 0.0);\\n float exponent = amt * 2.0;\\n return clamp(exp(-exponent*exponent), 0.0, 1.0);\\n}\\n#ifdef HAS_LINESTYLES\\nfloat getLinePatternPixel(int i, int j) {\\n return texture2D(tLineStyle, (vec2(i, j) + 0.5) / vLineStyleTexSize).x * 255.0;\\n}\\nfloat getPatternLength(int whichPattern) {\\n float p1 = getLinePatternPixel(0, whichPattern);\\n float p2 = getLinePatternPixel(1, whichPattern);\\n return (p2 * 256.0 + p1);\\n}\\n#endif\\nvoid fillLineSegment() {\\n float radius = abs(fsHalfWidth);\\n float parametricDistance = fsMultipurpose.x;\\n float segmentLength = fsMultipurpose.y;\\n float totalDistance = fsMultipurpose.z;\\n#ifdef LOADING_ANIMATION\\n float distFromStart = parametricDistance / segmentLength;\\n if (loadingProgress < 1.0 && distFromStart > loadingProgress) {\\n discard;\\n }\\n#endif\\n#ifdef HAS_LINESTYLES\\n int whichPattern = int(fsMultipurpose.w);\\n if (whichPattern > 0) {\\n const float TEX_TO_UNIT = 1.0 / 96.0;\\n float patternScale;\\n if (fsHalfWidth < 0.0) {\\n patternScale = LTSCALE;\\n } else {\\n patternScale = LTSCALE * TEX_TO_UNIT * pixelsPerUnit;\\n }\\n float patLen = patternScale * getPatternLength(whichPattern);\\n float phase = mod((totalDistance + parametricDistance), patLen);\\n bool onPixel = true;\\n float radiusPixels = radius + aaRange;\\n for (int i=2; i aaRange) {\\n discard;\\n }\\n gl_FragColor = fsColor;\\n if (range > -aaRange)\\n gl_FragColor.a *= curveGaussian(range+aaRange, aaRange * 2.0);\\n}\\n#ifdef LOADING_ANIMATION\\n void fillTriangle() { gl_FragColor = vec4(fsColor.rgb, fsColor.a * loadingProgress); }\\n#else\\n void fillTriangle() { gl_FragColor = fsColor; }\\n#endif\\n#if NUM_CUTPLANES > 0\\nvarying highp vec3 vWorldPosition;\\n#endif\\n#include\\nfloat getSide(vec2 a, vec2 b, vec2 c) {\\n return sign((b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x));\\n}\\nvoid main() {\\n if (fsColor == vec4(0.0)) {\\n discard;\\n }\\n#ifdef VIEWPORT_CLIPPING\\n vec2 bottomLeft = (mvpMatrix * modelMatrix * vec4(viewportBounds.xy, 0., 1.)).xy;\\n vec2 bottomRight = (mvpMatrix * modelMatrix * vec4(viewportBounds.zy, 0., 1.)).xy;\\n vec2 topRight = (mvpMatrix * modelMatrix * vec4(viewportBounds.zw, 0., 1.)).xy;\\n vec2 topLeft = (mvpMatrix * modelMatrix * vec4(viewportBounds.xw, 0., 1.)).xy;\\n float side = getSide(topLeft, topRight, bottomLeft);\\n if (side * getSide(topRight, bottomRight, vPosition) < 0.0 ||\\n side * getSide(bottomRight, bottomLeft, vPosition) < 0.0 ||\\n side * getSide(bottomLeft, topLeft, vPosition) < 0.0 ||\\n side * getSide(topLeft, topRight, vPosition) < 0.0) {\\n discard;\\n }\\n#endif\\n if (fsHalfWidth == 0.0) {\\n fillTriangle();\\n }\\n else\\n fillLineSegment();\\n float writeId = 1.0;\\n gl_FragColor.a *= opacity;\\n if (gl_FragColor.a == 0.0) {\\n discard;\\n }\\n if (fsGhosting != 0.0 || \\n ((viewportId != 0.0) && (abs(fsVpTC.x * 255.0 + fsVpTC.y) >= 0.5 && abs(fsVpTC.x * 255.0 + fsVpTC.y - viewportId) >= 0.5))) {\\n writeId = 0.0;\\n gl_FragColor.a *= ((swap == 1.0) ? 0.21 : 0.1);\\n }\\n#ifndef SELECTION_RENDERER\\n if (grayscale != 0.0) {\\n const vec3 rgb2grey = vec3(0.299, 0.587, 0.114);\\n float gray = dot(gl_FragColor.rgb, rgb2grey);\\n gl_FragColor.rgb = vec3(gray);\\n }\\n#endif\\n#if NUM_CUTPLANES > 0\\n checkCutPlanes(vWorldPosition);\\n#endif\\n#ifdef MRT_NORMALS\\n outNormal = vec4(0.0, 0.0, 0.0, 1.0);\\n#endif\\n#include\\n}\\n\";","module.exports = \"\\n#include\\nattribute vec2 fields1;\\nattribute vec4 fields2;\\nattribute vec4 flags4b;\\nattribute vec4 layerVp4b;\\n#ifdef USE_INSTANCING\\nattribute vec4 instFlags4b;\\n#endif\\n#ifdef VIEWPORT_CLIPPING\\nvarying vec2 vPosition;\\n#endif\\nuniform mat4 mvpMatrix;\\nuniform float pixelsPerUnit;\\nuniform float aaRange;\\nuniform vec2 size;\\nuniform float viewportId;\\nuniform float swap;\\n#ifdef HAS_LAYERS\\nuniform sampler2D tLayerMask;\\n#endif\\n#ifdef SELECTION_RENDERER\\nuniform sampler2D tSelectionTexture;\\nuniform vec2 vSelTexSize;\\n#endif\\n#ifdef SELECTION_RENDERER\\nuniform vec4 selectionColor;\\n#endif\\n#ifdef LOADING_ANIMATION\\nuniform float meshAnimTime;\\n#endif\\n#if NUM_CUTPLANES > 0\\nvarying vec3 vWorldPosition;\\n#endif\\nvarying vec4 dbId;\\n#ifdef UNPACK_POSITIONS\\nuniform sampler2D tIdColor;\\nuniform vec2 vIdColorTexSize;\\nuniform vec4 unpackXform;\\nattribute vec2 uvIdColor;\\nfloat unpackLineWeight(float w) {\\n if (w > 0.5) {\\n return - (w - 0.5) * 1024.0;\\n } else {\\n return w * max(unpackXform.x, unpackXform.y) * 2.0;\\n }\\n}\\nvec4 getVertexColor() {\\n float u = (uvIdColor.x + 0.5) / vIdColorTexSize.x;\\n return texture2D(tIdColor, vec2(u, 0.5));\\n}\\nvec4 getDbId() {\\n float u = (uvIdColor.y + 0.5) / vIdColorTexSize.x;\\n vec4 normDbId = texture2D(tIdColor, vec2(u, 0.5));\\n return normDbId * 255.0;\\n}\\n#else\\nattribute vec4 color4b;\\nattribute vec4 dbId4b;\\nvec4 unpackXform;\\nfloat unpackLineWeight(float w) {\\n return w;\\n}\\nvec4 getVertexColor() {\\n return color4b;\\n}\\nvec4 getDbId() {\\n return dbId4b;\\n}\\n#endif\\nvec2 centralVertex;\\nvec2 offsetPosition;\\nvec2 offsetPosDepth;\\nvec2 cos_sin(const float angle) { return vec2(cos(angle), sin(angle)); }\\nvoid min_max(inout vec2 minPt, inout vec2 maxPt, const vec2 p) {\\n minPt = min(minPt, p);\\n maxPt = max(maxPt, p);\\n}\\n#if defined(USE_INSTANCING)\\nfloat getVertexId() { return instFlags4b.x; }\\n#else\\nfloat getVertexId() { return flags4b.x; }\\n#endif\\nbool isStartVertex() { return (getVertexId() < VBB_SEG_END_RIGHT); }\\nbool isLeftVertex() { float id = getVertexId(); return ((id == VBB_SEG_END_LEFT || id == VBB_SEG_START_LEFT)); }\\nstruct SegmentData { float angle, distAlong, distTotal, lineWidthHalf, lineType; };\\nvoid decodeSegmentData(out SegmentData seg) {\\n seg.angle = fields2.x * TAU - PI;\\n seg.distAlong = fields2.y * max(unpackXform.x, unpackXform.y);\\n seg.distTotal = fields2.w;\\n seg.lineWidthHalf = unpackLineWeight(fields2.z);\\n seg.lineType = flags4b.z;\\n}\\nvoid strokeLineSegment() {\\n SegmentData seg; decodeSegmentData(seg);\\n float isStartCapVertex = isStartVertex() ? -1.0 : 1.0;\\n float isLeftSide = isLeftVertex( ) ? 1.0 : -1.0;\\n vec4 startPosition = (mvpMatrix * modelMatrix * vec4(centralVertex.xy, 0.0, 1.0));\\n float distanceAlong = seg.distAlong;\\n vec2 along = distanceAlong * cos_sin(seg.angle);\\n vec4 endPosition = (mvpMatrix * modelMatrix * vec4(centralVertex.xy + along, 0.0, 1.0));\\n vec2 screenStart = startPosition.xy * 0.5 * size / startPosition.w;\\n vec2 screenEnd = endPosition.xy * 0.5 * size / endPosition.w;\\n if (isStartCapVertex < 0.0) {\\n offsetPosition = centralVertex = screenStart;\\n offsetPosDepth = startPosition.zw;\\n } else {\\n offsetPosition = centralVertex = screenEnd;\\n offsetPosDepth = endPosition.zw;\\n }\\n vec2 screenDelta = screenEnd - screenStart;\\n float screenAngle = (distanceAlong == 0.0) ? 0.0 : atan(screenDelta.y, screenDelta.x);\\n float angleTransverse = screenAngle - isLeftSide * HALF_PI;\\n float lwAdjustment = fsHalfWidth + aaRange;\\n vec2 transverseOffset = cos_sin(angleTransverse) * lwAdjustment;\\n offsetPosition += transverseOffset;\\n vec2 moveOffset = isStartCapVertex * isLeftSide * vec2(-transverseOffset.y, transverseOffset.x);\\n offsetPosition += moveOffset;\\n centralVertex += moveOffset;\\n float distanceFromStart = max(0.0, isStartCapVertex) * length(screenDelta);\\n fsMultipurpose.x = (isStartCapVertex * lwAdjustment) + distanceFromStart;\\n fsMultipurpose.y = length(screenDelta);\\n fsMultipurpose.z = seg.distTotal;\\n fsMultipurpose.w = seg.lineType;\\n if (seg.lineWidthHalf < 0.0)\\n fsHalfWidth = -fsHalfWidth;\\n fsOffsetDirection = offsetPosition - centralVertex;\\n gl_Position = vec4(2.0 * offsetPosition / size * offsetPosDepth.y, offsetPosDepth.xy);\\n}\\nstruct CommonAttribs { vec2 pos; vec4 color; vec2 layerTC, vpTC; float lineWidthHalf, geomType, ghosting; };\\nvoid decodeCommonAttribs(out CommonAttribs attribs) {\\n attribs.pos = fields1.xy * unpackXform.xy + unpackXform.zw;\\n attribs.color = getVertexColor();\\n attribs.geomType = flags4b.y;\\n attribs.layerTC = layerVp4b.xy / 255.0;\\n attribs.vpTC = layerVp4b.zw / 255.0;\\n attribs.lineWidthHalf = unpackLineWeight(fields2.z);\\n attribs.ghosting = flags4b.w;\\n}\\nvoid strokeIndexedTriangle() {\\n fsHalfWidth = 0.0;\\n fsMultipurpose.z = 0.0;\\n gl_Position = (mvpMatrix * modelMatrix * vec4(centralVertex.xy, 0.0, 1.0));\\n}\\n#ifdef SELECTION_RENDERER\\nbool isSelected(const CommonAttribs attribs) {\\n vec3 oid = getDbId().rgb;\\n float id01 = oid.r + oid.g * 256.0;\\n float t = (id01 + 0.5) * (1.0 / 4096.0);\\n float flrt = floor(t);\\n float texU = t - flrt;\\n float id23 = oid.b * (65536.0 / 4096.0) + flrt;\\n t = (id23 + 0.5) / vSelTexSize.y;\\n float texV = fract(t);\\n vec4 selBit = texture2D(tSelectionTexture, vec2(texU, texV));\\n return selBit.r == 1.0;\\n}\\n#endif\\nbool isLayerOff(const CommonAttribs attribs) {\\n#ifdef HAS_LAYERS\\n vec4 layerBit = texture2D(tLayerMask, attribs.layerTC);\\n return (layerBit.r == 0.0);\\n#else\\n return false;\\n#endif\\n}\\nvec4 getColor(const CommonAttribs attribs) {\\n if (isLayerOff(attribs)) { return vec4(0.0); }\\n#ifdef SELECTION_RENDERER\\n if (isSelected(attribs)) { return selectionColor; }\\n return vec4(0.0);\\n#else\\n return attribs.color;\\n#endif\\n}\\n#ifdef GAMMA_INPUT\\nvec4 inputToLinear(vec4 c) {\\n return vec4(vec3(c*c), c.a);\\n}\\n#endif\\nvoid main() {\\n#ifndef UNPACK_POSITIONS\\n unpackXform = vec4(1.0, 1.0, 0.0, 0.0);\\n#endif\\n CommonAttribs attribs; decodeCommonAttribs(attribs);\\n fsColor = getColor(attribs);\\n #ifdef GAMMA_INPUT\\n fsColor = inputToLinear(fsColor);\\n #endif\\n if (swap != 0.0 ) {\\n if ( fsColor.r == 0.0 && fsColor.g == 0.0 && fsColor.b == 0.0 )\\n fsColor.rgb = vec3(1.0,1.0,1.0);\\n else if ( fsColor.r == 1.0 && fsColor.g == 1.0 && fsColor.b == 1.0 )\\n fsColor.rgb = vec3(0.0,0.0,0.0);\\n }\\n centralVertex = offsetPosition = attribs.pos;\\n float lineWeight = attribs.lineWidthHalf;\\n if (lineWeight > 0.0) {\\n lineWeight = max(0.5, lineWeight * pixelsPerUnit);\\n }\\n else {\\n lineWeight = max(0.5, abs(lineWeight));\\n }\\n fsHalfWidth = lineWeight;\\n dbId = dbId4b / 255.0;\\n fsVpTC = attribs.vpTC;\\n fsGhosting = attribs.ghosting;\\n#ifdef LOADING_ANIMATION\\n if (dbId.rgb == vec3(1.0)) {\\n loadingProgress = 1.0;\\n } else {\\n loadingProgress = smoothstep(0.0, 1.0, meshAnimTime);\\n }\\n#endif\\n if (attribs.geomType == VBB_GT_LINE_SEGMENT) strokeLineSegment();\\n else strokeIndexedTriangle();\\n#if NUM_CUTPLANES > 0\\n vec4 worldPosition = modelMatrix * vec4( offsetPosition.xy, 0.0, 1.0 );\\n vWorldPosition = worldPosition.xyz;\\n#endif\\n#ifdef VIEWPORT_CLIPPING\\n vPosition = gl_Position.xy;\\n#endif\\n}\\n\";","module.exports = \"varying highp vec3 vNormal;\\nvarying highp float depth;\\n#if NUM_CUTPLANES > 0\\nvarying vec3 vWorldPosition;\\n#endif\\n#include\\nvoid main() {\\n#if NUM_CUTPLANES > 0\\n checkCutPlanes(vWorldPosition);\\n#endif\\n vec3 n = vNormal;\\n n = n * ( -1.0 + 2.0 * float( gl_FrontFacing ) );\\n n = normalize( n );\\n gl_FragColor = vec4(n.x, n.y, depth, 1.0);\\n}\\n\";","module.exports = \"varying vec3 vNormal;\\nvarying float depth;\\n#if NUM_CUTPLANES > 0\\nvarying vec3 vWorldPosition;\\n#endif\\n#include\\n#include\\nvoid main() {\\n#ifdef UNPACK_NORMALS\\n vec3 objectNormal = decodeNormal(normal);\\n#else\\n vec3 objectNormal = normal;\\n#endif\\n#ifdef FLIP_SIDED\\n objectNormal = -objectNormal;\\n#endif\\n objectNormal = getInstanceNormal(objectNormal);\\n vec3 instPos = getInstancePos(position);\\n vec3 transformedNormal = normalMatrix * objectNormal;\\n vNormal = normalize( transformedNormal );\\n#if NUM_CUTPLANES > 0\\n vec4 worldPosition = modelMatrix * vec4( instPos, 1.0 );\\n vWorldPosition = worldPosition.xyz;\\n#endif\\n vec4 mvPosition = modelViewMatrix * vec4( instPos, 1.0 );\\n depth = mvPosition.z;\\n vec4 p_Position = projectionMatrix * mvPosition;\\n gl_Position = p_Position;\\n}\\n\";","module.exports = \"uniform vec3 diffuse;\\r\\nuniform float opacity;\\r\\n\\r\\nuniform vec3 emissive;\\r\\nuniform vec3 specular;\\r\\nuniform float shininess;\\r\\n\\r\\n#include\\r\\n\\r\\n#ifdef USE_COLOR\\r\\nvarying vec3 vColor;\\r\\n#endif\\r\\n\\r\\n#ifdef GAMMA_INPUT\\r\\nvec3 InputToLinear(vec3 c) {\\r\\n return c * c;\\r\\n}\\r\\nfloat InputToLinear(float c) {\\r\\n return c * c;\\r\\n}\\r\\n#else\\r\\nvec3 InputToLinear(vec3 c) {\\r\\n return c;\\r\\n}\\r\\nfloat InputToLinear(float c) {\\r\\n return c;\\r\\n}\\r\\n#endif\\r\\n\\r\\n#if defined( USE_MAP ) || defined( USE_SPECULARMAP )\\r\\nvarying vec2 vUv;\\r\\n#endif\\r\\n\\r\\n#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\\r\\nvarying vec2 vUvBump;\\r\\n#endif\\r\\n\\r\\n#if defined( USE_ALPHAMAP )\\r\\nvarying vec2 vUvAlpha;\\r\\n#endif\\r\\n\\r\\n#ifdef USE_MAP\\r\\nuniform sampler2D map;\\r\\n#endif\\r\\n\\r\\n#if TONEMAP_OUTPUT > 0\\r\\nuniform float exposureBias;\\r\\n#include\\r\\n#endif\\r\\n\\r\\n#if defined(IRR_RGBM) || defined(ENV_RGBM) || defined(ENV_GAMMA) || defined(IRR_GAMMA)\\r\\nuniform float envMapExposure;\\r\\n#endif\\r\\n\\r\\n#ifdef USE_FOG\\r\\nuniform vec3 fogColor;\\r\\nuniform float fogNear;\\r\\nuniform float fogFar;\\r\\n#endif\\r\\n#include\\r\\n#include\\r\\n#include\\r\\n\\r\\n#ifdef USE_ENVMAP\\r\\n\\r\\nuniform float reflMipIndex;\\r\\n\\r\\nuniform float reflectivity;\\r\\nuniform samplerCube envMap;\\r\\n\\r\\n#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\\r\\n\\r\\nuniform float refractionRatio;\\r\\n\\r\\n#endif\\r\\n\\r\\nvec3 sampleReflection(vec3 dir, float mipIndex) {\\r\\n\\r\\n vec3 adjDir = adjustLookupVector(dir);\\r\\n\\r\\n#ifdef ENV_GAMMA\\r\\n\\r\\n#ifdef HAVE_TEXTURE_LOD\\r\\n vec4 envTexColor = textureCubeLodEXT( envMap, adjDir, mipIndex );\\r\\n#else\\r\\n\\r\\n\\r\\n vec4 envTexColor = textureCube( envMap, adjDir, mipIndex );\\r\\n#endif\\r\\n\\r\\n return GammaDecode(envTexColor, envMapExposure);\\r\\n\\r\\n#elif defined(ENV_RGBM)\\r\\n\\r\\n#ifdef HAVE_TEXTURE_LOD\\r\\n vec4 envTexColor = textureCubeLodEXT( envMap, adjDir, mipIndex );\\r\\n#else\\r\\n\\r\\n\\r\\n vec4 envTexColor = textureCube( envMap, adjDir, mipIndex );\\r\\n#endif\\r\\n\\r\\n return RGBMDecode(envTexColor, envMapExposure);\\r\\n\\r\\n#else\\r\\n\\r\\n\\r\\n\\r\\n vec4 envTexColor = textureCube( envMap, adjDir );\\r\\n vec3 cubeColor = envTexColor.xyz;\\r\\n\\r\\n#ifdef GAMMA_INPUT\\r\\n cubeColor *= cubeColor;\\r\\n#endif\\r\\n\\r\\n return cubeColor;\\r\\n\\r\\n#endif\\r\\n\\r\\n}\\r\\n\\r\\n#endif\\r\\n\\r\\n\\r\\nuniform vec3 ambientLightColor;\\r\\n\\r\\n#if MAX_DIR_LIGHTS > 0\\r\\n\\r\\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\\r\\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\\r\\n\\r\\n#endif\\r\\n\\r\\n#if MAX_POINT_LIGHTS > 0\\r\\n\\r\\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\\r\\n\\r\\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\\r\\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\\r\\n\\r\\n#endif\\r\\n\\r\\n#if MAX_SPOT_LIGHTS > 0\\r\\n\\r\\nuniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];\\r\\nuniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];\\r\\nuniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];\\r\\nuniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];\\r\\nuniform float spotLightExponent[ MAX_SPOT_LIGHTS ];\\r\\n\\r\\nuniform float spotLightDistance[ MAX_SPOT_LIGHTS ];\\r\\n\\r\\n#endif\\r\\n\\r\\n#ifdef USE_IRRADIANCEMAP\\r\\nuniform samplerCube irradianceMap;\\r\\n#endif\\r\\n\\r\\n#if MAX_SPOT_LIGHTS > 0 || NUM_CUTPLANES > 0\\r\\nvarying highp vec3 vWorldPosition;\\r\\n#endif\\r\\n\\r\\nvarying highp vec3 vViewPosition;\\r\\n#ifndef FLAT_SHADED\\r\\nvarying highp vec3 vNormal;\\r\\n#endif\\r\\n\\r\\n#ifdef USE_BUMPMAP\\r\\n\\r\\nuniform sampler2D bumpMap;\\r\\nuniform float bumpScale;\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\nvec2 dHdxy_fwd() {\\r\\n\\r\\n vec2 dSTdx = dFdx( vUvBump );\\r\\n vec2 dSTdy = dFdy( vUvBump );\\r\\n\\r\\n float Hll = bumpScale * GET_BUMPMAP(vUvBump).x;\\r\\n float dBx = bumpScale * GET_BUMPMAP(vUvBump + dSTdx).x - Hll;\\r\\n float dBy = bumpScale * GET_BUMPMAP(vUvBump + dSTdy).x - Hll;\\r\\n\\r\\n return vec2( dBx, dBy );\\r\\n\\r\\n}\\r\\n\\r\\nvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\\r\\n\\r\\n vec3 vSigmaX = dFdx( surf_pos );\\r\\n vec3 vSigmaY = dFdy( surf_pos );\\r\\n vec3 vN = surf_norm;\\r\\n\\r\\n vec3 R1 = cross( vSigmaY, vN );\\r\\n vec3 R2 = cross( vN, vSigmaX );\\r\\n\\r\\n float fDet = dot( vSigmaX, R1 );\\r\\n\\r\\n vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\\r\\n return normalize( abs( fDet ) * surf_norm - vGrad );\\r\\n\\r\\n}\\r\\n\\r\\n#endif\\r\\n\\r\\n\\r\\n#ifdef USE_NORMALMAP\\r\\n\\r\\nuniform sampler2D normalMap;\\r\\nuniform vec2 normalScale;\\r\\n\\r\\n\\r\\n\\r\\n\\r\\nvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\\r\\n\\r\\n vec3 q0 = dFdx( eye_pos.xyz );\\r\\n vec3 q1 = dFdy( eye_pos.xyz );\\r\\n vec2 st0 = dFdx( vUvBump.st );\\r\\n vec2 st1 = dFdy( vUvBump.st );\\r\\n\\r\\n vec3 S = normalize( q0 * st1.t - q1 * st0.t );\\r\\n vec3 T = normalize( -q0 * st1.s + q1 * st0.s );\\r\\n vec3 N = normalize( surf_norm );\\r\\n\\r\\n vec3 mapN = GET_NORMALMAP(vUvBump).xyz * 2.0 - 1.0;\\r\\n mapN.xy = normalScale * mapN.xy;\\r\\n mat3 tsn = mat3( S, T, N );\\r\\n return normalize( tsn * mapN );\\r\\n\\r\\n}\\r\\n\\r\\n#endif\\r\\n\\r\\n\\r\\n#ifdef USE_SPECULARMAP\\r\\nuniform sampler2D specularMap;\\r\\n#endif\\r\\n\\r\\n#ifdef USE_ALPHAMAP\\r\\nuniform sampler2D alphaMap;\\r\\n#endif\\r\\n\\r\\n#include\\r\\n\\r\\nvec3 Schlick_v3(vec3 v, float cosHV) {\\r\\n float facing = max(1.0 - cosHV, 0.0);\\r\\n return v + (1.0 - v) * pow(facing, 5.0);\\r\\n}\\r\\n\\r\\nfloat Schlick_f(float v, float cosHV) {\\r\\n float facing = max(1.0 - cosHV, 0.0);\\r\\n return v + ( 1.0 - v ) * pow(facing, 5.0);\\r\\n}\\r\\n\\r\\n#include\\r\\n\\r\\nvoid main() {\\r\\n\\r\\n#if NUM_CUTPLANES > 0\\r\\n checkCutPlanes(vWorldPosition);\\r\\n#endif\\r\\n\\r\\n gl_FragColor = vec4( vec3 ( 1.0 ), opacity );\\r\\n\\r\\n#ifdef USE_MAP\\r\\n vec4 texelColor = GET_MAP(vUv);\\r\\n#ifdef MAP_INVERT\\r\\n texelColor.xyz = 1.0-texelColor.xyz;\\r\\n#endif\\r\\n#ifdef GAMMA_INPUT\\r\\n texelColor.xyz *= texelColor.xyz;\\r\\n#endif\\r\\n gl_FragColor = gl_FragColor * texelColor;\\r\\n#endif\\r\\n\\r\\n#ifdef USE_ALPHAMAP\\r\\n vec4 texelAlpha = GET_ALPHAMAP(vUvAlpha);\\r\\n gl_FragColor.a *= texelAlpha.r;\\r\\n#endif\\r\\n\\r\\n#ifdef ALPHATEST\\r\\n if ( gl_FragColor.a < ALPHATEST ) discard;\\r\\n#endif\\r\\n\\r\\n float specularStrength;\\r\\n\\r\\n#ifdef USE_SPECULARMAP\\r\\n vec4 texelSpecular = GET_SPECULARMAP(vUv);\\r\\n specularStrength = texelSpecular.r;\\r\\n#else\\r\\n specularStrength = 1.0;\\r\\n#endif\\r\\n\\r\\n#ifndef FLAT_SHADED\\r\\n vec3 normal = normalize( vNormal );\\r\\n#ifdef DOUBLE_SIDED\\r\\n\\r\\n#endif\\r\\n#else\\r\\n vec3 fdx = dFdx( vViewPosition );\\r\\n vec3 fdy = dFdy( vViewPosition );\\r\\n vec3 normal = normalize( cross( fdx, fdy ) );\\r\\n#endif\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n vec3 viewDirection;\\r\\n if (projectionMatrix[3][3] == 0.0) {\\r\\n viewDirection = normalize( vViewPosition );\\r\\n } else {\\r\\n viewDirection = vec3(0.0, 0.0, 1.0);\\r\\n }\\r\\n normal = faceforward(normal, -viewDirection, normal);\\r\\n\\r\\n vec3 geomNormal = normal;\\r\\n\\r\\n#ifdef USE_NORMALMAP\\r\\n normal = perturbNormal2Arb( -vViewPosition, normal );\\r\\n#elif defined( USE_BUMPMAP )\\r\\n normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\\r\\n#endif\\r\\n\\r\\n vec3 totalDiffuse = vec3( 0.0 );\\r\\n vec3 totalSpecular = vec3( 0.0 );\\r\\n\\r\\n\\r\\n\\r\\n float shininessB = shininess * 4.0;\\r\\n\\r\\n#if MAX_POINT_LIGHTS > 0\\r\\n\\r\\n vec3 pointDiffuse = vec3( 0.0 );\\r\\n vec3 pointSpecular = vec3( 0.0 );\\r\\n\\r\\n for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\\r\\n\\r\\n vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\\r\\n vec3 lVector = lPosition.xyz + vViewPosition.xyz;\\r\\n\\r\\n float lDistance = 1.0;\\r\\n if ( pointLightDistance[ i ] > 0.0 )\\r\\n lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\\r\\n\\r\\n lVector = normalize( lVector );\\r\\n\\r\\n\\r\\n\\r\\n float dotProduct = dot( normal, lVector );\\r\\n\\r\\n float pointDiffuseWeight = max( dotProduct, 0.0 );\\r\\n\\r\\n\\r\\n pointDiffuse += InputToLinear(diffuse) * InputToLinear(pointLightColor[ i ]) * pointDiffuseWeight * lDistance;\\r\\n\\r\\n\\r\\n\\r\\n vec3 pointHalfVector = normalize( lVector + viewDirection );\\r\\n float pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\\r\\n\\r\\n float pointSpecularWeight = specularStrength * max( pow( pointDotNormalHalf, shininessB ), 0.0 );\\r\\n float specularNormalization = shininessB * 0.125 + 0.25;\\r\\n vec3 schlick = Schlick_v3(InputToLinear(specular), dot( lVector, pointHalfVector ) );\\r\\n pointSpecular += schlick * InputToLinear(pointLightColor[ i ]) * pointSpecularWeight * pointDiffuseWeight * lDistance * specularNormalization ;\\r\\n\\r\\n }\\r\\n\\r\\n totalDiffuse += pointDiffuse;\\r\\n totalSpecular += pointSpecular;\\r\\n\\r\\n#endif\\r\\n\\r\\n#if MAX_SPOT_LIGHTS > 0\\r\\n\\r\\n vec3 spotDiffuse = vec3( 0.0 );\\r\\n vec3 spotSpecular = vec3( 0.0 );\\r\\n\\r\\n for ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {\\r\\n\\r\\n vec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );\\r\\n vec3 lVector = lPosition.xyz + vViewPosition.xyz;\\r\\n\\r\\n float lDistance = 1.0;\\r\\n if ( spotLightDistance[ i ] > 0.0 )\\r\\n lDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );\\r\\n\\r\\n lVector = normalize( lVector );\\r\\n\\r\\n float spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - vWorldPosition ) );\\r\\n\\r\\n if ( spotEffect > spotLightAngleCos[ i ] ) {\\r\\n\\r\\n spotEffect = max( pow( spotEffect, spotLightExponent[ i ] ), 0.0 );\\r\\n\\r\\n\\r\\n\\r\\n float dotProduct = dot( normal, lVector );\\r\\n\\r\\n float spotDiffuseWeight = max( dotProduct, 0.0 );\\r\\n\\r\\n spotDiffuse += InputToLinear(diffuse) * InputToLinear(spotLightColor[ i ]) * spotDiffuseWeight * lDistance * spotEffect;\\r\\n\\r\\n\\r\\n\\r\\n vec3 spotHalfVector = normalize( lVector + viewDirection );\\r\\n float spotDotNormalHalf = max( dot( normal, spotHalfVector ), 0.0 );\\r\\n float spotSpecularWeight = specularStrength * max( pow( spotDotNormalHalf, shininessB ), 0.0 );\\r\\n\\r\\n float specularNormalization = shininessB * 0.125 + 0.25;\\r\\n vec3 schlick = Schlick_v3(InputToLinear(specular), dot( lVector, spotHalfVector ) );\\r\\n spotSpecular += schlick * InputToLinear(spotLightColor[ i ]) * spotSpecularWeight * spotDiffuseWeight * lDistance * specularNormalization * spotEffect;\\r\\n }\\r\\n\\r\\n }\\r\\n\\r\\n totalDiffuse += spotDiffuse;\\r\\n totalSpecular += spotSpecular;\\r\\n\\r\\n#endif\\r\\n\\r\\n#if MAX_DIR_LIGHTS > 0\\r\\n\\r\\n vec3 dirDiffuse = vec3( 0.0 );\\r\\n vec3 dirSpecular = vec3( 0.0 );\\r\\n\\r\\n for( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\\r\\n\\r\\n vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\\r\\n vec3 dirVector = normalize( lDirection.xyz );\\r\\n\\r\\n\\r\\n\\r\\n float dotProduct = dot( normal, dirVector );\\r\\n\\r\\n float dirDiffuseWeight = max( dotProduct, 0.0 );\\r\\n\\r\\n dirDiffuse += InputToLinear(diffuse) * InputToLinear(directionalLightColor[ i ]) * dirDiffuseWeight;\\r\\n\\r\\n\\r\\n\\r\\n vec3 dirHalfVector = normalize( dirVector + viewDirection );\\r\\n float dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\\r\\n float dirSpecularWeight = specularStrength * max( pow( dirDotNormalHalf, shininessB ), 0.0 );\\r\\n\\r\\n float specularNormalization = shininessB * 0.125 + 0.25;\\r\\n vec3 schlick = Schlick_v3(InputToLinear(specular), dot( dirVector, dirHalfVector ));\\r\\n\\r\\n dirSpecular += schlick * InputToLinear(directionalLightColor[ i ]) * dirSpecularWeight * dirDiffuseWeight * specularNormalization;\\r\\n\\r\\n }\\r\\n\\r\\n totalDiffuse += dirDiffuse;\\r\\n totalSpecular += dirSpecular;\\r\\n\\r\\n#endif\\r\\n\\r\\n\\r\\n\\r\\n#ifdef USE_IRRADIANCEMAP\\r\\n vec3 worldNormal = mat3(viewMatrixInverse) * normal;\\r\\n vec3 indirectDiffuse = sampleIrradianceMap(worldNormal, irradianceMap, envMapExposure);\\r\\n\\r\\n indirectDiffuse = applyEnvShadow(indirectDiffuse, worldNormal);\\r\\n\\r\\n totalDiffuse += InputToLinear(diffuse) * indirectDiffuse;\\r\\n#endif\\r\\n\\r\\n\\r\\n#ifdef METAL\\r\\n gl_FragColor.xyz = gl_FragColor.xyz * ( InputToLinear(emissive) + totalDiffuse + ambientLightColor * InputToLinear(diffuse) + totalSpecular );\\r\\n#else\\r\\n gl_FragColor.xyz = gl_FragColor.xyz * ( InputToLinear(emissive) + totalDiffuse + ambientLightColor * InputToLinear(diffuse) ) + totalSpecular;\\r\\n#endif\\r\\n\\r\\n\\r\\n\\r\\n#ifdef USE_COLOR\\r\\n gl_FragColor = gl_FragColor * vec4( vColor, 1.0 );\\r\\n#endif\\r\\n\\r\\n\\r\\n#if defined(USE_ENVMAP)\\r\\n\\r\\n vec3 reflectVec;\\r\\n\\r\\n#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\\r\\n\\r\\n#ifdef ENVMAP_MODE_REFLECTION\\r\\n reflectVec = reflect( -viewDirection, normal );\\r\\n#else \\r\\n reflectVec = refract( -viewDirection, normal, refractionRatio );\\r\\n#endif\\r\\n\\r\\n#else\\r\\n\\r\\n reflectVec = reflect( -viewDirection, normal );\\r\\n\\r\\n#endif\\r\\n\\r\\n reflectVec = mat3(viewMatrixInverse) * reflectVec;\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n float reflectScale = 1.0;\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n vec3 cubeColor = sampleReflection(reflectVec, reflMipIndex);\\r\\n\\r\\n cubeColor *= reflectScale;\\r\\n\\r\\n float facing = dot( viewDirection, normal );\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n if (facing < -1e-2)\\r\\n facing = 1.0;\\r\\n else\\r\\n facing = max(1e-6, facing);\\r\\n\\r\\n#ifdef USE_BUMPMAP\\r\\n\\r\\n\\r\\n\\r\\n facing = min(1.0, facing + bumpScale * 7.0);\\r\\n\\r\\n#endif\\r\\n\\r\\n vec3 schlickRefl;\\r\\n\\r\\n#ifdef METAL\\r\\n\\r\\n\\r\\n schlickRefl = InputToLinear(specular);\\r\\n\\r\\n#else\\r\\n\\r\\n\\r\\n schlickRefl = Schlick_v3(InputToLinear(specular), facing);\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n gl_FragColor.a = mix(gl_FragColor.a, Schlick_f(gl_FragColor.a, facing), reflectivity);\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n float invSchlick = pow(1.0 - facing * 0.5, 5.0);\\r\\n\\r\\n\\r\\n float norm_factor = (28.0 / 23.0) * (1.0 - invSchlick) * (1.0 - invSchlick);\\r\\n\\r\\n gl_FragColor.xyz *= norm_factor * (1.0 - InputToLinear(specular));\\r\\n\\r\\n#endif\\r\\n\\r\\n\\r\\n gl_FragColor.xyz += cubeColor.xyz * specularStrength * schlickRefl.xyz;\\r\\n\\r\\n#ifdef CLEARCOAT\\r\\n\\r\\n vec3 reflectVecClearcoat = reflect( -viewDirection, geomNormal );\\r\\n reflectVecClearcoat = mat3(viewMatrixInverse) * reflectVecClearcoat;\\r\\n\\r\\n vec3 cubeColorClearcoat = sampleReflection(reflectVecClearcoat, 0.0);\\r\\n\\r\\n\\r\\n float schlickClearcoat = Schlick_f(InputToLinear(reflectivity), facing);\\r\\n\\r\\n\\r\\n\\r\\n gl_FragColor.xyz = mix(gl_FragColor.xyz, cubeColorClearcoat * schlickClearcoat, 0.5);\\r\\n\\r\\n#endif\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n#endif\\r\\n\\r\\n#if TONEMAP_OUTPUT == 1\\r\\n gl_FragColor.xyz = toneMapCanonOGS_WithGamma_WithColorPerserving(exposureBias * gl_FragColor.xyz);\\r\\n#elif TONEMAP_OUTPUT == 2\\r\\n gl_FragColor.xyz = toneMapCanonFilmic_WithGamma( exposureBias * gl_FragColor.xyz );\\r\\n#endif\\r\\n\\r\\n\\r\\n\\r\\n#ifdef USE_FOG\\r\\n float depth = gl_FragCoord.z / gl_FragCoord.w;\\r\\n float fogFactor = smoothstep( fogNear, fogFar, depth );\\r\\n gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\\r\\n#endif\\r\\n#include\\r\\n#include\\r\\n\\r\\n}\\r\\n\";","module.exports = \"varying vec3 vViewPosition;\\n#ifndef FLAT_SHADED\\nvarying vec3 vNormal;\\n#endif\\n#if defined( USE_MAP ) || defined( USE_SPECULARMAP )\\nvarying vec2 vUv;\\nuniform mat3 texMatrix;\\n#endif\\n#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\\nvarying vec2 vUvBump;\\nuniform mat3 texMatrixBump;\\n#endif\\n#if defined( USE_ALPHAMAP )\\nvarying vec2 vUvAlpha;\\nuniform mat3 texMatrixAlpha;\\n#endif\\n#if defined( USE_ENVMAP )\\n#if ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP )\\nuniform float refractionRatio;\\n#endif\\n#endif\\n#if MAX_SPOT_LIGHTS > 0 || NUM_CUTPLANES > 0\\nvarying vec3 vWorldPosition;\\n#endif\\n#ifdef USE_COLOR\\nvarying vec3 vColor;\\n#endif\\n#ifdef MRT_NORMALS\\nvarying float depth;\\n#endif\\n#include\\n#include\\n#include\\n#include\\n#include\\nvoid main() {\\n#if defined( USE_MAP ) || defined( USE_SPECULARMAP )\\n vUv = (texMatrix * vec3(uv, 1.0)).xy;\\n#endif\\n#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\\n vUvBump = (texMatrixBump * vec3(uv, 1.0)).xy;\\n#endif\\n#if defined( USE_ALPHAMAP )\\n vUvAlpha = (texMatrixAlpha * vec3(uv, 1.0)).xy;\\n#endif\\n#ifdef USE_COLOR\\n#ifdef GAMMA_INPUT\\n vColor = color * color;\\n#else\\n vColor = color;\\n#endif\\n#endif\\n#ifdef UNPACK_NORMALS\\n vec3 objectNormal = decodeNormal(normal);\\n#else\\n vec3 objectNormal = normal;\\n#endif\\n#ifdef FLIP_SIDED\\n objectNormal = -objectNormal;\\n#endif\\n objectNormal = getInstanceNormal(objectNormal);\\n vec3 instPos = getInstancePos(position);\\n vec3 transformedNormal = normalMatrix * objectNormal;\\n#ifndef FLAT_SHADED\\n vNormal = normalize( transformedNormal );\\n#endif\\n vec4 mvPosition = modelViewMatrix * vec4( instPos, 1.0 );\\n gl_Position = projectionMatrix * mvPosition;\\n#include\\n vViewPosition = -mvPosition.xyz;\\n#if MAX_SPOT_LIGHTS > 0 || NUM_CUTPLANES > 0\\n vec4 worldPosition = modelMatrix * vec4( instPos, 1.0 );\\n vWorldPosition = worldPosition.xyz;\\n#endif\\n#ifdef MRT_NORMALS\\n depth = mvPosition.z;\\n#endif\\n#include\\n#include\\n}\\n\";","module.exports = \"\\n#define EDGE_SHARPNESS (3.0)\\n#define SCALE (2)\\n#define R (4)\\n#define VALUE_TYPE float\\n#define VALUE_COMPONENTS r\\n#define VALUE_IS_KEY 0\\n#define KEY_COMPONENTS gb\\n#if __VERSION__ >= 330\\nconst float gaussian[R + 1] =\\nfloat[](0.153170, 0.144893, 0.122649, 0.092902, 0.062970);\\n#endif\\nuniform sampler2D tDiffuse;\\nuniform vec2 size;\\nuniform vec2 resolution;\\nuniform vec2 axis;\\nuniform float radius;\\n#define result gl_FragColor.VALUE_COMPONENTS\\n#define keyPassThrough gl_FragColor.KEY_COMPONENTS\\nfloat unpackKey(vec2 p) {\\n return p.x + p.y * (1.0 / 255.0);\\n}\\nvarying vec2 vUv;\\nvoid main() {\\n# if __VERSION__ < 330\\n float gaussian[R + 1];\\n# if R == 3\\n gaussian[0] = 0.153170; gaussian[1] = 0.144893; gaussian[2] = 0.122649; gaussian[3] = 0.092902;\\n# elif R == 4\\n gaussian[0] = 0.153170; gaussian[1] = 0.144893; gaussian[2] = 0.122649; gaussian[3] = 0.092902; gaussian[4] = 0.062970;\\n# elif R == 6\\n gaussian[0] = 0.111220; gaussian[1] = 0.107798; gaussian[2] = 0.098151; gaussian[3] = 0.083953; gaussian[4] = 0.067458; gaussian[5] = 0.050920; gaussian[6] = 0.036108;\\n# endif\\n# endif\\n ivec2 axisi = ivec2(axis);\\n ivec2 ssC = ivec2(gl_FragCoord.xy);\\n vec4 temp = texture2D(tDiffuse, vUv);\\n gl_FragColor.gb = temp.KEY_COMPONENTS;\\n gl_FragColor.a = temp.a;\\n VALUE_TYPE sum = temp.VALUE_COMPONENTS;\\n if (temp.a == 0.0) {\\n result = sum;\\n return;\\n }\\n float key = unpackKey(keyPassThrough);\\n float BASE = gaussian[0];\\n float totalWeight = BASE;\\n sum *= totalWeight;\\n float scale = 1.5 / radius;\\n int r = -4; {\\n vec2 ssUV = vec2(ssC + axisi * (r * SCALE))*resolution;\\n temp = texture2D(tDiffuse, ssUV);\\n float tapKey = unpackKey(temp.KEY_COMPONENTS);\\n VALUE_TYPE value = temp.VALUE_COMPONENTS;\\n float weight = 0.3 + gaussian[4];\\n float dz = tapKey - key;\\n weight *= max(0.0, 1.0 - (EDGE_SHARPNESS * 2000.0) * abs(dz) * scale);\\n sum += value * weight;\\n totalWeight += weight;\\n }\\n r = -3; {\\n vec2 ssUV = vec2(ssC + axisi * (r * SCALE))*resolution;\\n temp = texture2D(tDiffuse, ssUV);\\n float tapKey = unpackKey(temp.KEY_COMPONENTS);\\n VALUE_TYPE value = temp.VALUE_COMPONENTS;\\n float weight = 0.3 + gaussian[3];\\n float dz = tapKey - key;\\n weight *= max(0.0, 1.0 - (EDGE_SHARPNESS * 2000.0) * abs(dz) * scale);\\n sum += value * weight;\\n totalWeight += weight;\\n }\\n r = -2; {\\n vec2 ssUV = vec2(ssC + axisi * (r * SCALE))*resolution;\\n temp = texture2D(tDiffuse, ssUV);\\n float tapKey = unpackKey(temp.KEY_COMPONENTS);\\n VALUE_TYPE value = temp.VALUE_COMPONENTS;\\n float weight = 0.3 + gaussian[2];\\n float dz = tapKey - key;\\n weight *= max(0.0, 1.0 - (EDGE_SHARPNESS * 2000.0) * abs(dz) * scale);\\n sum += value * weight;\\n totalWeight += weight;\\n }\\n r=-1; {\\n vec2 ssUV = vec2(ssC + axisi * (r * SCALE))*resolution;\\n temp = texture2D(tDiffuse, ssUV);\\n float tapKey = unpackKey(temp.KEY_COMPONENTS);\\n VALUE_TYPE value = temp.VALUE_COMPONENTS;\\n float weight = 0.3 + gaussian[1];\\n float dz = tapKey - key;\\n weight *= max(0.0, 1.0 - (EDGE_SHARPNESS * 2000.0) * abs(dz) * scale);\\n sum += value * weight;\\n totalWeight += weight;\\n }\\n r = 1; {\\n vec2 ssUV = vec2(ssC + axisi * (r * SCALE))*resolution;\\n temp = texture2D(tDiffuse, ssUV);\\n float tapKey = unpackKey(temp.KEY_COMPONENTS);\\n VALUE_TYPE value = temp.VALUE_COMPONENTS;\\n float weight = 0.3 + gaussian[1];\\n float dz = tapKey - key;\\n weight *= max(0.0, 1.0 - (EDGE_SHARPNESS * 2000.0) * abs(dz) * scale);\\n sum += value * weight;\\n totalWeight += weight;\\n }\\n r = 2; {\\n vec2 ssUV = vec2(ssC + axisi * (r * SCALE))*resolution;\\n temp = texture2D(tDiffuse, ssUV);\\n float tapKey = unpackKey(temp.KEY_COMPONENTS);\\n VALUE_TYPE value = temp.VALUE_COMPONENTS;\\n float weight = 0.3 + gaussian[2];\\n float dz = tapKey - key;\\n weight *= max(0.0, 1.0 - (EDGE_SHARPNESS * 2000.0) * abs(dz) * scale);\\n sum += value * weight;\\n totalWeight += weight;\\n }\\n r = 3; {\\n vec2 ssUV = vec2(ssC + axisi * (r * SCALE))*resolution;\\n temp = texture2D(tDiffuse, ssUV);\\n float tapKey = unpackKey(temp.KEY_COMPONENTS);\\n VALUE_TYPE value = temp.VALUE_COMPONENTS;\\n float weight = 0.3 + gaussian[3];\\n float dz = tapKey - key;\\n weight *= max(0.0, 1.0 - (EDGE_SHARPNESS * 2000.0) * abs(dz) * scale);\\n sum += value * weight;\\n totalWeight += weight;\\n }\\n r = 4; {\\n vec2 ssUV = vec2(ssC + axisi * (r * SCALE))*resolution;\\n temp = texture2D(tDiffuse, ssUV);\\n float tapKey = unpackKey(temp.KEY_COMPONENTS);\\n VALUE_TYPE value = temp.VALUE_COMPONENTS;\\n float weight = 0.3 + gaussian[4];\\n float dz = tapKey - key;\\n weight *= max(0.0, 1.0 - (EDGE_SHARPNESS * 2000.0) * abs(dz) * scale);\\n sum += value * weight;\\n totalWeight += weight;\\n }\\n const float epsilon = 0.0001;\\n result = sum / (totalWeight + epsilon);\\n}\\n\";","module.exports = \"\\n#include \\n#define USE_MIPMAP 1\\nuniform float cameraNear;\\nuniform float cameraFar;\\nuniform vec2 size;\\nuniform vec2 resolution;\\nuniform float lumInfluence;\\nvarying vec2 vUv;\\n#define NUM_SAMPLES (17)\\n#define LOG_MAX_OFFSET (3)\\n#define MAX_MIP_LEVEL (5)\\n#define NUM_SPIRAL_TURNS (5)\\n#define MIN_RADIUS (3.0)\\nuniform float projScale;\\n#ifdef USE_MIPMAP\\nuniform sampler2D tDepth_mip1;\\nuniform sampler2D tDepth_mip2;\\nuniform sampler2D tDepth_mip3;\\nuniform sampler2D tDepth_mip4;\\nuniform sampler2D tDepth_mip5;\\n#endif\\nuniform float radius;\\nuniform float bias;\\nuniform float intensity;\\nvec2 tapLocation(int sampleNumber, float spinAngle, out float ssR){\\n float alpha = float(float(sampleNumber) + 0.5) * (1.0 / float(NUM_SAMPLES));\\n float angle = alpha * (float(NUM_SPIRAL_TURNS) * 6.28) + spinAngle;\\n ssR = alpha;\\n return vec2(cos(angle), sin(angle));\\n}\\nfloat CSZToKey(float z) {\\n return clamp( (z+cameraNear) / (cameraNear-cameraFar), 0.0, 1.0);\\n}\\nvoid packKey(float key, out vec2 p) {\\n float temp = floor(key * 255.0);\\n p.x = temp * (1.0 / 255.0);\\n p.y = key * 255.0 - temp;\\n}\\n#include \\nfloat unpackDepthNearFar( const in vec4 rgba_depth ) {\\n float depth = unpackDepth( rgba_depth );\\n if (depth == 0.0)\\n return -cameraFar * 1.0e10;\\n return depth * (cameraNear - cameraFar) - cameraNear;\\n}\\nvec3 reconstructCSFaceNormal(vec3 C) {\\n return normalize(cross(dFdy(C), dFdx(C)));\\n}\\nvec3 reconstructNonUnitCSFaceNormal(vec3 C) {\\n return cross(dFdy(C), dFdx(C));\\n}\\nvec3 getPosition(ivec2 ssP, float depth) {\\n vec3 P;\\n P = reconstructCSPosition(vec2(ssP) + vec2(0.5), depth);\\n return P;\\n}\\nvec3 getOffsetPosition(ivec2 ssC, vec2 unitOffset, float ssR) {\\n ivec2 ssP = ivec2(ssR * unitOffset) + ssC;\\n vec3 P;\\n vec2 screenUV = (vec2(ssP) + vec2(0.5)) * resolution;\\n#ifdef USE_MIPMAP\\n int mipLevel = int(max(0.0, min(floor(log2(ssR)) - float(LOG_MAX_OFFSET), float(MAX_MIP_LEVEL))));\\n if (mipLevel == 0) {\\n P.z = texture2D(tDepth, screenUV).z;\\n if (P.z == 0.0) P.z = -cameraFar * 1.0e10;\\n }\\n else if (mipLevel == 1)\\n P.z = unpackDepthNearFar(texture2D(tDepth_mip1, screenUV));\\n else if (mipLevel == 2)\\n P.z = unpackDepthNearFar(texture2D(tDepth_mip2, screenUV));\\n else if (mipLevel == 3)\\n P.z = unpackDepthNearFar(texture2D(tDepth_mip3, screenUV));\\n else if (mipLevel == 4)\\n P.z = unpackDepthNearFar(texture2D(tDepth_mip4, screenUV));\\n else if (mipLevel == 5)\\n P.z = unpackDepthNearFar(texture2D(tDepth_mip5, screenUV));\\n#else\\n P.z = texture2D(tDepth, screenUV).z;\\n if (P.z == 0.0) P.z = -cameraFar * 1.0e10;\\n#endif\\n P = reconstructCSPosition(vec2(ssP) + vec2(0.5), P.z);\\n return P;\\n}\\nfloat sampleAO(in ivec2 ssC, in vec3 C, in vec3 n_C, in float ssDiskRadius, in int tapIndex, in float randomPatternRotationAngle) {\\n float ssR;\\n vec2 unitOffset = tapLocation(tapIndex, randomPatternRotationAngle, ssR);\\n ssR = max(0.75, ssR * ssDiskRadius);\\n vec3 Q = getOffsetPosition(ssC, unitOffset, ssR);\\n vec3 v = Q - C;\\n float vv = dot(v, v);\\n float vn = dot(v, n_C);\\n const float epsilon = 0.001;\\n float angAdjust = mix(1.0, max(0.0, 1.5 * n_C.z), 0.35);\\n#define HIGH_QUALITY\\n#ifdef HIGH_QUALITY\\n float f = max(1.0 - vv / (radius * radius), 0.0); return angAdjust * f * max((vn - bias) / sqrt(epsilon + vv), 0.0);\\n#else\\n float f = max(radius * radius - vv, 0.0); return angAdjust * f * f * f * max((vn - bias) / (epsilon + vv), 0.0);\\n#endif\\n}\\nconst bool useNoise = true;\\nfloat getRandomAngle(vec2 pos) {\\n float dt= dot(pos ,vec2(12.9898,78.233));\\n return 6.28318 * fract(sin(mod(dt,3.14)) * 43758.5453);\\n}\\nvoid main() {\\n ivec2 ssC = ivec2(gl_FragCoord.xy);\\n vec4 nrmz = texture2D(tDepth, vUv);\\n if (nrmz.z == 0.0) {\\n gl_FragColor.r = 1.0;\\n gl_FragColor.a = 0.0;\\n packKey(1.0, gl_FragColor.gb);\\n return;\\n }\\n vec3 C = getPosition(ssC, nrmz.z);\\n packKey(CSZToKey(C.z), gl_FragColor.gb);\\n float ssDiskRadius = -projScale * radius / mix(C.z, -1.0, isOrtho);\\n float A;\\n if (ssDiskRadius <= MIN_RADIUS) {\\n A = 1.0;\\n } else {\\n float sum = 0.0;\\n float randomPatternRotationAngle = getRandomAngle(vUv);\\n vec3 n_C = vec3(nrmz.x, nrmz.y, sqrt(1.0 - dot(nrmz.xy, nrmz.xy)));\\n sum += sampleAO(ssC, C, n_C, ssDiskRadius, 0, randomPatternRotationAngle);\\n sum += sampleAO(ssC, C, n_C, ssDiskRadius, 1, randomPatternRotationAngle);\\n sum += sampleAO(ssC, C, n_C, ssDiskRadius, 2, randomPatternRotationAngle);\\n sum += sampleAO(ssC, C, n_C, ssDiskRadius, 3, randomPatternRotationAngle);\\n sum += sampleAO(ssC, C, n_C, ssDiskRadius, 4, randomPatternRotationAngle);\\n sum += sampleAO(ssC, C, n_C, ssDiskRadius, 5, randomPatternRotationAngle);\\n sum += sampleAO(ssC, C, n_C, ssDiskRadius, 6, randomPatternRotationAngle);\\n sum += sampleAO(ssC, C, n_C, ssDiskRadius, 7, randomPatternRotationAngle);\\n sum += sampleAO(ssC, C, n_C, ssDiskRadius, 8, randomPatternRotationAngle);\\n sum += sampleAO(ssC, C, n_C, ssDiskRadius, 9, randomPatternRotationAngle);\\n sum += sampleAO(ssC, C, n_C, ssDiskRadius, 10, randomPatternRotationAngle);\\n sum += sampleAO(ssC, C, n_C, ssDiskRadius, 11, randomPatternRotationAngle);\\n sum += sampleAO(ssC, C, n_C, ssDiskRadius, 12, randomPatternRotationAngle);\\n sum += sampleAO(ssC, C, n_C, ssDiskRadius, 13, randomPatternRotationAngle);\\n sum += sampleAO(ssC, C, n_C, ssDiskRadius, 14, randomPatternRotationAngle);\\n sum += sampleAO(ssC, C, n_C, ssDiskRadius, 15, randomPatternRotationAngle);\\n sum += sampleAO(ssC, C, n_C, ssDiskRadius, 16, randomPatternRotationAngle);\\n float intensityDivR6 = intensity / pow(radius, 6.0);\\n#ifdef HIGH_QUALITY\\n A = pow(max(0.0, 1.0 - sqrt(sum * (3.0 / float(NUM_SAMPLES)))), intensity);\\n#else\\n A = max(0.0, 1.0 - sum * intensityDivR6 * (5.0 / float(NUM_SAMPLES)));\\n A = (pow(A, 0.2) + 1.2 * A*A*A*A) / 2.2;\\n#endif\\n if (abs(dFdx(C.z)) < 0.02) {\\n A -= dFdx(A) * (mod(float(ssC.x), 2.0) - 0.5);\\n }\\n if (abs(dFdy(C.z)) < 0.02) {\\n A -= dFdy(A) * (mod(float(ssC.y), 2.0) - 0.5);\\n }\\n A = mix(1.0, A, clamp(ssDiskRadius - MIN_RADIUS,0.0,1.0));\\n }\\n gl_FragColor.r = A;\\n gl_FragColor.a = 1.0;\\n}\\n\";","module.exports = \"uniform sampler2D tDiffuse;\\nuniform vec2 resolution;\\nvoid main() {\\n vec2 ssP = vec2(gl_FragCoord.xy);\\n ssP = ssP * 2.0 + mod(ssP, 2.0);\\n ssP = (ssP + 0.5) * resolution * 0.5;\\n gl_FragColor = texture2D(tDiffuse, ssP);\\n}\\n\";","module.exports = \"uniform sampler2D tDiffuse;\\nuniform vec2 resolution;\\nuniform float cameraNear;\\nuniform float cameraInvNearFar;\\n#include \\nvoid main() {\\n vec2 ssP = vec2(gl_FragCoord.xy);\\n ssP = ssP * 2.0 + mod(ssP, 2.0);\\n ssP = (ssP + 0.5) * resolution * 0.5;\\n float depth = texture2D(tDiffuse, ssP).z;\\n if (depth != 0.0)\\n depth = (depth + cameraNear) * cameraInvNearFar;\\n gl_FragColor = packDepth(depth);\\n}\\n\";","module.exports = \"varying vec2 vUv;\\nvoid main() {\\n vUv = uv;\\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\\n}\\n\";","module.exports = \"\\nvoid main() {\\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\\n}\\n\";","module.exports = \"#include\\nvarying float depth;\\n#ifdef USE_SURFACE_CUTOUT_MAP\\n#include\\n#prism_uniforms\\nvarying vec2 vUv;\\n#else\\n#ifdef USE_MAP\\nvarying vec2 vUv;\\nuniform sampler2D map;\\n#endif\\n#ifdef USE_ALPHAMAP\\nvarying vec2 vUvAlpha;\\nuniform sampler2D alphaMap;\\n#endif\\n#endif\\nuniform float shadowMinOpacity;\\nvoid applyCutoutMaps() {\\n float opacity = 1.0;\\n#ifdef USE_SURFACE_CUTOUT_MAP\\n#prism_sample_texture\\n#else\\n#ifdef USE_MAP\\n opacity *= GET_MAP(vUv).a;\\n#endif\\n#ifdef USE_ALPHAMAP\\n opacity *= GET_ALPHAMAP(vUvAlpha).r;\\n#endif\\n#endif\\n#if defined(USE_SURFACE_CUTOUT_MAP) || defined(USE_MAP) || defined(USE_ALPHAMAP)\\n if (opacity < shadowMinOpacity) discard;\\n#endif\\n}\\nvoid main() {\\n float normalizedLinearDepth = (depth - shadowMapRangeMin) / shadowMapRangeSize;\\n float val = exp(shadowESMConstant * normalizedLinearDepth);\\n#ifdef USE_HARD_SHADOWS\\n val = normalizedLinearDepth;\\n#endif\\n applyCutoutMaps();\\n gl_FragColor = vec4(val, 0, 0, 1);\\n}\\n\";","module.exports = \"#include\\nvoid main() {\\n float shadowIntensity = 0.5 * (1.0 - getShadowValue());\\n gl_FragColor = vec4(0.0, 0.0, 0.0, shadowIntensity);\\n}\\n\";","module.exports = \"#include\\nvoid main() {\\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\\n#include\\n}\\n\";","module.exports = \"#include\\nvarying float depth;\\n#ifdef USE_SURFACE_CUTOUT_MAP\\nvarying vec2 vUv;\\n#else\\n#ifdef USE_MAP\\nvarying vec2 vUv;\\nuniform mat3 texMatrix;\\n#endif\\n#ifdef USE_ALPHAMAP\\nvarying vec2 vUvAlpha;\\nuniform mat3 texMatrixAlpha;\\n#endif\\n#endif\\nvoid passCutoutUVCoords() {\\n#ifdef USE_SURFACE_CUTOUT_MAP\\n vUv = uv;\\n#else\\n#ifdef USE_MAP\\n vUv = (texMatrix * vec3(uv, 1.0)).xy;\\n#endif\\n#ifdef USE_ALPHAMAP\\n vUvAlpha = (texMatrixAlpha * vec3(uv, 1.0)).xy;\\n#endif\\n#endif\\n}\\nvoid main() {\\n vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\\n vec4 p_Position = projectionMatrix * mvPosition;\\n gl_Position = p_Position;\\n depth = -mvPosition.z;\\n passCutoutUVCoords();\\n}\\n\";","module.exports = \"#include\\nuniform sampler2D sheetMap;\\nuniform sampler2D idMap;\\nuniform vec2 resolution;\\nuniform vec3 modelIDv2;\\nuniform float alphaTest;\\nvoid main() {\\n vec2 uv = vec2(gl_FragCoord.x * resolution.x, gl_FragCoord.y * resolution.y);\\n vec4 c = texture2D(sheetMap, uv);\\n if (c.a <= alphaTest)\\n discard;\\n \\n gl_FragColor = c;\\n vec4 dbId = texture2D(idMap, uv);\\n#ifdef MRT_NORMALS\\n outNormal = vec4(0.0, 0.0, 0.0, 1.0);\\n#endif\\n#ifdef MRT_ID_BUFFER\\n outId = vec4(dbId.rgb, 1.0);\\n #ifdef MODEL_COLOR\\n outModelId = vec4(modelIDv2.rgb, 1.0);\\n #endif\\n#elif defined(ID_COLOR)\\n gl_FragColor = vec4(dbId.rgb, 1.0);\\n#elif defined(MODEL_COLOR)\\n gl_FragColor = vec4(modelIDv2.rgb, 1.0);\\n#endif\\n}\\n\";","module.exports = \"void main() {\\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\\n}\";","/**\n * BVH definitions:\n *\n * BVH Node: if this was C (the only real programming language), it would go something like this,\n * but with better alignment.\n *\n * This is definition for \"fat\" nodes (for rasterization),\n * i.e. when inner nodes also contain primitives.\n * struct Node { byte/short/int offset\n * float worldBox[6]; //world box of the node node 0/0/0\n * int leftChildIndex; //pointer to left child node (right is left+1) 24/12/6\n * ushort primCount; //how many fragments are at this node 28/14/7\n * ushort flags; //bitfield of good stuff 30/15/7.5\n *\n * int primStart; //start of node's own primitives (fragments) list 32/16/8\n * };\n * => sizeof(Node) = 36 bytes\n\n * Definition for lean nodes (for ray casting): when a node is either inner node (just children, no primitives)\n * or leaf (just primitives, no children).\n * struct Node {\n * float worldBox[6]; //world box of the node\n * union {\n * int leftChildIndex; //pointer to left child node (right is left+1)\n * int primStart; //start of node's own primitives (fragments) list\n * };\n * ushort primCount; //how many fragments are at this node\n * ushort flags; //bitfield of good stuff\n * };\n * => sizeof(Node) = 32 bytes\n *\n * The class below encapsulates an array of such nodes using ArrayBuffer as backing store.\n *\n * @param {ArrayBuffer|number} initialData Initial content of the NodeArray, or initial allocation of empty nodes\n * @param {boolean} useLeanNode Use minimal node structure size. Currently this parameter must be set to false.\n * @constructor\n */\nexport function NodeArray(initialData, useLeanNode) {\n 'use strict';\n\n if (useLeanNode) {\n this.bytes_per_node = 32;\n } else {\n this.bytes_per_node = 36;\n }\n\n var initialCount;\n var initialBuffer;\n\n if (initialData instanceof ArrayBuffer) {\n initialCount = initialData.byteLength / this.bytes_per_node;\n initialBuffer = initialData;\n this.nodeCount = initialCount;\n } else\n {\n initialCount = initialData | 0;\n initialBuffer = new ArrayBuffer(this.bytes_per_node * initialCount);\n this.nodeCount = 0;\n }\n\n this.nodeCapacity = initialCount;\n this.nodesRaw = initialBuffer;\n\n this.is_lean_node = useLeanNode;\n this.node_stride = this.bytes_per_node / 4;\n this.node_stride_short = this.bytes_per_node / 2;\n\n //Allocate memory buffer for all tree nodes\n this.nodesF = new Float32Array(this.nodesRaw);\n this.nodesI = new Int32Array(this.nodesRaw);\n this.nodesS = new Uint16Array(this.nodesRaw);\n}\n\nNodeArray.prototype.setLeftChild = function (nodeidx, childidx) {\n this.nodesI[nodeidx * this.node_stride + 6] = childidx;\n};\nNodeArray.prototype.getLeftChild = function (nodeidx) {\n return this.nodesI[nodeidx * this.node_stride + 6];\n};\n\nNodeArray.prototype.setPrimStart = function (nodeidx, start) {\n if (this.is_lean_node)\n this.nodesI[nodeidx * this.node_stride + 6] = start;else\n\n this.nodesI[nodeidx * this.node_stride + 8] = start;\n};\nNodeArray.prototype.getPrimStart = function (nodeidx) {\n if (this.is_lean_node)\n return this.nodesI[nodeidx * this.node_stride + 6];else\n\n return this.nodesI[nodeidx * this.node_stride + 8];\n};\n\nNodeArray.prototype.setPrimCount = function (nodeidx, count) {\n this.nodesS[nodeidx * this.node_stride_short + 14] = count;\n};\nNodeArray.prototype.getPrimCount = function (nodeidx) {\n return this.nodesS[nodeidx * this.node_stride_short + 14];\n};\n\nNodeArray.prototype.setFlags = function (nodeidx, axis, isFirst, isTransparent) {\n this.nodesS[nodeidx * this.node_stride_short + 15] = isTransparent << 3 | isFirst << 2 | axis & 0x3;\n};\nNodeArray.prototype.getFlags = function (nodeidx) {\n return this.nodesS[nodeidx * this.node_stride_short + 15];\n};\n\nNodeArray.prototype.setBox0 = function (nodeidx, src) {\n var off = nodeidx * this.node_stride;\n var dst = this.nodesF;\n dst[off] = src[0];\n dst[off + 1] = src[1];\n dst[off + 2] = src[2];\n dst[off + 3] = src[3];\n dst[off + 4] = src[4];\n dst[off + 5] = src[5];\n};\nNodeArray.prototype.getBoxThree = function (nodeidx, dst) {\n var off = nodeidx * this.node_stride;\n var src = this.nodesF;\n dst.min.x = src[off];\n dst.min.y = src[off + 1];\n dst.min.z = src[off + 2];\n dst.max.x = src[off + 3];\n dst.max.y = src[off + 4];\n dst.max.z = src[off + 5];\n};\nNodeArray.prototype.getBoxArray = function (nodeidx, dst, offset) {\n var off = nodeidx * this.node_stride;\n var src = this.nodesF;\n offset = offset || 0;\n dst[0 + offset] = src[off];\n dst[1 + offset] = src[off + 1];\n dst[2 + offset] = src[off + 2];\n dst[3 + offset] = src[off + 3];\n dst[4 + offset] = src[off + 4];\n dst[5 + offset] = src[off + 5];\n};\nNodeArray.prototype.setBoxThree = function (nodeidx, src) {\n var off = nodeidx * this.node_stride;\n var dst = this.nodesF;\n dst[off] = src.min.x;\n dst[off + 1] = src.min.y;\n dst[off + 2] = src.min.z;\n dst[off + 3] = src.max.x;\n dst[off + 4] = src.max.y;\n dst[off + 5] = src.max.z;\n};\n\n\n\n\nNodeArray.prototype.makeEmpty = function (nodeidx) {\n\n var off = nodeidx * this.node_stride;\n var dst = this.nodesI;\n\n //No point to makeEmpty here, because the box gets set\n //directly when the node is initialized in bvh_subdivide.\n //box_make_empty(this.nodesF, off);\n\n //_this.setLeftChild(nodeidx,-1);\n dst[off + 6] = -1;\n\n //both prim count and flags to 0\n dst[off + 7] = 0;\n\n //_this.setPrimStart(nodeidx, -1);\n if (!this.is_lean_node)\n dst[off + 8] = -1;\n\n};\n\nNodeArray.prototype.realloc = function (extraSize) {\n if (this.nodeCount + extraSize > this.nodeCapacity) {\n var nsz = 0 | this.nodeCapacity * 3 / 2;\n if (nsz < this.nodeCount + extraSize)\n nsz = this.nodeCount + extraSize;\n\n var nnodes = new ArrayBuffer(nsz * this.bytes_per_node);\n var nnodesI = new Int32Array(nnodes);\n nnodesI.set(this.nodesI);\n\n this.nodeCapacity = nsz;\n this.nodesRaw = nnodes;\n this.nodesF = new Float32Array(nnodes);\n this.nodesI = nnodesI;\n this.nodesS = new Uint16Array(nnodes);\n }\n};\n\nNodeArray.prototype.nextNodes = function (howMany) {\n\n this.realloc(howMany);\n\n var res = this.nodeCount;\n this.nodeCount += howMany;\n\n for (var i = 0; i < howMany; i++) {\n this.makeEmpty(res + i);\n }\n\n return res;\n};\n\nNodeArray.prototype.getRawData = function () {\n return this.nodesRaw.slice(0, this.nodeCount * this.bytes_per_node);\n};\n\nvar POINT_STRIDE = 3;\nvar BOX_EPSILON = 1e-5;\nvar BOX_SCALE_EPSILON = 1e-5;\nvar MAX_DEPTH = 15; /* max tree depth */\nvar MAX_BINS = 16;\n\n/**\n * Bounding Volume Hierarchy build algorithm.\n * Uses top down binning -- see \"On fast Construction of SAH-based Bounding Volume Hierarchies\" by I.Wald\n * Ported from the C version here: https://git.autodesk.com/stanevt/t-ray/blob/master/render3d/t-ray/t-core/t-bvh.c\n * Optimized for JavaScript.\n */\nvar BVHModule = function () {\n //There be dragons in this closure.\n\n \"use strict\";\n\n\n /**\n * Utilities for manipulating bounding boxes stored\n * in external array (as sextuplets of float32)\n */\n\n\n function box_get_centroid(dst, dst_off, src, src_off) {\n dst[dst_off] = 0.5 * (src[src_off] + src[src_off + 3]);\n dst[dst_off + 1] = 0.5 * (src[src_off + 1] + src[src_off + 4]);\n dst[dst_off + 2] = 0.5 * (src[src_off + 2] + src[src_off + 5]);\n }\n\n function box_add_point_0(dst, src, src_off) {\n\n if (dst[0] > src[src_off]) dst[0] = src[src_off];\n if (dst[3] < src[src_off]) dst[3] = src[src_off];\n\n if (dst[1] > src[src_off + 1]) dst[1] = src[src_off + 1];\n if (dst[4] < src[src_off + 1]) dst[4] = src[src_off + 1];\n\n if (dst[2] > src[src_off + 2]) dst[2] = src[src_off + 2];\n if (dst[5] < src[src_off + 2]) dst[5] = src[src_off + 2];\n\n }\n\n function box_add_box_0(dst, src, src_off) {\n\n if (dst[0] > src[src_off]) dst[0] = src[src_off];\n if (dst[1] > src[src_off + 1]) dst[1] = src[src_off + 1];\n if (dst[2] > src[src_off + 2]) dst[2] = src[src_off + 2];\n\n if (dst[3] < src[src_off + 3]) dst[3] = src[src_off + 3];\n if (dst[4] < src[src_off + 4]) dst[4] = src[src_off + 4];\n if (dst[5] < src[src_off + 5]) dst[5] = src[src_off + 5];\n }\n\n function box_add_box_00(dst, src) {\n if (dst[0] > src[0]) dst[0] = src[0];\n if (dst[1] > src[1]) dst[1] = src[1];\n if (dst[2] > src[2]) dst[2] = src[2];\n\n if (dst[3] < src[3]) dst[3] = src[3];\n if (dst[4] < src[4]) dst[4] = src[4];\n if (dst[5] < src[5]) dst[5] = src[5];\n }\n\n function box_get_size(dst, dst_off, src, src_off) {\n for (var i = 0; i < 3; i++) {\n dst[dst_off + i] = src[src_off + 3 + i] - src[src_off + i];\n }\n }\n\n //function box_copy(dst, dst_off, src, src_off) {\n // for (var i=0; i<6; i++) {\n // dst[dst_off+i] = src[src_off+i];\n // }\n //}\n\n // unwound version of box_copy\n function box_copy_00(dst, src) {\n dst[0] = src[0];\n dst[1] = src[1];\n dst[2] = src[2];\n dst[3] = src[3];\n dst[4] = src[4];\n dst[5] = src[5];\n }\n\n var dbl_max = Infinity;\n\n //function box_make_empty(dst, dst_off) {\n // dst[dst_off] = dbl_max;\n // dst[dst_off+1] = dbl_max;\n // dst[dst_off+2] = dbl_max;\n // dst[dst_off+3] = -dbl_max;\n // dst[dst_off+4] = -dbl_max;\n // dst[dst_off+5] = -dbl_max;\n //}\n\n function box_make_empty_0(dst) {\n dst[0] = dbl_max;\n dst[1] = dbl_max;\n dst[2] = dbl_max;\n dst[3] = -dbl_max;\n dst[4] = -dbl_max;\n dst[5] = -dbl_max;\n }\n\n function box_area(src, src_off) {\n\n var dx = src[src_off + 3] - src[src_off];\n var dy = src[src_off + 4] - src[src_off + 1];\n var dz = src[src_off + 5] - src[src_off + 2];\n\n if (dx < 0 || dy < 0 || dz < 0)\n return 0;\n\n return 2.0 * (dx * dy + dy * dz + dz * dx);\n }\n\n function box_area_0(src) {\n\n var dx = src[3] - src[0];\n var dy = src[4] - src[1];\n var dz = src[5] - src[2];\n\n if (dx < 0 || dy < 0 || dz < 0)\n return 0;\n\n return 2.0 * (dx * dy + dy * dz + dz * dx);\n }\n\n\n\n\n\n function bvh_split_info() {\n this.vb_left = new Float32Array(6);\n this.vb_right = new Float32Array(6);\n this.cb_left = new Float32Array(6);\n this.cb_right = new Float32Array(6);\n this.num_left = 0;\n this.best_split = -1;\n this.best_cost = -1;\n this.num_bins = -1;\n }\n\n bvh_split_info.prototype.reset = function () {\n this.num_left = 0;\n this.best_split = -1;\n this.best_cost = -1;\n this.num_bins = -1;\n };\n\n\n function bvh_bin() {\n this.box_bbox = new Float32Array(6); // bbox of all primitive bboxes\n this.box_centroid = new Float32Array(6); // bbox of all primitive centroids\n this.num_prims = 0; // number of primitives in the bin\n }\n\n bvh_bin.prototype.reset = function () {\n this.num_prims = 0; // number of primitives in the bin\n box_make_empty_0(this.box_bbox);\n box_make_empty_0(this.box_centroid);\n };\n\n function accum_bin_info() {\n this.BL = new Float32Array(6);\n this.CL = new Float32Array(6);\n this.NL = 0;\n this.AL = 0;\n }\n\n accum_bin_info.prototype.reset = function () {\n this.NL = 0;\n this.AL = 0;\n\n box_make_empty_0(this.BL);\n box_make_empty_0(this.CL);\n };\n\n\n //Scratch variables used by bvh_bin_axis\n //TODO: can be replaced by a flat ArrayBuffer\n var bins = [];\n var i;\n for (i = 0; i < MAX_BINS; i++) {\n bins.push(new bvh_bin());\n }\n\n //TODO: can be replaced by a flat ArrayBuffer\n var ai = [];\n for (i = 0; i < MAX_BINS - 1; i++) {\n ai.push(new accum_bin_info());}\n\n var BR = new Float32Array(6);\n var CR = new Float32Array(6);\n\n\n function assign_bins(bvh, start, end, axis, cb, cbdiag, num_bins) {\n\n var centroids = bvh.centroids;\n var primitives = bvh.primitives;\n var boxes = bvh.finfo.boxes;\n var boxStride = bvh.finfo.boxStride;\n\n /* bin assignment */\n var k1 = num_bins * (1.0 - BOX_SCALE_EPSILON) / cbdiag[axis];\n var cbaxis = cb[axis];\n var sp = bvh.sort_prims;\n\n for (var j = start; j <= end; j++)\n {\n /* map array index to primitive index -- since primitive index array gets reordered by the BVH build*/\n /* while the primitive info array is not reordered */\n var iprim = primitives[j] | 0;\n\n var fpbin = k1 * (centroids[iprim * 3 /*POINT_STRIDE*/ + axis] - cbaxis);\n var binid = fpbin | 0; //Truncate to int is algorithmic -> not an optimization thing!\n\n /* possible floating point problems */\n if (binid < 0)\n {\n binid = 0;\n //debug(\"Bin index out of range \" + fpbin);\n } else\n if (binid >= num_bins)\n {\n binid = num_bins - 1;\n //debug(\"Bin index out of range. \" + fpbin);\n }\n\n /* Store the bin index for the partitioning step, so we don't recompute it there */\n sp[j] = binid;\n\n /* update other bin data with the new primitive */\n //var bin = bins[binid];\n bins[binid].num_prims++;\n\n box_add_box_0(bins[binid].box_bbox, boxes, iprim * boxStride);\n box_add_point_0(bins[binid].box_centroid, centroids, iprim * 3 /*POINT_STRIDE*/);\n }\n /* at this point all primitves are assigned to a bin */\n }\n\n\n function bvh_bin_axis(bvh, start, end, axis, cb, cbdiag, split_info) {\n\n /* if size is near 0 on this axis, cost of split is infinite */\n if (cbdiag[axis] < bvh.scene_epsilon)\n {\n split_info.best_cost = Infinity;\n return;\n }\n\n var num_bins = MAX_BINS;\n if (num_bins > end - start + 1)\n num_bins = end - start + 1;\n\n var i;\n for (i = 0; i < num_bins; i++) {\n bins[i].reset();}\n\n for (i = 0; i < num_bins - 1; i++) {\n ai[i].reset();}\n\n split_info.num_bins = num_bins;\n\n assign_bins(bvh, start, end, axis, cb, cbdiag, num_bins);\n\n\n /* now do the accumulation sweep from left to right */\n box_copy_00(ai[0].BL, bins[0].box_bbox);\n box_copy_00(ai[0].CL, bins[0].box_centroid);\n ai[0].AL = box_area_0(ai[0].BL);\n ai[0].NL = bins[0].num_prims;\n var bin;\n for (i = 1; i < num_bins - 1; i++)\n {\n bin = bins[i];\n var aii = ai[i];\n box_copy_00(aii.BL, ai[i - 1].BL);\n box_add_box_00(aii.BL, bin.box_bbox);\n aii.AL = box_area_0(aii.BL);\n\n box_copy_00(aii.CL, ai[i - 1].CL);\n box_add_box_00(aii.CL, bin.box_centroid);\n\n aii.NL = ai[i - 1].NL + bin.num_prims;\n }\n\n /* sweep from right to left, keeping track of lowest cost and split */\n i = num_bins - 1;\n box_copy_00(BR, bins[i].box_bbox);\n box_copy_00(CR, bins[i].box_centroid);\n var AR = box_area_0(BR);\n var NR = bins[i].num_prims;\n\n var best_split = i;\n var best_cost = AR * NR + ai[i - 1].AL * ai[i - 1].NL;\n box_copy_00(split_info.vb_right, BR);\n box_copy_00(split_info.cb_right, bins[i].box_centroid);\n box_copy_00(split_info.vb_left, ai[i - 1].BL);\n box_copy_00(split_info.cb_left, ai[i - 1].CL);\n split_info.num_left = ai[i - 1].NL;\n\n for (i = i - 1; i >= 1; i--)\n {\n bin = bins[i];\n box_add_box_00(BR, bin.box_bbox);\n box_add_box_00(CR, bin.box_centroid);\n AR = box_area_0(BR);\n NR += bin.num_prims;\n\n var cur_cost = AR * NR + ai[i - 1].AL * ai[i - 1].NL;\n\n if (cur_cost <= best_cost)\n {\n best_cost = cur_cost;\n best_split = i;\n\n box_copy_00(split_info.vb_right, BR);\n box_copy_00(split_info.cb_right, CR);\n box_copy_00(split_info.vb_left, ai[i - 1].BL);\n box_copy_00(split_info.cb_left, ai[i - 1].CL);\n split_info.num_left = ai[i - 1].NL;\n }\n }\n\n split_info.best_split = best_split;\n split_info.best_cost = best_cost;\n }\n\n function bvh_partition(bvh, start, end, axis, cb, cbdiag, split_info) {\n\n //At this point, the original algorithm does an in-place NON-STABLE partition\n //to move primitives to the left and right sides of the split plane\n //into contiguous location of the primitives list for use by\n //the child nodes. But, we want to preserve the ordering by size\n //without having to do another sort, so we have to use\n //a temporary storage location to copy into. We place right-side primitives\n //in temporary storage, then copy back into the original storage in the right order.\n //Left-side primitives are still put directly into the destination location.\n var primitives = bvh.primitives;\n //var centroids = bvh.centroids;\n var i, j;\n\n //sort_prims contains bin indices computed during the split step.\n //Here we read those and also use sort_prims as temporary holding\n //of primitive indices. Hopefully the read happens before the write. :)\n //In C it was cheap enough to compute this again...\n //var k1 = split_info.num_bins * (1.0 - BOX_SCALE_EPSILON) / cbdiag[axis];\n //var cbaxis = cb[axis];\n var sp = bvh.sort_prims;\n\n var right = 0;\n var left = start | 0;\n var best_split = split_info.best_split | 0;\n\n for (i = start; i <= end; i++) {\n var iprim = primitives[i] | 0;\n //var fpbin = (k1 * (centroids[3/*POINT_STRIDE*/ * iprim + axis] - cbaxis));\n var binid = sp[i]; /* fpbin|0; */\n\n if (binid < best_split) {\n primitives[left++] = iprim;\n } else {\n sp[right++] = iprim;\n }\n }\n\n //if ((left-start) != split_info.num_left)\n // debug(\"Mismatch between binning and partitioning.\");\n\n //Copy back the right-side primitives into main primitives array, while\n //maintaining order\n for (j = 0; j < right; j++) {\n primitives[left + j] = sp[j];\n }\n /* at this point the binning is complete and we have computed a split */\n }\n\n\n function bvh_fatten_inner_node(bvh, nodes, nodeidx, start, end, cb, cbdiag, poly_cut_off) {\n\n var primitives = bvh.primitives;\n var centroids = bvh.centroids;\n\n //Take the first few items to place into the inner node,\n //but do not go over the max item or polygon count.\n var prim_count = end - start + 1;\n\n if (prim_count > bvh.frags_per_inner_node)\n prim_count = bvh.frags_per_inner_node;\n\n if (prim_count > poly_cut_off)\n prim_count = poly_cut_off;\n\n\n nodes.setPrimStart(nodeidx, start);\n nodes.setPrimCount(nodeidx, prim_count);\n start += prim_count;\n\n //Because we take some primitives off the input, we have to recompute\n //the bounding box used for computing the node split.\n box_make_empty_0(cb);\n for (var i = start; i <= end; i++) {\n box_add_point_0(cb, centroids, 3 /*POINT_STRIDE*/ * primitives[i]);\n }\n\n //Also update the split axis -- it could possibly change too.\n box_get_size(cbdiag, 0, cb, 0);\n //Decide which axis to split on. Done purely by longest.\n var axis = 0;\n if (cbdiag[1] > cbdiag[0])\n axis = 1;\n if (cbdiag[2] > cbdiag[axis])\n axis = 2;\n\n return axis;\n }\n\n\n var cbdiag = new Float32Array(3); //scratch variable used in bvh_subdivide\n\n function bvh_subdivide(bvh,\n nodeidx, /* current parent node to consider splitting */\n start, end, /* primitive sub-range to be considered at this recursion step */\n vb, /* bounding volume of the primitives' bounds in the sub-range */\n cb, /* bounding box of primitive centroids in this range */\n transparent, /* does the node contain opaque or transparent objects */\n depth /* recursion depth */)\n\n {\n box_get_size(cbdiag, 0, cb, 0);\n var nodes = bvh.nodes;\n var frags_per_leaf = transparent ? bvh.frags_per_leaf_node_transparent : bvh.frags_per_leaf_node;\n var frags_per_inner = transparent ? bvh.frags_per_inner_node_transparent : bvh.frags_per_inner_node;\n var polys_per_node = bvh.max_polys_per_node;\n\n //Decide which axis to split on.\n var axis = 0;\n if (cbdiag[1] > cbdiag[0])\n axis = 1;\n if (cbdiag[2] > cbdiag[axis])\n axis = 2;\n\n //Whether the node gets split or not, it gets\n //the same overall bounding box.\n nodes.setBox0(nodeidx, vb);\n\n //Check the expected polygon count of the node. This figures out the maximum number of fragments\n // we can put at the node as determined by polys_per_node\n var poly_count = 0;\n var poly_cut_off = 0;\n var prim_count = end - start + 1;\n\n // If we have the number of triangles in each mesh, limit the number of primitives in an inner node.\n if (bvh.finfo.hasPolygonCounts && bvh.frags_per_inner_node) {\n // Walk through primitives, add up the counts until we reach polys_per_node (10000), or run through\n // frags_per_inner_node (usually 32).\n // We know that later on we'll limit the number to frags_per_inner_node, so also do it here.\n var shorten_end = prim_count <= bvh.frags_per_inner_node ? end : start + bvh.frags_per_inner_node - 1;\n for (var i = start; i <= shorten_end; i++) {\n poly_count += bvh.finfo.getPolygonCount(bvh.primitives[i]);\n poly_cut_off++;\n if (poly_count > polys_per_node)\n break;\n }\n }\n\n var isSmall = prim_count <= frags_per_leaf && poly_count < polys_per_node ||\n prim_count === 1;\n\n //Decide whether to terminate recursion\n if (isSmall ||\n depth > MAX_DEPTH || //max recursion depth\n cbdiag[axis] < bvh.scene_epsilon) //node would be way too tiny for math to make sense (a point)\n {\n nodes.setLeftChild(nodeidx, -1);\n nodes.setPrimStart(nodeidx, start);\n nodes.setPrimCount(nodeidx, end - start + 1);\n nodes.setFlags(nodeidx, 0, 0, transparent ? 1 : 0);\n return;\n }\n\n //Pick the largest (first) primitives to live in this node\n //NOTE: this assumes primitives are sorted by size.\n //NOTE: This step is an optional departure from the original, and we also do a check for it above\n // to compute poly_cut_off.\n if (frags_per_inner) {\n axis = bvh_fatten_inner_node(bvh, nodes, nodeidx, start, end, cb, cbdiag, poly_cut_off);\n start = start + nodes.getPrimCount(nodeidx);\n }\n\n var split_info = new bvh_split_info();\n\n //Do the binning of the remaining primitives to go into child nodes\n bvh_bin_axis(bvh, start, end, axis, cb, cbdiag, split_info);\n\n if (split_info.num_bins < 0) {\n //Split was too costly, so add all objects to the current node and bail\n nodes.setPrimCount(nodeidx, nodes.getPrimCount(nodeidx) + end - start + 1);\n return;\n }\n\n bvh_partition(bvh, start, end, axis, cb, cbdiag, split_info);\n\n var child_idx = nodes.nextNodes(2);\n\n /* set info about split into the node */\n var cleft = (split_info.vb_left[3 + axis] + split_info.vb_left[axis]) * 0.5;\n var cright = (split_info.vb_right[3 + axis] + split_info.vb_right[axis]) * 0.5;\n\n nodes.setFlags(nodeidx, axis, cleft < cright ? 0 : 1, transparent ? 1 : 0);\n nodes.setLeftChild(nodeidx, child_idx);\n\n\n /* validate split */\n /*\n if (true) {\n for (var i=start; i< start+num_left; i++)\n {\n //int binid = (int)(k1 * (info->prim_info[info->bvh->iprims[i]].centroid.v[axis] - cb->min.v[axis]));\n var cen = primitives[i] * POINT_STRIDE;\n if ( centroids[cen] < split_info.cb_left[0]\n || centroids[cen] > split_info.cb_left[3]\n || centroids[cen+1] < split_info.cb_left[1]\n || centroids[cen+1] > split_info.cb_left[4]\n || centroids[cen+2] < split_info.cb_left[2]\n || centroids[cen+2] > split_info.cb_left[5])\n {\n debug (\"wrong centroid box\");\n }\n }\n for (i=start+num_left; i<=end; i++)\n {\n //int binid = (int)(k1 * (info->prim_info[info->bvh->iprims[i]].centroid.v[axis] - cb->min.v[axis]));\n var cen = primitives[i] * POINT_STRIDE;\n if ( centroids[cen] < split_info.cb_right[0]\n || centroids[cen] > split_info.cb_right[3]\n || centroids[cen+1] < split_info.cb_right[1]\n || centroids[cen+1] > split_info.cb_right[4]\n || centroids[cen+2] < split_info.cb_right[2]\n || centroids[cen+2] > split_info.cb_right[5])\n {\n debug (\"wrong centroid box\");\n }\n }\n }\n */\n\n\n /* recurse */\n //bvh_subdivide(bvh, child_idx, start, start + split_info.num_left - 1, split_info.vb_left, split_info.cb_left, transparent, depth+1);\n //bvh_subdivide(bvh, child_idx + 1, start + split_info.num_left, end, split_info.vb_right, split_info.cb_right, transparent, depth+1);\n\n //Iterative stack-based recursion for easier profiling\n bvh.recursion_stack.push([bvh, child_idx + 1, start + split_info.num_left, end, split_info.vb_right, split_info.cb_right, transparent, depth + 1]);\n bvh.recursion_stack.push([bvh, child_idx, start, start + split_info.num_left - 1, split_info.vb_left, split_info.cb_left, transparent, depth + 1]);\n\n }\n\n\n function compute_boxes(bvh) {\n\n var boxv_o = bvh.boxv_o;\n var boxc_o = bvh.boxc_o;\n var boxv_t = bvh.boxv_t;\n var boxc_t = bvh.boxc_t;\n\n box_make_empty_0(boxv_o);\n box_make_empty_0(boxc_o);\n box_make_empty_0(boxv_t);\n box_make_empty_0(boxc_t);\n\n var c = bvh.centroids;\n var b = bvh.finfo.boxes;\n var boxStride = bvh.finfo.boxStride;\n\n for (var i = 0, iEnd = bvh.prim_count; i < iEnd; i++) {\n\n // find which primitive in the sorted list to use next\n var p = bvh.primitives[i];\n box_get_centroid(c, 3 /*POINT_STRIDE*/ * p, b, boxStride * p);\n\n if (i >= bvh.first_transparent) {\n\n box_add_point_0(boxc_t, c, 3 /*POINT_STRIDE*/ * p);\n box_add_box_0(boxv_t, b, boxStride * p);\n\n } else {\n\n box_add_point_0(boxc_o, c, 3 /*POINT_STRIDE*/ * p);\n box_add_box_0(boxv_o, b, boxStride * p);\n\n }\n }\n\n box_get_size(cbdiag, 0, bvh.boxv_o, 0);\n var maxsz = Math.max(cbdiag[0], cbdiag[1], cbdiag[2]);\n bvh.scene_epsilon = BOX_EPSILON * maxsz;\n }\n\n\n\n\n //Module exports\n return {\n bvh_subdivide: bvh_subdivide,\n compute_boxes: compute_boxes,\n box_area: box_area };\n\n\n}();\n\n\nfunction FragInfo(fragments, materialDefs) {\n //Invariants\n this.boxes = fragments.boxes; //Array of Float32, each bbox is a sextuplet\n this.polygonCounts = fragments.polygonCounts;\n this.hasPolygonCounts = !!this.polygonCounts;\n this.materials = fragments.materials; //material indices (we need to know which fragments are transparent)\n this.materialDefs = materialDefs;\n this.count = fragments.length;\n this.boxStride = 6;\n this.wantSort = true;\n}\n\nFragInfo.prototype.getCount = function () {\n return this.count;\n};\n\nFragInfo.prototype.isTransparent = function (i) {\n return this.materialDefs && this.materialDefs[this.materials[i]] ? this.materialDefs[this.materials[i]].transparent : false;\n};\n\nFragInfo.prototype.getPolygonCount = function (i) {\n return this.polygonCounts[i];\n};\n\n/**\n * Given a list of LMV fragments, builds a spatial index for view-dependent traversal and hit testing.\n * @constructor\n */\nexport function BVHBuilder(fragments, materialDefs, finfo) {\n\n //Initialize the inputs (bboxes, transparent flags, polygon counts)\n this.finfo = finfo || new FragInfo(fragments, materialDefs);\n\n this.prim_count = this.finfo.getCount();\n\n //To be initialized by build() function based on build options\n this.frags_per_leaf_node = -1;\n this.frags_per_inner_node = -1;\n this.nodes = null;\n\n this.work_buf = new ArrayBuffer(this.prim_count * 4);\n this.sort_prims = new Int32Array(this.work_buf);\n\n //Allocate memory buffer for re-ordered fragment primitive indices,\n //which will be sorted by node ownership and point to the index\n //of the fragment data.\n this.primitives = new Int32Array(this.prim_count);\n\n //The BVH split algorithm works based on centroids of the bboxes.\n this.centroids = new Float32Array(POINT_STRIDE * this.prim_count);\n\n //BBoxes and centroid bboxes for opaque and transparent primitive sets\n this.boxv_o = new Float32Array(6);\n this.boxc_o = new Float32Array(6);\n this.boxv_t = new Float32Array(6);\n this.boxc_t = new Float32Array(6);\n\n\n this.recursion_stack = [];\n}\n\nBVHBuilder.prototype.sortPrimitives = function (wantSort) {\n\n var prim_sizes = new Float32Array(this.work_buf);\n var primitives = this.primitives;\n var numTransparent = 0;\n\n //Sort the input objects by size\n //We assume all LMV SVF files come\n //sorted by draw priority already, so in theory we can skip this step.\n //This turns out to not be the case - some fragments are badly sorted.\n //Part of the reason may be that the surface area of the geometry itself,\n //not its bounding box, is used to sort by physical size in LMVTK.\n //In any case, the transparent objects do not always come last (bug in LMVTK?),\n //so we still have to pull them out to the end of the list, so some sorting\n //takes place no matter how this value is set.\n // Turning this option on will mean that the BVH building process as a whole\n // will be 45% to 75% longer, for large models - full sorting takes awhile.\n // In absolute terms this is an increase of a maximum of 1.15 seconds for a\n // very large model (one with over 1 million fragments, i.e., mesh instances).\n // This cost may be acceptable. For smaller models - \"only\" 70K instances -\n // the cost is 0.05 seconds. For 130k instances, 0.1 seconds. The rise is\n // slightly more than linear, but not excessively slow. I think it's acceptable,\n // given that the cost is still much less than loading even a small part of the\n // model.\n var doSort = wantSort;\n\n // console.log(\"BVH sort is \" + WANT_SORT);\n\n var i, iEnd;\n for (i = 0, iEnd = this.prim_count; i < iEnd; i++) {\n\n //Start with trivial 1:1 order of the indices array\n primitives[i] = i;\n\n var transparent = this.finfo.isTransparent(i);\n\n if (transparent)\n numTransparent++;\n\n if (doSort) {\n prim_sizes[i] = BVHModule.box_area(this.finfo.boxes, this.finfo.boxStride * i);\n\n //In order to make transparent objects appear last,\n //we give them a negative size, so that they are naturally\n //sorted last in the sort by size.\n if (transparent)\n prim_sizes[i] = -prim_sizes[i];\n } else {\n //We still need the transparency flag for the loop below\n //where we find the last opaque item, but we can\n //short-cut the size computation.\n prim_sizes[i] = transparent ? -1 : 1;\n }\n }\n\n\n if (doSort) {\n Array.prototype.sort.call(this.primitives, function (a, b) {\n return prim_sizes[b] - prim_sizes[a];\n });\n } else {\n if (numTransparent && numTransparent < this.prim_count) {\n\n var tmpTransparent = new Int32Array(numTransparent);\n var oidx = 0,tidx = 0;\n\n for (i = 0, iEnd = this.prim_count; i < iEnd; i++) {\n if (prim_sizes[i] >= 0)\n primitives[oidx++] = primitives[i];else\n\n tmpTransparent[tidx++] = primitives[i];\n }\n\n primitives.set(tmpTransparent, this.prim_count - numTransparent);\n }\n }\n\n this.first_transparent = this.prim_count - numTransparent;\n};\n\n\nBVHBuilder.prototype.build = function (options) {\n //Kick off the BVH build.\n\n var useSlimNodes = options && !!options.useSlimNodes;\n\n var self = this;\n function assign_option(name, defaultVal) {\n if (options.hasOwnProperty(name))\n self[name] = options[name];else\n\n self[name] = defaultVal;\n }\n\n // note: frags_per_leaf_node does *not* make an upper limit for the number of frags per node.\n\n //options for build optimized for rasterization renderer scenes\n if (useSlimNodes) {\n assign_option(\"frags_per_leaf_node\", 1);\n assign_option(\"frags_per_inner_node\", 0);\n assign_option(\"frags_per_leaf_node_transparent\", 1);\n assign_option(\"frags_per_inner_node_transparent\", 0);\n assign_option(\"max_polys_per_node\", Infinity);\n } else {\n var multiplier = options.isWeakDevice ? 0.5 : 1.0;\n\n //TODO: tune these constants\n assign_option(\"frags_per_leaf_node\", 0 | 256 * multiplier);\n //Placing fragments at inner nodes places more emphasis on bigger objects during tree traversal\n //but it can only be done for opaque objects. Transparent objects have to be strictly back to front\n //traversal regardless of size, unless a unified traversal\n assign_option(\"frags_per_inner_node\", 0 | this.frags_per_leaf_node);\n assign_option(\"frags_per_leaf_node_transparent\", this.frags_per_leaf_node);\n assign_option(\"frags_per_inner_node_transparent\", 0);\n assign_option(\"max_polys_per_node\", 0 | 20000 * multiplier);\n }\n\n //Reuse existing node array if there\n if (this.nodes && this.nodes.is_lean_node == useSlimNodes)\n this.nodes.nodeCount = 0;else\n {\n var est_nodes = this.prim_count / this.frags_per_leaf_node;\n var num_nodes = 1;\n while (num_nodes < est_nodes) {\n num_nodes *= 2;}\n\n this.nodes = new NodeArray(num_nodes, options ? options.useSlimNodes : false);\n }\n\n this.sortPrimitives(this.finfo.wantSort);\n\n BVHModule.compute_boxes(this);\n\n //Init the root nodes at 0 for opaque\n //and 1 for transparent objects\n var root = this.nodes.nextNodes(2);\n\n //Now kick off the recursive tree build\n\n //Opaque\n BVHModule.bvh_subdivide(this, root, 0, this.first_transparent - 1, this.boxv_o, this.boxc_o, false, 0);\n\n var a;\n while (this.recursion_stack.length) {\n a = this.recursion_stack.pop();\n BVHModule.bvh_subdivide(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7]);\n }\n\n //Transparent\n BVHModule.bvh_subdivide(this, root + 1, this.first_transparent, this.prim_count - 1, this.boxv_t, this.boxc_t, true, 0);\n\n while (this.recursion_stack.length) {\n a = this.recursion_stack.pop();\n BVHModule.bvh_subdivide(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7]);\n }\n};","import * as globals from \"../globals.js\";\nimport { isNodeJS } from \"../../compat\";\nimport * as THREE from \"three\";\nimport { logger } from \"../../logger/Logger\";\n\n//Finds a precanned BufferAttribute corresponding to the given\n//attribute data, so that we don't have to allocate the same exact\n//one over and over and over.\nvar bufattrs = {};\n\nfunction findBufferAttribute(attributeName, attributeData, numInstances) {\n\n //Note .array could be undefined in case we are using\n //an interleaved buffer.\n var attr;\n if (attributeData.array) {\n attr = new THREE.BufferAttribute(attributeData.array, attributeData.itemSize);\n } else\n {\n var id = attributeName + \"|\" +\n attributeData.bytesPerItem + \"|\" +\n attributeData.normalize + \"|\" +\n attributeData.isPattern + \"|\" +\n attributeData.divisor + \"|\" +\n attributeData.offset;\n\n attr = bufattrs[id];\n if (attr)\n return attr;\n\n attr = new THREE.BufferAttribute(undefined, attributeData.itemSize);\n bufattrs[id] = attr;\n }\n\n attr.bytesPerItem = attributeData.bytesPerItem;\n attr.normalize = attributeData.normalize;\n attr.isPattern = attributeData.isPattern;\n\n if (numInstances) {\n attr.divisor = attributeData.divisor;\n }\n\n if (attributeData.array) {\n //Is the data for the attribute specified separately\n //from the interleaved VB?\n } else\n if (attributeData.hasOwnProperty(\"offset\")) {\n //If the attribute is in the interleaved VB, it has\n //an offset into it.\n attr.itemOffset = attributeData.offset;\n } else\n {\n logger.warn(\"VB attribute is neither interleaved nor separate. Something is wrong with the buffer specificaiton.\");\n }\n\n return attr;\n}\n\nvar attrKeys = {};\n\nfunction findAttributesKeys(geometry) {\n var key = \"\";\n\n for (var p in geometry.attributes) {\n key += p + \"|\";}\n\n var res = attrKeys[key];\n if (res)\n return res;\n\n res = Object.keys(geometry.attributes);\n attrKeys[key] = res;\n\n return res;\n}\n\n\nvar indexAttr16;\nvar indexAttr32;\nvar BufferGeometry;\nvar idcounter = 1;\n\nfunction initBufferGeometry() {\n\n indexAttr16 = new THREE.BufferAttribute(undefined, 1);\n indexAttr16.bytesPerItem = 2;\n\n indexAttr32 = new THREE.BufferAttribute(undefined, 1);\n indexAttr32.bytesPerItem = 4;\n\n BufferGeometry = function BufferGeometry() {\n\n //Avoid calling the superclass constructor for performance reasons.\n //Skips the creation of a uuid and defining an accessor for the .id property.\n //THREE.BufferGeometry.call(this);\n\n this.id = idcounter++;\n\n this.attributes = {};\n\n //These are properly initialized by meshToGeometr.\n /*\r\n this.uuid = null;\r\n this.name = null;\r\n \r\n this.drawcalls = [];\r\n this.offsets = this.drawcalls; // backwards compatibility\r\n \r\n this.boundingBox = null;\r\n this.boundingSphere = null;\r\n \r\n this.numInstances = undefined;\r\n this.streamingDraw = false;\r\n this.streamingIndex = false;\r\n this.svfid = undefined;\r\n \r\n this.vb = null;\r\n this.vbbuffer = undefined;\r\n this.ib = null;\r\n this.ibbuffer = undefined;\r\n this.iblines = null;\r\n this.iblinesbuffer = undefined;\r\n this.vaos = undefined;\r\n \r\n this.vbNeedsUpdate = false;\r\n this.vbstride = 0;\r\n this.byteSize = 0;\r\n \r\n this.attributesKeys = undefined;\r\n */\n // Note:\n // 1. Although __webglInit would also be undefined without this assignment, it is still essential\n // for performance reasons, because it makes this property known to the JIT compiler. Otherwise,\n // it would be attached to each buffer later in WebGLRenderer - which would waste performance.\n // 2. It is essential to use \"undefined\" and not \"false\" here. The reason is that WebGLRenderer\n // only checks in the form \"__webglInit === undefined\", i.e., setting it to \"false\" here would have\n // the same effect like setting it to \"true\" and would finally cause a memory leak.\n this.__webglInit = undefined;\n };\n\n BufferGeometry.prototype = Object.create(THREE.BufferGeometry.prototype);\n BufferGeometry.prototype.constructor = BufferGeometry;\n\n}\n\nexport function createBufferGeometry() {\n if (!BufferGeometry)\n initBufferGeometry();\n\n return new BufferGeometry();\n}\n\n//Converts a mesh description passed back from worker threads into a renderable three.js\n//compatible BufferGeometry.\n//Sets various extra flags we need.\nexport function meshToGeometry(mdata) {\n\n var mesh = mdata.mesh;\n var geometry = createBufferGeometry();\n\n if (isNodeJS()) {\n //Used by SVF post-processing tools\n geometry.packId = mdata.packId;\n geometry.meshIndex = mdata.meshIndex;\n }\n\n geometry.byteSize = 0;\n\n geometry.vb = mesh.vb;\n geometry.vbbuffer = undefined;\n geometry.vbNeedsUpdate = true;\n geometry.byteSize += mesh.vb.byteLength;\n geometry.hash = mdata.hash;\n\n geometry.vbstride = mesh.vbstride;\n if (mesh.isLines) /* mesh is SVF lines */\n geometry.isLines = mesh.isLines;\n if (mesh.isWideLines) {/* mesh is SVF wide lines */\n geometry.isWideLines = true;\n geometry.lineWidth = mesh.lineWidth;\n }\n if (mesh.isPoints) {/* mesh is SVF points */\n geometry.isPoints = mesh.isPoints;\n geometry.pointSize = mesh.pointSize;\n }\n if (mdata.is2d) /* mesh is from F2D */{\n geometry.is2d = true;\n }\n\n geometry.numInstances = mesh.numInstances;\n\n for (var attributeName in mesh.vblayout) {\n var attributeData = mesh.vblayout[attributeName];\n\n //geometry.addAttribute(attributeName, findBufferAttribute(attributeData, geometry.numInstances));\n geometry.attributes[attributeName] = findBufferAttribute(attributeName, attributeData, geometry.numInstances);\n }\n\n //Index buffer setup\n if (!globals.memoryOptimizedLoading) {\n var iAttr = new THREE.BufferAttribute(mesh.indices, 1);\n iAttr.bytesPerItem = mesh.indices instanceof Uint32Array ? 4 : 2;\n geometry.addAttribute(\"index\", iAttr);\n } else {\n\n geometry.attributes.index = mesh.indices instanceof Uint32Array ? indexAttr32 : indexAttr16;\n geometry.ib = mesh.indices;\n geometry.ibbuffer = undefined;\n\n if (mesh.iblines) {\n geometry.attributes.indexlines = mesh.iblines instanceof Uint32Array ? indexAttr32 : indexAttr16;\n geometry.iblines = mesh.iblines;\n geometry.iblinesbuffer = undefined;\n }\n }\n\n geometry.attributesKeys = findAttributesKeys(geometry);\n\n geometry.byteSize += mesh.indices.byteLength;\n\n //TODO: Not sure chunking into list of smaller offset/counts\n //is required for LMV data since it's already broken up.\n //if (mesh.indices.length > 65535)\n // Works fine now. Left in for debugging.\n //if (mesh.vb.length / mesh.vbstride > 65535)\n // logger.warn(\"Mesh with \" + (mesh.vb.length / mesh.vbstride) + \" > 65535 vertices. It will fail to draw.\");\n\n //TODO: This is a transient object that gets freed once the geometry\n //is added to the GeometryList. We can save on the object creation\n //eventually when we do micro optimizations.\n geometry.boundingBox = new THREE.Box3().copy(mesh.boundingBox);\n geometry.boundingSphere = new THREE.Sphere().copy(mesh.boundingSphere);\n\n //MEM\n /*\r\n geometry.drawcalls = null;\r\n geometry.offsets = null;\r\n */\n\n mdata.geometry = geometry;\n\n mdata.mesh = null;\n}\n\nexport var BufferGeometryUtils = {\n meshToGeometry: meshToGeometry,\n createBufferGeometry: createBufferGeometry,\n findBufferAttribute: findBufferAttribute };","import { getVertexCount, enumMeshTriangles, enumMeshVertices } from './VertexEnumerator';\nimport { LmvVector3 } from './LmvVector3';\nimport { LmvBox3 } from './LmvBox3';\n\n\n//It's important for this function to remain outside the closure of remapVertices.\n//Otherwise V8 will try to JIT optimize it for every mesh, which make things very slow.\nfunction getVertexIndex(v, i, uniqueV, SCALE, remap) {\n var x = 0 | v.x * SCALE;\n var y = 0 | v.y * SCALE;\n var z = 0 | v.z * SCALE;\n\n var mx = uniqueV[x];\n if (!mx) {\n uniqueV[x] = mx = {};\n }\n\n var my = mx[y];\n if (!my) {\n mx[y] = my = {};\n }\n\n var mz = my[z];\n if (mz === undefined) {\n my[z] = mz = i;\n }\n\n remap[i] = mz;\n}\n\n\nfunction remapVertices(geom, boundingBox) {\n //de-duplicate vertices based on position only (ignoring normals)\n\n var remap = [];\n var uniqueV = {};\n\n var boxScale = 1.0;\n if (geom.boundingBox || boundingBox) {\n var bbox = new LmvBox3().copy(geom.boundingBox || boundingBox);\n var sz = bbox.size();\n boxScale = Math.max(sz.x, Math.max(sz.y, sz.z));\n }\n\n var SCALE = (1 << 16) / boxScale; //snap scale, assuming unit mesh\n\n function remapcb(v, n, uv, i) {\n getVertexIndex(v, i, uniqueV, SCALE, remap);\n }\n\n enumMeshVertices(geom, remapcb);\n\n return remap;\n}\n\n\nfunction transformVertices(geom, toWorld) {\n\n var vbuf = new Float32Array(3 * getVertexCount(geom));\n\n function cb(v, n, uv, i) {\n vbuf[3 * i] = v.x;\n vbuf[3 * i + 1] = v.y;\n vbuf[3 * i + 2] = v.z;\n }\n\n enumMeshVertices(geom, cb, toWorld);\n\n return vbuf;\n}\n\nexport function createWireframe(geom, toWorld, boundingBox, wantAllTriangleEdges) {\n\n if (geom.isLines)\n return;\n\n if (geom.iblines)\n return;\n\n //find unique vertices\n var remap = remapVertices(geom, boundingBox);\n\n //get vertices in world space -- we need this for\n //correct angle calculations\n var worldVerts = transformVertices(geom, toWorld);\n\n //loop over all triangles, keeping track of\n //edges that seem important\n var seenEdges = {};\n\n var edgeIB = [];\n\n var _v1 = new LmvVector3();\n var _v2 = new LmvVector3();\n var _v3 = new LmvVector3();\n var _n1 = new LmvVector3();\n var _n2 = new LmvVector3();\n\n function getV(i, v) {\n v.x = worldVerts[3 * i];\n v.y = worldVerts[3 * i + 1];\n v.z = worldVerts[3 * i + 2];\n }\n\n function getNormal(i1, i2, i3, n) {\n getV(i1, _v1);\n getV(i2, _v2);\n getV(i3, _v3);\n\n _v2.sub(_v1);\n _v3.sub(_v1);\n _v2.cross(_v3);\n\n n.copy(_v2).normalize();\n }\n\n function doOneEdge(i1orig, i2orig, opp1orig) {\n\n var i1 = remap[i1orig];\n var i2 = remap[i2orig];\n var opp1 = remap[opp1orig];\n\n //Ignore degenerates\n if (i1 === i2 || i1 === opp1 || i2 === opp1)\n return;\n\n var reversed = false;\n if (i1 > i2) {\n var tmp = i1;\n i1 = i2;\n i2 = tmp;\n reversed = true;\n }\n\n var e1 = seenEdges[i1];\n if (e1) {\n var opp2orig = e1[i2];\n if (opp2orig === undefined) {\n e1[i2] = reversed ? -opp1orig - 1 : opp1orig;\n } else {\n //We now know two triangles that share this edge,\n //we can check if it's important\n\n if (!wantAllTriangleEdges) {\n //Use original indices, so that we\n //can do the math with the correct winding order\n getNormal(i1orig, i2orig, opp1orig, _n1);\n\n if (opp2orig < 0) {\n getNormal(i2, i1, remap[-opp2orig - 1], _n2);\n } else {\n getNormal(i1, i2, remap[opp2orig], _n2);\n }\n\n var dot = _n1.dot(_n2);\n\n if (Math.abs(dot) < 0.25) {\n edgeIB.push(i1orig);\n edgeIB.push(i2orig);\n }\n } else {\n edgeIB.push(i1orig);\n edgeIB.push(i2orig);\n }\n\n delete e1[i2];\n }\n } else {\n seenEdges[i1] = {};\n seenEdges[i1][i2] = opp1orig;\n }\n }\n\n function tricb(vA, vB, vC, iA, iB, iC) {\n doOneEdge(iA, iB, iC);\n doOneEdge(iB, iC, iA);\n doOneEdge(iC, iA, iB);\n }\n\n //find edges that have neighboring triangles at sharp angle\n enumMeshTriangles(geom, tricb);\n\n //process remaining edges (outer edges that only have one triangle)\n\n for (var i1 in seenEdges) {\n for (var i2 in seenEdges[i1]) {\n edgeIB.push(parseInt(i1));\n edgeIB.push(parseInt(i2));\n }\n }\n\n\n if (edgeIB.length > 1) {\n geom.iblines = new Uint16Array(edgeIB.length);\n geom.iblines.set(edgeIB);\n }\n\n /*\n for (var i=0; i 0;\n if (this.isFixedSize) {\n this.boxes = this.fragments.boxes; // Float32Array, stores Boxes as 6 floats per fragment (after applying mesh matrix)\n this.transforms = this.fragments.transforms; // Float32Array, stores transforms as 12 floats per fragment (Matrix4 with omitted last row)\n this.useThreeMesh = !memoryOptimizedLoading;\n } else {\n this.boxes = null;\n this.transforms = null;\n this.useThreeMesh = true; //This code path will be used for 2D drawings, which stream in with unknown number of meshes\n }\n\n // initial length for arrays of meshes/geometries/flags\n // Can be zero.\n var initialSize = this.fragments.length;\n\n this.vizflags = new Uint16Array(initialSize); // visibility/highlight mode flags\n\n //This will be the list of all mesh instances in the model.\n //Corresponds to all fragments in the case of SVF.\n if (this.useThreeMesh)\n this.vizmeshes = new Array(initialSize);\n\n if (model.isOTG()) {\n var stats = model.getData().metadata.stats;\n var nm = stats.num_materials;\n var ng = stats.num_geoms;\n\n this.materialids = allocateUintArray(initialSize, nm);\n this.geomids = allocateUintArray(initialSize, ng);\n } else {\n this.geomids = new Int32Array(initialSize); // geomid per fragId. geomids are resolved by this.geoms.GetGeometry(geomid) to obtain BufferGeometry.\n this.materialids = new Int32Array(initialSize); // material per fragId. matIds are resolved by this.materialmap[matId]\n }\n this.materialmap = {}; // map from material ids to THREE.ShaderMaterial instances\n this.materialIdMap = {};\n this.nextMaterialId = 1;\n\n // theming (coloring based on id)\n this.db2ThemingColor = []; // empty if no theming is applied. A theming color db2ThemingColor[dbId] is stored as THREE.Vector4 with values in [0,1].\n this.originalColors = []; // if vizmesh[i] has modified vertex-colors due to theming, originalColors[i] stores a copy of the original colors.\n this.themingOrGhostingNeedsUpdate = []; // indicates if vertex-colors of vizmesh[i] needs to be updated based on recent theming or ghosting changes.\n this.dbIdOpacity = []; // ids with overridden opacity, or hidden by setting alpha to 0\n\n // ghosting for 2d objects: A ghosted object is reduced in transparency and blended with the pageColor.\n this.dbIdIsGhosted = [];\n\n this.animxforms = null; // If animation is used, this is a Float32Array storing 10 floats per fragment to describe scale (3), rotation (4), and translation (3).\n // See this.updateAnimTransform.\n\n for (var i = 0; i < initialSize; i++) {\n this.vizflags[i] = 1; //MESH_VISIBLE initially\n }\n\n // Set the visflags from the fragment visibility, if there is any.\n // For OTG, the flags are not fully loaded at this point. Otg flags are handled in setMesh().\n if (!model.isOTG() && this.fragments.visibilityFlags) {\n this.vizflags.set(this.fragments.visibilityFlags);\n }\n\n this.allVisible = true; // see this.areAllVisible(..). Indicates if MESH_VISIBLE flag is set for all meshes (i.e., not considering culling)\n this.allVisibleDirty = true; // if true, this.allVisible is outdated and must be recomputed in this.areAllVisible.\n this.nextAvailableFragID = initialSize;\n\n // Visibility of lines and points is independent of per-fragment visibility flags\n this.linesHidden = false;\n this.pointsHidden = false;\n\n // Optional: Additional transform applied to the whole model \n this.matrix = null;\n\n // TODO: comment out; for debug\n //this.geomCount = 0;\n //this.geomMax = 100;\n}\n\n// [HB:] This method is only used in RenderModel.setFragment(), which seems to be not called at all. Can we remove this?\n// (including the nextAvailableFragID member and RenderModel.setFragment).\nFragmentList.prototype.getNextAvailableFragmentId = function () {\n return this.nextAvailableFragID++;\n};\n\n// [HB:] When does this method ever return true? vizflags is resized in SetMesh, which only used in RenderModel.activateFragment and \n// RenderModel.setFragment (never called). RenderModel.activateFragment(..) is only used by loaders when new fragments have been loaded.\n// However, for SvfLoader, fragments.length is always the full fragments count and for F2D, new stuff is first added to fragments, then\n// to VisFlags. \n// Maybe this should actually be a \"<\" and is only relevant for F2D case?\nFragmentList.prototype.fragmentsHaveBeenAdded = function () {\n return this.vizflags.length > this.fragments.length;\n};\n\n// Returns undefined if fragId has no material \nFragmentList.prototype.getSvfMaterialId = function (fragId) {\n var mat = this.getMaterial(fragId);\n return mat ? mat.svfMatId : undefined;\n};\n\n/**\n * Set mesh for a fragment, replacing any temporary previous one.\n * @param {number} fragId - Fragment ID\n * @param {Object} meshinfo - Object as defined in Viewer3DImpl.setupMesh(..). Contains:\n * geometry: instanceof BufferGeometry\n * material: instance of THREE.Material\n * matrix: instanceof THREE.Matrix4\n * bbox: Optional world space bounding box\n * isLine: bool to mark line geometry\n * isWideLine: bool to mark wide line geometry\n * isPoint: bool to mark point geometry\n * is2D: bool to indicate 2D geometry (e.g., set by F2DLoader) \n * @param {bool} updateFragmentData - If true, this.bbox and this.transforms is also updated for this fragment.\n * Only allowed if this.isFixedSize==true. (otherwise, this.boxes and this.transforms is null)\n * @param {bool} [retainMesh] - If true, meshInfo is a THREE.Mesh and this.useThreeMesh, then\n * meshInfo will be used as the THREE.Mesh for the fragment.\n */\nFragmentList.prototype.setMesh = function (fragId, meshInfo, updateFragmentData, retainMesh) {\n\n //Remove any temporary geometry we used for the fragment\n //while it was loading\n if (this.vizmeshes) {\n var oldGeom = this.vizmeshes[fragId];\n if (oldGeom && oldGeom.parent) {\n oldGeom.parent.remove(oldGeom);\n }\n }\n\n //The various data arrays need to be re-sized if the fragment is new\n //so we have to do it manually in case this happens. \n if (this.vizflags.length <= fragId) {\n\n // Gradually should only used if isFixedSize is false (as used for F2D geometry)\n if (this.isFixedSize) {\n logger.warn(\"Attempting to resize a fragments list that was initialized with fixed data. This will have a performance impact.\");\n this.isFixedSize = false;\n }\n\n // determine new length of all per-fragmentId arrays\n var nlen = Math.ceil(1.5 * Math.max(this.vizflags.length, fragId)) || 1;\n if (this.useThreeMesh && nlen < this.vizmeshes.length)\n nlen = this.vizmeshes.length;\n\n // re-allocate vizflags\n var nflags = new Uint16Array(nlen);\n nflags.set(this.vizflags);\n this.vizflags = nflags;\n\n // re-allocate other per-fragmentId arrays...\n\n if (this.transforms) {\n var ntransforms = new Float32Array(nlen * 12);\n ntransforms.set(this.transforms);\n this.transforms = ntransforms;\n }\n\n if (this.boxes) {\n var nboxes = new Float32Array(nlen * 6);\n nboxes.set(this.boxes);\n this.boxes = nboxes;\n }\n\n if (this.geomids) {\n var nids = new Int32Array(nlen);\n nids.set(this.geomids);\n this.geomids = nids;\n\n }\n\n if (this.materialids) {\n var nmids = new Int32Array(nlen);\n nmids.set(this.materialids);\n this.materialids = nmids;\n }\n }\n\n //Remember the mesh in the frag->viz mesh array\n if (this.useThreeMesh) {\n var mesh;\n if (retainMesh && meshInfo instanceof THREE.Mesh) {\n mesh = meshInfo;\n\n if (meshInfo.matrix) {\n mesh.matrixWorld.copy(meshInfo.matrix);\n }\n\n mesh.dbId = mesh.dbId || 0;\n } else {\n mesh = new THREE.Mesh(meshInfo.geometry, meshInfo.material);\n\n // Copy matrix to mesh.matrix and mesh.matrixWorld\n // [HB:] Why copying twice?\n if (meshInfo.matrix) {\n if (mesh.matrix) {\n mesh.matrix.copy(meshInfo.matrix);\n }\n mesh.matrixWorld.copy(meshInfo.matrix);\n }\n\n mesh.is2d = meshInfo.is2d;\n mesh.isLine = meshInfo.isLine;\n mesh.isWideLine = meshInfo.isWideLine;\n mesh.isPoint = meshInfo.isPoint;\n\n mesh.dbId = this.fragments.fragId2dbId[fragId] | 0;\n }\n\n // If we would leave that true, THREE.js would call UpdateMatrix() for this mesh and \n // overwrite the matrix with another one computed by position, scale, and quaternion.\n mesh.matrixAutoUpdate = false;\n\n //Add the mesh to the render group for this fragment\n //Note each render group renders potentially many fragments.\n mesh.frustumCulled = false; //we do our own culling in RenderQueue, the renderer doesn't need to\n\n // keep fragId and dbId\n mesh.fragId = fragId;\n mesh.modelId = this.modelId;\n\n // If a model matrix already exists, update matrixWorld (like it's done in setModelMatrix)\n // It's possible that the matrix was set before all vizmeshes were set.\n if (this.matrix) {\n mesh.matrixWorld.multiplyMatrices(this.matrix, mesh.matrix);\n }\n // cache the mesh in this.vizmeshes\n this.vizmeshes[fragId] = mesh;\n } else {\n // When not using THREE.Mesh, store ids of BufferGeometry and material instead\n\n // Handle shared Otg geoms: If the geometry contains a hash, it is a shareable Otg geometry. For these,\n // we cannot use svfid, because the geomId may vary per model.\n // => For this case, the geomId must be provided separately by the meshInfo\n var geomId = undefined;\n if (meshInfo.geometry.hash) {\n // shared otg geom\n if (meshInfo.geomId === undefined) {\n console.error(\"meshInfo must provide geomId\");\n }\n geomId = meshInfo.geomId;\n } else {\n // svf geom\n geomId = meshInfo.geometry.svfid;\n }\n\n this.geomids[fragId] = geomId;\n\n this.setMaterial(fragId, meshInfo.material);\n }\n\n // Don't override the visibility flag which could be set before geometry is ready.\n // This can improve the performance when streaming geometry and rendering happen together.\n var typeFlags = 0;\n if (meshInfo.isLine) typeFlags = MeshFlags.MESH_ISLINE;else\n if (meshInfo.isWideLine) typeFlags = MeshFlags.MESH_ISWIDELINE;else\n if (meshInfo.isPoint) typeFlags = MeshFlags.MESH_ISPOINT;\n if (!this.isFixedSize) {\n this.vizflags[fragId] |= MeshFlags.MESH_VISIBLE | typeFlags;\n } else\n {\n this.vizflags[fragId] |= typeFlags;\n }\n\n if (updateFragmentData && this.transforms && this.boxes) {\n // Update transform and bb\n var transform = meshInfo.matrix;\n\n // Copy the transform to the fraglist array\n // We store in column-major order like the elements of the Matrix4, but skip row 3.\n var i = fragId * 12;\n var cur = transform.elements;\n var orig = this.transforms;\n orig[i] = cur[0];\n orig[i + 1] = cur[1];\n orig[i + 2] = cur[2];\n orig[i + 3] = cur[4];\n orig[i + 4] = cur[5];\n orig[i + 5] = cur[6];\n orig[i + 6] = cur[8];\n orig[i + 7] = cur[9];\n orig[i + 8] = cur[10];\n orig[i + 9] = cur[12];\n orig[i + 10] = cur[13];\n orig[i + 11] = cur[14];\n\n // When using Otg, computed bboxes are only used until we get the actual ones from fragments_extra.\n // Once loaded, they must not be overwritten by computed ones (which are too large in some cases).\n if (!this.fragments.boxesLoaded) {\n if (meshInfo.bbox) {\n _tmpBox.copy(meshInfo.bbox);\n } else {\n // Transform the local BB to world\n if (meshInfo.geometry && meshInfo.geometry.boundingBox) {\n _tmpBox.copy(meshInfo.geometry.boundingBox);\n } else {\n this.geoms.getModelBox(this.geomids[fragId], _tmpBox);\n }\n\n if (!_tmpBox.empty()) {\n _tmpBox.applyMatrix4(transform);\n }\n }\n\n // Write bounding box to this.boxes\n var boffset = fragId * 6;\n var bb = this.boxes;\n bb[boffset] = _tmpBox.min.x;\n bb[boffset + 1] = _tmpBox.min.y;\n bb[boffset + 2] = _tmpBox.min.z;\n bb[boffset + 3] = _tmpBox.max.x;\n bb[boffset + 4] = _tmpBox.max.y;\n bb[boffset + 5] = _tmpBox.max.z;\n }\n }\n};\n\n\nFragmentList.prototype.isFlagSet = function (fragId, flag) {\n return !!(this.vizflags[fragId] & flag);\n};\n\n/**\n * Set/unset flag of a fragment.\n * Note: Changing MESH_VISIBLE requires to update allVisibleDirty as well => Use setVisibility() for this case.\n * @param {number} fragId - Fragment ID.\n * @param {number} flag - Must be one of the flags defined at the beginning of this file, e.g., MESH_HIGHLIGHTED.\n * @returns {bool} False if nothing changed.\n */\nFragmentList.prototype.setFlagFragment = function (fragId, flag, value) {\n\n // If flag is already defined and has this value, just return false.\n var old = this.vizflags[fragId];\n if (!!(old & flag) == value) // \"!!\" casts to boolean, \"==\" is intentional.\n return false;\n\n // set or unset flag\n if (value)\n this.vizflags[fragId] = old | flag;else\n\n this.vizflags[fragId] = old & ~flag;\n\n return true;\n};\n\n/**\n * Set/unset flag for all fragments, e.g. setFlagGlobal(MESH_VISIBLE, true);\n * Note: Changing MESH_VISIBLE requires to update allVisibleDirty as well => use setAllVisibility() for this case.\n * @param {number} flag - Must be one of the flags defined at the beginning of this file, e.g., MESH_HIGHLIGHTED.\n * @param {bool} value - Value to be set to the flag\n */\nFragmentList.prototype.setFlagGlobal = function (flag, value) {\n var vizflags = this.vizflags;\n var i = 0,iEnd = vizflags.length;\n if (value) {\n for (; i < iEnd; i++) {\n vizflags[i] = vizflags[i] | flag;\n }\n } else {\n var notflag = ~flag;\n for (; i < iEnd; i++) {\n vizflags[i] = vizflags[i] & notflag;\n }\n }\n};\n\n/**\n * Marks all lines as visible or hidden.\n * Works like this.setFlagGlobal(MESH_HIDE, hide), but only affects fragments with MESH_ISLINE flag.\n * @param {bool} hide - Desired visibility status.\n */\nFragmentList.prototype.hideLines = function (hide) {\n this.linesHidden = hide;\n};\n\n/**\n * Marks all points as visible or hidden.\n * Works like this.setFlagGlobal(MESH_HIDE, hide), but only affects fragments with MESH_ISPOINT flag.\n * @param {bool} hide - Desired visibility status.\n */\nFragmentList.prototype.hidePoints = function (hide) {\n this.pointsHidden = hide;\n};\n\n/**\n * Marks all fragments with the given flag as visible or hidden.\n * Works like this.setFlagGlobal(MESH_HIDE, hide), but only affects fragments with given flag.\n * @param {number} typeFlag - visibility flag of fragments to change\n * @param {bool} hide - Desired visibility status.\n */\nFragmentList.prototype.hideFragments = function (typeFlag, hide) {\n\n var flag = MeshFlags.MESH_HIDE;\n\n var vizflags = this.vizflags;\n var i = 0,iEnd = vizflags.length;\n if (hide) {\n for (; i < iEnd; i++) {\n if (vizflags[i] & typeFlag)\n vizflags[i] = vizflags[i] | flag;\n }\n } else {\n var notflag = ~flag;\n for (; i < iEnd; i++) {\n if (vizflags[i] & typeFlag)\n vizflags[i] = vizflags[i] & notflag;\n }\n }\n\n // Mark allVisible as outdated \n this.allVisibleDirty = true;\n};\n\n/**\n * Checks visibility of a fragment.\n * @param {number} frag - Fragment ID.\n * @returns {bool} True if the fragment is visible and not highlighted nor hidden.\n */\nFragmentList.prototype.isFragVisible = function (frag) {\n var isHiddenLine = this.linesHidden && (this.isLine(frag) || this.isWideLine(frag));\n var isHiddenPoint = this.pointsHidden && this.isPoint(frag);\n return (this.vizflags[frag] & 7 /*MESH_VISIBLE|MESH_HIGHLIGHTED|MESH_HIDE*/) == 1 && !isHiddenLine && !isHiddenPoint;\n};\n\nFragmentList.prototype.isFragOff = function (frag) {\n return !!(this.vizflags[frag] & MeshFlags.MESH_HIDE);\n};\n\n/*\n * Returns true if a fragment was excluded from loading or unloaded. \n *\n * Note that isNotLoaded()==false does not guarantee that geometry and material are already in memory.\n * Only vice versa: If true, it will not be loaded at all.\n */\nFragmentList.prototype.isNotLoaded = function (frag) {\n return this.vizflags[frag] & MeshFlags.MESH_NOTLOADED;\n};\n\nFragmentList.prototype.isLine = function (frag) {\n return !!(this.vizflags[frag] & MeshFlags.MESH_ISLINE /*MESH_VISIBLE|MESH_HIGHLIGHTED*/);\n};\n\nFragmentList.prototype.isWideLine = function (frag) {\n return this.isFlagSet(frag, MeshFlags.MESH_ISWIDELINE);\n};\n\nFragmentList.prototype.isPoint = function (frag) {\n return this.isFlagSet(frag, MeshFlags.MESH_ISPOINT);\n};\n\n\n// [HB:] This method does not consider the MESH_HIDE flag, but this.setFragOff seems to expect this, because it sets allVisibleDirty.\n// Is this a bug?\nFragmentList.prototype.areAllVisible = function () {\n\n // update allVisible if any flags have changed\n if (this.allVisibleDirty) {\n\n // allVisible <=> MESH_VISIBLE is set for all fragments\n var vizflags = this.vizflags;\n var allVisible = true;\n for (var i = 0, iEnd = vizflags.length; i < iEnd; i++) {\n if ((vizflags[i] & 1 /*MESH_VISIBLE*/) === 0) {\n allVisible = false;\n break;\n }\n }\n\n this.allVisible = allVisible;\n this.allVisibleDirty = false;\n }\n\n return this.allVisible;\n};\n\n// Swaps r/b channels in a THREE.Color object.\nfunction swapRBChannels(color) {\n var tmp = color.r;\n color.r = color.b;\n color.b = tmp;\n return color;\n}\n\n/** Linear interpolation between original color and theming color based on theming intensity.\n * @param origColor {number} original uint32 color from vertex-buffer. alpha is vertex-opacity\n * @param themingColor {THREE.Vector4} theming color as vec4f. Channels are (r,g,b,a) where alpha is theming intensity.\n * @returns finalColor {number} final color as uint32\n */\nvar applyThemingColorAndVisibility = function () {\n var tmp1 = null;\n var tmp2 = null;\n var rgbMask = parseInt(\"00FFFFFF\", 16);\n var alphaMask = parseInt(\"FF000000\", 16);\n return function (origColor, themingColor) {\n if (!tmp1) {\n tmp1 = new THREE.Color();\n tmp2 = new THREE.Color();\n }\n\n tmp1.set(origColor & rgbMask);\n\n // THREE.Color denotes uint color in BGRA order (i.e., Blue in the lowest byte).\n // In the vertex-buffer, we use RGBA - so we have to swap when converting between these two.\n swapRBChannels(tmp1);\n\n if (themingColor) {\n // set tmp2 to theming color\n tmp2.setRGB(themingColor.x, themingColor.y, themingColor.z);\n\n // blend original color with theming color\n tmp1.lerp(tmp2, themingColor.w);\n }\n\n // convert back to color-buffer uint32 and preserve original alpha bits\n return swapRBChannels(tmp1).getHex() | origColor & alphaMask;\n };\n}();\n\n// Updates the per-vertex array of a mesh to reflect latest theming and ghosting state.\n// Note that this can only work on F2D meshes with known attributes and interleaved vertex buffer.\nfunction updateVertexBufferForThemingAndGhosting(fragList, fragId) {\n\n // get backup of original per-vertex colors (undef if color array is currently not modified)\n var origColors = fragList.originalColors[fragId];\n\n // check if anything changed\n if (!fragList.themingOrGhostingNeedsUpdate[fragId]) {\n return;\n }\n\n // get values to access colors and ids\n var geom = fragList.getGeometry(fragId);\n if (!geom || !geom.vb) return;\n var vbr = new VertexBufferReader(geom);\n var vbw = new VertexBufferWriter(geom);\n\n if (!vbr.isInterleavedVb) {\n // we cannot work on this mesh.\n return;\n }\n\n // Track if any colors/layers are affected by theming/ghosting. If not, we can drop the color/layer array backup at the end.\n var themingApplied = false;\n\n // Constants used for ghosting of 2D objects\n var PaperLayer = 0; // we use the paper layer to determine the paper sheet background (see F2d.js initSheet). This shape must be excluded from ghosting.\n var vertexCount = vbr.vcount;\n // update vertex-color for each vertex\n for (var i = 0; i < vertexCount; i++) {\n\n var dbId = vbr.getDbIdAt(i);\n var color = origColors ? origColors[i] : vbr.getColorAt(i);\n var layer = vbr.getLayerIndexAt(i);\n\n // sign extend the upper byte to get back negative numbers (since per-vertex ids are clamped from 32 bit to 24 bit)\n dbId = dbId << 8 >> 8;\n\n var isPaper = dbId === -1 && layer === PaperLayer;\n\n // is this id affected by theming?\n var themeColor = fragList.db2ThemingColor[dbId];\n var isHidden = fragList.dbIdOpacity[dbId] === 0;\n\n if (!themeColor && !isHidden) {\n // no theming for this vertex\n if (origColors) {\n // restore original color\n color = origColors[i];\n } // else: if there is no backup array, the vertex-color is already the original.\n } else {\n // this vertex-color will be affected by theming.\n // make sure that we have backup.\n if (!origColors) {\n // backup original colors before we modify them.\n origColors = new Uint32Array(vertexCount);\n for (var j = 0; j < vertexCount; j++) {\n origColors[j] = vbr.getColorAt(j);\n }\n fragList.originalColors[fragId] = origColors;\n }\n\n // replace vertex-color based on theming and visibility\n if (isHidden) {\n color = 0;\n } else {\n color = applyThemingColorAndVisibility(color, themeColor);\n }\n\n // signal that the color backup array is still needed\n themingApplied = true;\n }\n\n if (!isHidden) {\n var opacity = fragList.dbIdOpacity[dbId];\n if (!isNaN(opacity)) {\n var rgbMask = parseInt(\"00FFFFFF\", 16);\n opacity = 255 * opacity << 24;\n color = color & rgbMask | opacity;\n }\n }\n\n // color -> vertexBuffer\n vbw.setColorAt(i, color);\n\n // is this id affected by theming?\n var isGhosted = fragList.dbIdIsGhosted[dbId] && !isPaper;\n var flags = vbr.getVertexFlagsAt(i);\n if (isGhosted)\n flags |= 0xff << 24;else\n\n flags &= ~(0xff << 24);\n\n // layer -> vertexBuffer\n vbw.setVertexFlagsAt(i, flags);\n }\n\n // if theming is off for all vertices, drop the backup array\n if (!themingApplied) {\n fragList.originalColors[fragId] = null;\n }\n\n // trigger refresh of GPU-side vertex buffer\n geom.vbNeedsUpdate = true;\n\n // don't touch this mesh again until new theming changes are done\n fragList.themingOrGhostingNeedsUpdate[fragId] = false;\n}\n\n/**\n * Provides an actual mesh for specific fragment.\n * NOTE: For (this.useThreeMesh==false), the returned value is volatile and will be overwritten on next call!\n * @param {number} fragId - Fragment ID.\n * @returns {THREE.Mesh} Mesh for the given fragment.\n */\nFragmentList.prototype.getVizmesh = function () {\n\n //A scratch object that we fill in and return in the case\n //we don't use THREE.Mesh for persistent storage. If the caller\n //needs to hold on to the mesh outside the callback scope, it has to clone it.\n\n var m = new THREE.Mesh(undefined, undefined, true);\n m.isTemp = true;\n m.dbId = 0;\n m.modelId = 0;\n m.fragId = -1;\n m.hide = false;\n m.isLine = false;\n m.isWideLine = false;\n m.isPoint = false;\n\n return function (fragId) {\n\n // make sure that vertex-colors reflect the latest theming-state\n if (this.is2d)\n updateVertexBufferForThemingAndGhosting(this, fragId);\n\n if (this.useThreeMesh) {\n var mesh = this.vizmeshes[fragId];\n if (mesh)\n mesh.themingColor = this.db2ThemingColor[mesh.dbId];\n return mesh;\n } else {\n\n\n // init temp mesh object from geometry, material etc.\n m.geometry = this.getGeometry(fragId); // BufferGeometry\n m.material = this.getMaterial(fragId); // THREE.ShaderMaterial\n m.dbId = this.getDbIds(fragId);\n m.modelId = this.modelId;\n m.fragId = fragId;\n m.visible = true;\n m.isLine = this.isLine(fragId);\n m.isWideLine = this.isWideLine(fragId);\n m.isPoint = this.isPoint(fragId);\n m.hide = this.isFragOff(fragId);\n m.themingColor = this.db2ThemingColor[m.dbId];\n\n this.getWorldMatrix(fragId, m.matrixWorld);\n\n return m;\n }\n };\n\n}();\n\n\nFragmentList.prototype.getMaterialId = function (fragId) {\n var m = this.getMaterial(fragId);\n return m ? m.id : 0;\n};\n\nFragmentList.prototype.getMaterial = function (fragId) {\n // material ids are either stored with vizmeshes or in the material map.\n return this.useThreeMesh ? this.vizmeshes[fragId].material : this.materialIdMap[this.materialids[fragId]];\n};\n\nFragmentList.prototype.getGeometry = function (fragId) {\n // geometry is either stored in with vizmoeshes or obtained from this.geoms.\n // Make sure this.vizmesh[fragId] isn't null or undefined\n var mesh;\n return this.useThreeMesh ?\n (mesh = this.vizmeshes[fragId]) ? mesh.geometry : null :\n this.geoms.getGeometry(this.geomids[fragId]);\n};\n\nFragmentList.prototype.getGeometryId = function (fragId) {\n // When using THREE.Meshes, fragIds and geomids are the same and this.geomids is not used.\n return this.useThreeMesh ? fragId : this.geomids[fragId];\n};\n\nFragmentList.prototype.setMaterial = function (fragId, material) {\n\n if (this.useThreeMesh) {\n\n this.vizmeshes[fragId].material = material;\n\n } else {\n\n var matId = this.materialmap[material.id];\n\n if (!matId) {\n\n //Material.id is global, hence we can't expect it to be a small\n //integer. Hence the incrementing counter indirection.\n matId = this.nextMaterialId++;\n\n this.materialids = reallocateUintArrayMaybe(this.materialids, matId);\n\n this.materialIdMap[matId] = material;\n\n //remember our local ID for this global material\n this.materialmap[material.id] = matId;\n }\n\n this.materialids[fragId] = matId;\n }\n};\n\nFragmentList.prototype.getCount = function () {\n return this.vizmeshes ? this.vizmeshes.length : this.vizflags.length;\n};\n\nFragmentList.prototype.getDbIds = function (fragId) {\n return this.fragments.fragId2dbId[fragId];\n};\n\n// glRenderer: instanceof WebGLRenderer (only neeeded when for this.useThreeMesh==false)\nFragmentList.prototype.dispose = function (glrenderer) {\n\n if (this.useThreeMesh) {\n\n // dispatch remove event to all meshes and dispose events to all BufferGeometry buffers\n // This will trigger EventListeners added by WebGLRenderer that deallocate the geometry later.\n // (see onGeometryDispose(..) in WebGLRenderer.js)\n var DISPOSE_EVENT = { type: 'dispose' };\n var REMOVED_EVENT = { type: 'removed' };\n for (var i = 0; i < this.vizmeshes.length; i++) {\n var m = this.vizmeshes[i];\n if (m) {\n m.dispatchEvent(REMOVED_EVENT);\n m.geometry.dispatchEvent(DISPOSE_EVENT);\n }\n }\n } else {\n // Delete all geometry data immediately (see WebGLRenderer.deallocateGeometry)\n this.geoms.dispose(glrenderer);\n }\n};\n\n// This function should probably not be called outside VisibityManager\n// in order to maintain node visibility state.\nFragmentList.prototype.setVisibility = function (fragId, value) {\n this.setFlagFragment(fragId, MeshFlags.MESH_VISIBLE, value);\n this.allVisibleDirty = true;\n};\n\n\n// Note that this function switches whole meshes on/off. It cannot be used to toggle visibility of\n// single 2D objects within a single mesh. For this one, use setObject2DVisible instead.\nFragmentList.prototype.setFragOff = function (fragId, value) {\n this.setFlagFragment(fragId, MeshFlags.MESH_HIDE, value);\n this.allVisibleDirty = true; // [HB:] Either this should be removed or this.areAllVisible should consider MESH_HIDE\n};\n\n\nFragmentList.prototype.setAllVisibility = function (value) {\n if (this.is2d) {\n var frags = this.fragments;\n if (frags && frags.dbId2fragId) {\n for (var id in frags.dbId2fragId) {\n this.setObject2DGhosted(parseInt(id), !value);\n }\n }\n } else {\n this.setFlagGlobal(MeshFlags.MESH_VISIBLE, value);\n }\n\n this.allVisible = value;\n this.allVisibleDirty = false;\n};\n\n/**\n * Updates animation transform of a specific fragment.\n * Note: \n * - If scale/rotation/translation are all null, the call resets the whole transform, i.e., no anim transform is assigned anymore.\n * - Leaving some of them null means to leave them unchanged.\n * @param {number} fragId - Fragment ID.\n * @param {Vector3=} scale\n * @param {Quaternion=} rotationQ\n * @param {Vector3=} translation\n */\nFragmentList.prototype.updateAnimTransform = function (fragId, scale, rotationQ, translation) {\n\n var ax = this.animxforms;\n var off;\n\n //Allocate animation transforms on first use.\n if (!ax) {\n var count = this.getCount();\n ax = this.animxforms = new Float32Array(10 * count); //3 scale + 4 rotation + 3 translation\n for (var i = 0; i < count; i++) {\n // get start index of the anim transform of fragment i\n off = i * 10;\n\n // init as identity transform\n ax[off] = 1; // scale.x\n ax[off + 1] = 1; // scale.y\n ax[off + 2] = 1; // scale.z\n ax[off + 3] = 0; // rot.x\n ax[off + 4] = 0; // rot.y\n ax[off + 5] = 0; // rot.z\n ax[off + 6] = 1; // rot.w\n ax[off + 7] = 0; // trans.x\n ax[off + 8] = 0; // trans.y\n ax[off + 9] = 0; // trans.z\n }\n }\n\n off = fragId * 10;\n var moved = false;\n\n if (scale) {\n ax[off] = scale.x;\n ax[off + 1] = scale.y;\n ax[off + 2] = scale.z;\n moved = true;\n }\n\n if (rotationQ) {\n ax[off + 3] = rotationQ.x;\n ax[off + 4] = rotationQ.y;\n ax[off + 5] = rotationQ.z;\n ax[off + 6] = rotationQ.w;\n moved = true;\n }\n\n if (translation) {\n ax[off + 7] = translation.x;\n ax[off + 8] = translation.y;\n ax[off + 9] = translation.z;\n moved = true;\n }\n\n // Set MESH_MOVED if an animation transform has been assigned. Just if scale/rotation/translation are all null, unset the flag.\n this.setFlagFragment(fragId, MeshFlags.MESH_MOVED, moved);\n\n //Assume that if we are called with null everything the caller wants to reset the transform.\n if (!moved) {\n // reset to identity transform\n ax[off] = 1;\n ax[off + 1] = 1;\n ax[off + 2] = 1;\n ax[off + 3] = 0;\n ax[off + 4] = 0;\n ax[off + 5] = 0;\n ax[off + 6] = 1;\n ax[off + 7] = 0;\n ax[off + 8] = 0;\n ax[off + 9] = 0;\n }\n};\n\n/**\n * Returns animation transform of a specific fragment.\n * @param {number} fragId - Fragment ID.\n * @param {THREE.Vector3=} scale - Output param.\n * @param {THREE.Quaternion=} rotationQ - Output param.\n * @param {THREE.Vector3=} translation - Output param.\n * @returns {bool} True if an anim transform is assigned to the given fragment.\n * If so, it is written to the given out params. False otherwise (outparams not changed).\n */\nFragmentList.prototype.getAnimTransform = function (fragId, scale, rotationQ, translation) {\n\n if (!this.animxforms)\n return false;\n\n if (!this.isFlagSet(fragId, MeshFlags.MESH_MOVED))\n return false;\n\n var off = fragId * 10;\n var ax = this.animxforms;\n\n if (scale) {\n scale.x = ax[off];\n scale.y = ax[off + 1];\n scale.z = ax[off + 2];\n }\n\n if (rotationQ) {\n rotationQ.x = ax[off + 3];\n rotationQ.y = ax[off + 4];\n rotationQ.z = ax[off + 5];\n rotationQ.w = ax[off + 6];\n }\n\n if (translation) {\n translation.x = ax[off + 7];\n translation.y = ax[off + 8];\n translation.z = ax[off + 9];\n }\n\n return true;\n};\n\n/**\n * Returns world matrix of a fragment.\n * @param {number} index - Fragment ID.\n * @param {THREE.Matrix4} dstMtx - Out param to receive the matrix.\n */\nFragmentList.prototype.getOriginalWorldMatrix = function (index, dstMtx) {\n var i = index * 12;\n\n var cur = dstMtx.elements;\n var orig = this.transforms;\n\n if (orig) {\n // If this.transforms is defined, copy transform from this array \n\n // In this.transforms, we only store the upper 3 rows explicitly. \n // The last row is alway (0,0,0,1).\n cur[0] = orig[i];\n cur[1] = orig[i + 1];\n cur[2] = orig[i + 2];\n cur[3] = 0;\n cur[4] = orig[i + 3];\n cur[5] = orig[i + 4];\n cur[6] = orig[i + 5];\n cur[7] = 0;\n cur[8] = orig[i + 6];\n cur[9] = orig[i + 7];\n cur[10] = orig[i + 8];\n cur[11] = 0;\n cur[12] = orig[i + 9];\n cur[13] = orig[i + 10];\n cur[14] = orig[i + 11];\n cur[15] = 1;\n } else if (this.useThreeMesh) {\n // get matrix directly from THREE.Mesh\n var m = this.vizmeshes[index];\n if (m)\n dstMtx.copy(m.matrix); // Was matrixWorld, but that is now being used for the alignment transform\n else\n dstMtx.identity();\n } else {\n dstMtx.identity();\n }\n};\n\n\n/**\n * Writes the final world matrix of a fragment to out param dstMtx.\n * The world matrix results from original transform and anim transform (if any).\n * @param {number} index - Fragment ID.\n * @param {THREE.Matrix4} dstMtx - Out param to receive the matrix.\n */\nFragmentList.prototype.getWorldMatrix = function () {\n\n //Allocate a second temp variable here because the input can be the class scoped\n //temporary matrix in some call sequences.\n var tmp = new THREE.Matrix4();\n\n return function (index, dstMtx) {\n\n this.getOriginalWorldMatrix(index, dstMtx);\n\n //If mesh hasn't moved from its original location, just use that.\n if (this.isFlagSet(index, MeshFlags.MESH_MOVED)) {\n\n //Otherwise construct the overall world matrix\n this.getAnimTransform(index, _tmpScale, _tmpRot, _tmpPos);\n\n // compose matrix from pos, rotation, and scale\n tmp.compose(_tmpPos, _tmpRot, _tmpScale);\n\n // First apply original matrix (in dstMtx), then anim matrix (in tmp).\n // Note that tmp muist be multipled from left for this.\n dstMtx.multiplyMatrices(tmp, dstMtx);\n }\n\n // Apply optional model-transform\n if (this.matrix) {\n // Apply fragment matrix first (=dst), then model matrix (=this.matrix).\n // Note that model matrix must be multipled from left for this.\n dstMtx.multiplyMatrices(this.matrix, dstMtx);\n }\n };\n}();\n\nFragmentList.prototype.setModelMatrix = function (matrix) {var _this = this;\n if (matrix) {\n this.matrix = this.matrix || new THREE.Matrix4();\n this.matrix.copy(matrix);\n if (this.useThreeMesh) {\n // For ThreeJS meshes we use matrixWorld to store the alignment matrix\n this.vizmeshes.forEach(function (mesh) {\n mesh.matrixWorld.multiplyMatrices(_this.matrix, mesh.matrix);\n });\n }\n } else {\n this.matrix = null;\n if (this.useThreeMesh) {\n this.vizmeshes.forEach(function (mesh) {\n mesh.matrixWorld.copy(mesh.matrix);\n });\n }\n }\n this.invMatrix = null;\n};\n\nFragmentList.prototype.getInverseModelMatrix = function () {\n if (this.matrix) {\n if (!this.invMatrix) {\n this.invMatrix = new THREE.Matrix4().getInverse(this.matrix);\n }\n\n return this.invMatrix;\n }\n\n return null;\n};\n\n/**\n * Writes the world box to dstBox outparams, considering matrix and anim transform (if specified).\n * @param {number} index - Fragment ID.\n * @param {THREE.Box3|LmvBox3} dstBox - result is saved here\n */\nFragmentList.prototype.getWorldBounds = function (index, dstBox) {\n\n //Check if the world transform of the mesh is unchanged from\n //the original LMV file -- in such case we can use the original\n //bounding box from the LMV package, which is presumably more precise (tighter)\n //than just transforming the model box.\n //This is important if we want to keep our bounding volume hierarchy efficient.\n if (this.boxes && !this.isFlagSet(index, MeshFlags.MESH_MOVED)) {\n var b = this.boxes;\n var boffset = index * 6;\n dstBox.min.x = b[boffset];\n dstBox.min.y = b[boffset + 1];\n dstBox.min.z = b[boffset + 2];\n dstBox.max.x = b[boffset + 3];\n dstBox.max.y = b[boffset + 4];\n dstBox.max.z = b[boffset + 5];\n\n // Consider optional model matrix if there is one\n if (this.matrix) {\n dstBox.applyMatrix4(this.matrix);\n }\n\n return;\n }\n\n // get original model box\n if (this.useThreeMesh) {\n // either from THREE.Mesh\n var m = this.vizmeshes[index];\n if (m && m.geometry) {\n dstBox.copy(m.geometry.boundingBox);\n }\n } else\n {\n // or from GeometryList\n this.geoms.getModelBox(this.geomids[index], dstBox);\n }\n\n if (!dstBox.empty()) {\n // apply world matrix to dstBox.\n // Note that the worldMatrix includes the model matrix as well.\n this.getWorldMatrix(index, _tmpMatrix);\n dstBox.applyMatrix4(_tmpMatrix);\n }\n};\n\n\n/**\n * Writes the original (as loaded) world box to dstBox outparams. Does not take into account changes\n * to object position like explode/animation or model matrix.\n * @param {number} index - Fragment ID.\n * @param {Array} dstBox - Array where result is stored as 6 consecutive numbers\n */\nFragmentList.prototype.getOriginalWorldBounds = function (index, dstBox) {\n\n if (this.boxes) {\n var b = this.boxes;\n var boffset = index * 6;\n dstBox[0] = b[boffset];\n dstBox[1] = b[boffset + 1];\n dstBox[2] = b[boffset + 2];\n dstBox[3] = b[boffset + 3];\n dstBox[4] = b[boffset + 4];\n dstBox[5] = b[boffset + 5];\n return;\n }\n\n // get original model box\n if (this.useThreeMesh) {\n // either from THREE.Mesh\n var m = this.vizmeshes[index];\n if (m && m.geometry) {\n _tmpBox.copy(m.geometry.boundingBox);\n }\n } else\n {\n // or from GeometryList\n this.geoms.getModelBox(this.geomids[index], _tmpBox);\n }\n\n if (!_tmpBox.empty()) {\n // apply world matrix to dstBox\n this.getOriginalWorldMatrix(index, _tmpMatrix);\n _tmpBox.applyMatrix4(_tmpMatrix);\n }\n\n dstBox[0] = _tmpBox.min.x;\n dstBox[1] = _tmpBox.min.y;\n dstBox[2] = _tmpBox.min.z;\n dstBox[3] = _tmpBox.max.x;\n dstBox[4] = _tmpBox.max.y;\n dstBox[5] = _tmpBox.max.z;\n};\n\n\n// set themingNeedsUpdate flag for all vizmeshes that contain a given dbId\nfunction setThemingOrGhostingNeedsUpdateFlag(fragList, dbId) {\n\n if (!fragList.is2d) {\n // In this case (3D model), we just have theming colors per mesh and don't need to update vertex buffers.\n return;\n }\n\n // get id(s) of affected mesh(es) that needs a vertex-color update\n var fragIds = fragList.fragments.dbId2fragId[dbId];\n\n // trigger update for single id or an array of ids\n if (Array.isArray(fragIds)) {\n for (var i = 0; i < fragIds.length; i++) {\n fragList.themingOrGhostingNeedsUpdate[fragIds[i]] = true;\n }\n } else if (typeof fragIds === 'number') {\n fragList.themingOrGhostingNeedsUpdate[fragIds] = true;\n }\n}\n\n/**\n * Applies a theming color that is blended with the final fragment color of a material shader.\n * @param {number} dbId\n * @param {THREE.Vector4} [color] - theming color (in xyz) and intensity (in w). All components in [0,1].\n * Set to undefined for 'no theming'\n */\nFragmentList.prototype.setThemingColor = function (dbId, color) {\n // Stop if color keeps the same\n var oldColor = this.db2ThemingColor[dbId];\n var colorsEqual = oldColor === color || oldColor && color && oldColor.equals(color);\n if (!colorsEqual) {\n this.db2ThemingColor[dbId] = color || undefined;\n setThemingOrGhostingNeedsUpdateFlag(this, dbId);\n }\n};\n\n/** Restore original colors for all themed shapes. */\nFragmentList.prototype.clearThemingColors = function () {\n\n // When using F2D (model.is2d()==true), we have to update the restore the original\n // per-vertex colors. For 3D, we can use per-shape colors, so that this step is not\n // needed.\n if (this.is2d) {\n // trigger update for all meshes that were affected by theming before\n // Note that dbId2fragId only exists for F2D models.\n for (var id in this.fragments.dbId2fragId) {\n setThemingOrGhostingNeedsUpdateFlag(this, parseInt(id));\n }\n delete this.db2ThemingColor['-1']; // Delete theming for sheet\n }\n\n // clear theming-color map\n this.db2ThemingColor.length = 0;\n};\n\n/** Set ghosting flag for a 2D object. This reduces the objects opacity, blends it with pageColor, and excludes it from selection.\n * @param {number} dbId\n * @param {bool} state\n */\nFragmentList.prototype.setObject2DGhosted = function (dbId, state) {\n var oldState = this.dbIdIsGhosted[dbId];\n if (!!state !== !!oldState) {\n this.dbIdIsGhosted[dbId] = state;\n setThemingOrGhostingNeedsUpdateFlag(this, dbId);\n }\n};\n\n/** Set an opacity value for a 2D object.\n * @param {number} dbId\n * @param {number} opacity\n */\nFragmentList.prototype.setObject2DOpacity = function (dbId, opacity) {\n var oldOpacity = this.dbIdOpacity[dbId];\n if (opacity !== oldOpacity) {\n this.dbIdOpacity[dbId] = opacity;\n setThemingOrGhostingNeedsUpdateFlag(this, dbId);\n }\n};\n\n/** Set hide flag for a 2D object. This sets opacity to 0.0, which also excludes it from selection.\n * @param {number} dbId\n * @param {bool} visible\n */\nFragmentList.prototype.setObject2DVisible = function (dbId, visible) {\n var wasVisible = this.dbIdOpacity[dbId] !== 0;\n if (visible !== wasVisible) {\n this.dbIdOpacity[dbId] = visible | 0;\n setThemingOrGhostingNeedsUpdateFlag(this, dbId);\n }\n};\n\n/**\n * Convenience class encapsulating a single fragment in a given FragmentList.\n * Use sparingly, as it is expensive to have those for every fragment in memory.\n * \n * @see Autodesk.Viewing.Viewer3D#getFragmentPointer\n * @see Autodesk.Viewing.Viewer3D#getModel\n * \n * @example\n * var avp = Autodesk.Viewing.Private;\n * var fragPointer = new avp.FragmentPointer(viewer.model.getFragmentList(), 4); // Get the fragment proxy for some frag id\n * // The Model class also exposes the following method to get the FragmentPointer:\n * // var fragPointer = viewer.model.getFragmentPointer(4); \n * \n * @constructor\n * \n * @param {Autodesk.Viewing.Private.FragmentList} frags - the fragment list\n * @param {number} fragId - the fragment id\n * \n * @alias Autodesk.Viewing.Private.FragmentPointer\n */\nexport function FragmentPointer(frags, fragId) {\n\n this.frags = frags; // fragment list\n this.fragId = fragId; // id of a fragment in frags\n\n // used by MeshAnimation\n this.scale = null;\n this.quaternion = null;\n this.position = null;\n}\n\n/**\n * Writes the final world matrix of a fragment to dst.\n * The world matrix results from original transform and anim transform (if any).\n * @param {THREE.Matrix4} dst - Out param to receive the matrix.\n * @example\n * var matrix = new THREE.Matrix4() // Create an empty Matrix4\n * fragPointer.getWorldMatrix(matrix); // Set the new values to the matrix variable\n */\nFragmentPointer.prototype.getWorldMatrix = function (dst) {\n this.frags.getWorldMatrix(this.fragId, dst);\n};\n\n/**\n * Writes the original world matrix of a fragment to dst.\n * @param {THREE.Matrix4} dst - Out param to receive the matrix.\n * @example\n * var matrix = new THREE.Matrix4() // Create an empty Matrix4\n * fragPointer.getOriginalWorldMatrix(matrix); // Set the new values to the matrix variable\n */\nFragmentPointer.prototype.getOriginalWorldMatrix = function (dst) {\n this.frags.getOriginalWorldMatrix(this.fragId, dst);\n};\n\n/**\n * Writes the world box to dst param, considering matrix and anim transform (if specified).\n * @param {THREE.Box3|LmvBox3} dst - result is saved here\n * @example\n * var box = new THREE.Box3(); // Create an empty Box3\n * fragPointer.getWorldBounds(box); // Set the new values to the box variable\n * \n */\nFragmentPointer.prototype.getWorldBounds = function (dst) {\n return this.frags.getWorldBounds(this.fragId, dst);\n\n};\n\n/**\n * Sets the scale, quaternion and position to the animation transform of the the fragment.\n * @returns {boolean} True if an animation transform is set. Otherwise, it returns false and transform is set to identity.\n */\nFragmentPointer.prototype.getAnimTransform = function () {\n\n if (!this.scale) {\n this.scale = new THREE.Vector3(1, 1, 1);\n this.quaternion = new THREE.Quaternion(0, 0, 0, 1);\n this.position = new THREE.Vector3(0, 0, 0);\n }\n\n return this.frags.getAnimTransform(this.fragId, this.scale, this.quaternion, this.position);\n\n};\n\n/**\n * Applies current scale/quaternion/position to the fragment.\n */\nFragmentPointer.prototype.updateAnimTransform = function () {\n\n if (!this.scale) {\n this.scale = new THREE.Vector3(1, 1, 1);\n this.quaternion = new THREE.Quaternion(0, 0, 0, 1);\n this.position = new THREE.Vector3(0, 0, 0);\n }\n\n this.frags.updateAnimTransform(this.fragId, this.scale, this.quaternion, this.position);\n};\n\n/**\n * Returns the material associated with the fragment\n * @returns {THREE.Material} - Material\n */\nFragmentPointer.prototype.getMaterial = function () {\n return this.frags.getMaterial(this.fragId);\n\n};\n\n/**\n * Set a material to the current fragment\n * @example\n * var material = new THREE.MeshBasicMaterial({ color: 0xff0000 }); // Create a new material\n * fragPointer.setMaterial(material); // Assign the new material to the fragment\n */\nFragmentPointer.prototype.setMaterial = function (material) {\n\n return this.frags.setMaterial(this.fragId, material);\n\n};","import * as THREE from 'three';\n\n// Rearranged logically, base 3. X is 1's digit, Y is 10's digit, Z is 100's digit.\n// low/medium/high value is 0/1/2. So the center of the 3x3x3 space is == 111 base 3 == 13.\n// old 64-position code, which is what the comment indices are based on\n// var pos = ((this.eye.x < box.min.x) ? 1 : 0) // 1 = left\n// + ((this.eye.x > box.max.x) ? 2 : 0) // 2 = right\n// + ((this.eye.y < box.min.y) ? 4 : 0) // 4 = bottom\n// + ((this.eye.y > box.max.y) ? 8 : 0) // 8 = top\n// + ((this.eye.z < box.min.z) ? 16 : 0) // 16 = front\n// + ((this.eye.z > box.max.z) ? 32 : 0); // 32 = back\nvar _boxIndexList = // [27][7]\n[\n[1, 5, 4, 7, 3, 2, 6], //21 front, bottom, left\n[0, 3, 2, 1, 5, 4, 6], //20 front, bottom\n[0, 3, 2, 6, 5, 4, 6], //22 front, bottom, right\n[0, 4, 7, 3, 2, 1, 6], //17 front, left\n[0, 3, 2, 1, -1, -1, 4], //16 front\n[0, 3, 2, 6, 5, 1, 6], //18 front, right\n[0, 4, 7, 6, 2, 1, 6], //25 front, top, left\n[0, 3, 7, 6, 2, 1, 6], //24 front, top\n[0, 3, 7, 6, 5, 1, 6], //26 front, top, right\n[0, 1, 5, 4, 7, 3, 6], // 5 bottom, left\n[0, 1, 5, 4, -1, -1, 4], // 4 bottom\n[0, 1, 2, 6, 5, 4, 6], // 6 bottom, right\n[0, 4, 7, 3, -1, -1, 4], // 1 left\n[-1, -1, -1, -1, -1, -1, 0], // 0 inside\n[1, 2, 6, 5, -1, -1, 4], // 2 right\n[0, 4, 7, 6, 2, 3, 6], // 9 top, left \n[2, 3, 7, 6, -1, -1, 4], // 8 top\n[1, 2, 3, 7, 6, 5, 6], //10 top, right\n[0, 1, 5, 6, 7, 3, 6], //37 back, bottom, left\n[0, 1, 5, 6, 7, 4, 6], //36 back, bottom\n[0, 1, 2, 6, 7, 4, 6], //38 back, bottom, right\n[0, 4, 5, 6, 7, 3, 6], //33 back, left\n[4, 5, 6, 7, -1, -1, 4], //32 back\n[1, 2, 6, 7, 4, 5, 6], //34 back, right\n[0, 4, 5, 6, 2, 3, 6], //41 back, top, left\n[2, 3, 7, 4, 5, 6, 6], //40 back, top\n[1, 2, 3, 7, 4, 5, 6] //42 back, top, right\n];\n\n//Encapsulates frustum-box intersection logic\nexport function FrustumIntersector() {\n this.frustum = new THREE.Frustum();\n this.viewProj = new THREE.Matrix4();\n this.viewDir = [0, 0, 1];\n this.ar = 1.0;\n this.viewport = new THREE.Vector3(1, 1, 1);\n this.areaConv = 1;\n this.areaCullThreshold = 1; // The pixel size of the object projected on screen, will be culled if less than this value.\n this.eye = new THREE.Vector3();\n this.perspective = false; // assume orthographic camera to match viewProj\n}\n\nexport var OUTSIDE = 0;\nexport var INTERSECTS = 1;\nexport var CONTAINS = 2;\nexport var CONTAINMENT_UNKNOWN = -1;\nFrustumIntersector.OUTSIDE = OUTSIDE;\nFrustumIntersector.INTERSECTS = INTERSECTS;\nFrustumIntersector.CONTAINS = CONTAINS;\nFrustumIntersector.CONTAINMENT_UNKNOWN = CONTAINMENT_UNKNOWN;\n\n// @param {THREE.Vector4[]} [cutPlanes]\nFrustumIntersector.prototype.reset = function (camera, cutPlanes) {\n this.viewProj.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);\n this.perspective = camera.isPerspective;\n this.frustum.setFromMatrix(this.viewProj);\n var vm = camera.matrixWorldInverse.elements;\n this.ar = camera.aspect;\n this.viewDir[0] = -vm[2];\n this.viewDir[1] = -vm[6];\n this.viewDir[2] = -vm[10];\n this.eye.x = camera.position.x;\n this.eye.y = camera.position.y;\n this.eye.z = camera.position.z;\n this.areaConv = camera.clientWidth * camera.clientHeight / 4;\n this.cutPlanes = cutPlanes;\n};\n\nFrustumIntersector.prototype.projectedArea = function () {\n\n var points = [\n new THREE.Vector3(),\n new THREE.Vector3(),\n new THREE.Vector3(),\n new THREE.Vector3(),\n new THREE.Vector3(),\n new THREE.Vector3(),\n new THREE.Vector3(),\n new THREE.Vector3()];\n\n var tmpBox = new THREE.Box2();\n\n function applyProjection(p, m) {\n\n var x = p.x,y = p.y,z = p.z;\n var e = m.elements;\n\n var w = e[3] * x + e[7] * y + e[11] * z + e[15];\n\n //This is the difference between this function and\n //the normal THREE.Vector3.applyProjection. We avoid\n //inverting the positions of points behind the camera,\n //otherwise our screen area computation can result in\n //boxes getting clipped out when they are in fact partially visible.\n if (w < 0)\n w = -w;\n\n var d = 1.0 / w;\n\n p.x = (e[0] * x + e[4] * y + e[8] * z + e[12]) * d;\n p.y = (e[1] * x + e[5] * y + e[9] * z + e[13]) * d;\n\n //We also don't need the Z\n //p.z = ( e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] ) * d;\n }\n\n return function (box) {\n\n if (box.empty())\n return 0;\n\n var matrix = this.viewProj;\n\n // NOTE: I am using a binary pattern to specify all 2^3 combinations below\n points[0].set(box.min.x, box.min.y, box.min.z); // 000\n points[1].set(box.min.x, box.min.y, box.max.z); // 001\n points[2].set(box.min.x, box.max.y, box.min.z); // 010\n points[3].set(box.min.x, box.max.y, box.max.z); // 011\n points[4].set(box.max.x, box.min.y, box.min.z); // 100\n points[5].set(box.max.x, box.min.y, box.max.z); // 101\n points[6].set(box.max.x, box.max.y, box.min.z); // 110\n points[7].set(box.max.x, box.max.y, box.max.z); // 111\n\n for (var i = 0; i < 8; i++) {\n applyProjection(points[i], matrix);}\n\n tmpBox.makeEmpty();\n tmpBox.setFromPoints(points);\n\n // Clamp both min and max value between [-1.0, 1.0]\n if (tmpBox.min.x < -1.0)\n tmpBox.min.x = -1.0;\n if (tmpBox.min.x > 1.0)\n tmpBox.min.x = 1.0;\n if (tmpBox.min.y < -1.0)\n tmpBox.min.y = -1.0;\n if (tmpBox.min.y > 1.0)\n tmpBox.min.y = 1.0;\n\n if (tmpBox.max.x > 1.0)\n tmpBox.max.x = 1.0;\n if (tmpBox.max.x < -1.0)\n tmpBox.max.x = -1.0;\n if (tmpBox.max.y > 1.0)\n tmpBox.max.y = 1.0;\n if (tmpBox.max.y < -1.0)\n tmpBox.max.y = -1.0;\n\n return (tmpBox.max.x - tmpBox.min.x) * (tmpBox.max.y - tmpBox.min.y);\n };\n\n}();\n\n// A more precise estimator, based on https://github.com/erich666/jgt-code/blob/master/Volume_04/Number_2/Schmalstieg1999/bboxarea.cxx\n// Schmalstieg, Dieter, and Robert F. Tobler, \"Fast Projected Area Computation for Three-Dimensional Bounding Boxes,\" journal of graphics tools, 4(2):37-43, 1999.\n// Note: this code assumes that the silhouette corners will all project to be in front of the viewer. We do Take\n// corrective action if this is not the case, but it's of a \"well, negate the value\" nature, not a true clip fix.\n// It is assumed that frustum culling has already been applied, so that such cases should be rare.\n// So, for example, a long terrain tile below the viewer may get the corners behind the viewer transformed to be some\n// semi-arbitrary corner locations in front. ProjectedArea has the same problem. Since this method is used just to get\n// a rough idea of the importance of a fragment, we don't spend a lot of time on fixing this. If a corner is detected\n// as behind the eye, we could instead return an area of 4, i.e., it fills the screen.\nFrustumIntersector.prototype.projectedBoxArea = function () {\n\n var sizeClippedPolygon;\n\n // maximum of 6 points in silhouette, plus 4 points, one for each clip edge\n var points = [];\n var pointsSwap = [];\n for (var i = 0; i < 10; i++) {\n points.push(new THREE.Vector3());\n pointsSwap.push(new THREE.Vector3());\n }\n\n // TODO: same as projectedArea - should this implementation be a derived class? How to do that in javascript?\n function applyProjection(p, m) {\n\n var x = p.x,y = p.y,z = p.z;\n var e = m.elements;\n\n var w = e[3] * x + e[7] * y + e[11] * z + e[15];\n\n //This is the difference between this function and\n //the normal THREE.Vector3.applyProjection. We avoid\n //inverting the positions of points behind the camera,\n //otherwise our screen area computation can result in\n //boxes getting clipped out when they are in fact partially visible.\n if (w < 0)\n w = -w;\n\n var d = 1.0 / w;\n\n p.x = (e[0] * x + e[4] * y + e[8] * z + e[12]) * d;\n p.y = (e[1] * x + e[5] * y + e[9] * z + e[13]) * d;\n\n //We also don't need the Z\n //p.z = ( e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] ) * d;\n }\n\n // Optimized to clip against -1 to 1 NDC in X and Y.\n // NOTE: this modifies the clipPolygon being passed in, as the\n // code takes four passes (for each edge of the screen) and ping-pongs\n // the data between clipPolygon (really, the \"points\" array) and pointsSwap, a temporary buffer.\n // Doing so saves us from having to copy data or duplicate code.\n function clip(clipPolygon, sizePolygon) {\n var polygonSource = clipPolygon;\n var polygonDest = pointsSwap;\n var polygonSwap;\n var prevPt, thisPt, prevIn, thisIn;\n var numPt, numClip;\n var newSizePolygon;\n\n var testInside = function testInside(pt) {\n switch (numClip) {\n case 0:\n return pt.x >= -1;\n case 1:\n return pt.x <= 1;\n case 2:\n return pt.y >= -1;\n case 3:\n return pt.y <= 1;}\n\n };\n var savePoint = function savePoint(pt) {\n polygonDest[newSizePolygon].x = pt.x;\n polygonDest[newSizePolygon++].y = pt.y;\n };\n var saveIntersect = function saveIntersect() {\n var ptx, pty;\n switch (numClip) {\n case 0:\n ptx = -1;\n pty = prevPt.y + (thisPt.y - prevPt.y) * (ptx - prevPt.x) / (thisPt.x - prevPt.x);\n break;\n case 1:\n ptx = 1;\n pty = prevPt.y + (thisPt.y - prevPt.y) * (ptx - prevPt.x) / (thisPt.x - prevPt.x);\n break;\n case 2:\n pty = -1;\n ptx = prevPt.x + (thisPt.x - prevPt.x) * (pty - prevPt.y) / (thisPt.y - prevPt.y);\n break;\n case 3:\n pty = 1;\n ptx = prevPt.x + (thisPt.x - prevPt.x) * (pty - prevPt.y) / (thisPt.y - prevPt.y);\n break;}\n\n polygonDest[newSizePolygon].x = ptx;\n polygonDest[newSizePolygon++].y = pty;\n };\n\n // If polygon size <= 2, it will have no area, so don't care. We need this test to avoid\n // access polygonSource[-1] when size === 0.\n for (numClip = 0; numClip < 4 && sizePolygon > 2; numClip++) {\n newSizePolygon = 0;\n prevPt = polygonSource[sizePolygon - 1];\n prevIn = testInside(prevPt);\n for (numPt = 0; numPt < sizePolygon; numPt++) {\n thisPt = polygonSource[numPt];\n thisIn = testInside(thisPt);\n if (prevIn) {\n if (thisIn) {\n // edge is entirely in - save point\n savePoint(thisPt);\n } else {\n // edge is exiting - save intersection\n saveIntersect();\n }\n } else {\n // edge starts out\n if (thisIn) {\n // edge is entering - save intersection and point\n saveIntersect();\n savePoint(thisPt);\n }\n //else {\n // edge is still out - save nothing\n //}\n }\n prevPt = thisPt;\n prevIn = thisIn;\n }\n\n // swap for next round\n sizePolygon = newSizePolygon;\n polygonSwap = polygonSource;\n polygonSource = polygonDest;\n polygonDest = polygonSwap;\n }\n sizeClippedPolygon = sizePolygon;\n return polygonSource;\n }\n\n // if not specified, perform clip\n return function (box, doNotClip) {\n\n if (box.empty())\n return 0;\n\n var matrix = this.viewProj;\n\n //compute the array index to classify eye with respect to the 6 defining planes\n //of the bbox, 0-26\n var pos;\n if (this.perspective) {\n if (this.eye.x >= box.min.x) {\n pos = this.eye.x > box.max.x ? 2 : 1;\n } else {\n pos = 0;\n }\n if (this.eye.y >= box.min.y) {\n pos += this.eye.y > box.max.y ? 6 : 3;\n }\n if (this.eye.z >= box.min.z) {\n pos += this.eye.z > box.max.z ? 18 : 9;\n }\n } else {\n if (this.viewDir[0] <= 0) {\n pos = this.viewDir[0] < 0 ? 2 : 1;\n } else {\n pos = 0;\n }\n if (this.viewDir[1] <= 0) {\n pos += this.viewDir[1] < 0 ? 6 : 3;\n }\n if (this.viewDir[2] <= 0) {\n pos += this.viewDir[2] < 0 ? 18 : 9;\n }\n }\n\n // 13 indicates eye location is inside box, index 1+3+9, so return full screen area\n if (pos === 13) {\n return 4;\n }\n var num = _boxIndexList[pos][6]; //look up number of vertices in outline\n\n //generate 8 corners of the bbox, as needed\n // run through \"num\" points and create and transform just those\n var i;\n for (i = 0; i < num; i++) {\n var idx = _boxIndexList[pos][i];\n // tricksiness here: order is (though this is left-handed; we use right-handed)\n // (min[0],min[1],min[2]); // 7+------+6\n // (max[0],min[1],min[2]); // /| /|\n // (max[0],max[1],min[2]); // / | / |\n // (min[0],max[1],min[2]); // / 4+---/--+5\n // (min[0],min[1],max[2]); // 3+------+2 / y z\n // (max[0],min[1],max[2]); // | / | / | /\n // (max[0],max[1],max[2]); // |/ |/ |/\n // (min[0],max[1],max[2]); // 0+------+1 *---x\n\n points[i].set(\n (idx + 1) % 4 < 2 ? box.min.x : box.max.x,\n idx % 4 < 2 ? box.min.y : box.max.y,\n idx < 4 ? box.min.z : box.max.z);\n\n applyProjection(points[i], matrix);\n }\n\n var sum = 0;\n // always clip if needed; TODO: make more efficient, i.e., don't alloc each time.\n if (doNotClip) {\n sum = (points[num - 1].x - points[0].x) * (points[num - 1].y + points[0].y);\n for (i = 0; i < num - 1; i++) {\n sum += (points[i].x - points[i + 1].x) * (points[i].y + points[i + 1].y);}\n } else {\n var clippedPolygon = clip(points, num);\n // see if clipped polygon has anything returned at all; if not, area is 0\n if (sizeClippedPolygon >= 3) {\n sum = (clippedPolygon[sizeClippedPolygon - 1].x - clippedPolygon[0].x) * (clippedPolygon[sizeClippedPolygon - 1].y + clippedPolygon[0].y);\n for (i = 0; i < sizeClippedPolygon - 1; i++) {\n sum += (clippedPolygon[i].x - clippedPolygon[i + 1].x) * (clippedPolygon[i].y + clippedPolygon[i + 1].y);}\n }\n }\n\n // avoid winding order left-handed/right-handed headaches by taking abs(); fixes clockwise loops\n return Math.abs(sum * 0.5); //return computed value corrected by 0.5\n };\n\n}();\n\nFrustumIntersector.prototype.estimateDepth = function (bbox) {\n\n var e = this.viewProj.elements;\n\n // Take center of box and find its distance from the eye.\n var x = (bbox.min.x + bbox.max.x) / 2.0;\n var y = (bbox.min.y + bbox.max.y) / 2.0;\n var z = (bbox.min.z + bbox.max.z) / 2.0;\n\n // not used: var w = e[3] * x + e[7] * y + e[11] * z + e[15];\n\n var d = 1.0 / (e[3] * x + e[7] * y + e[11] * z + e[15]);\n\n return (e[2] * x + e[6] * y + e[10] * z + e[14]) * d;\n\n};\n\nFrustumIntersector.prototype.intersectsBox = function () {\n\n //Copied from three.js and modified to return separate\n //value for full containment versus intersection.\n //Return values: 0 -> outside, 1 -> intersects, 2 -> contains\n var p1 = new THREE.Vector3();\n var p2 = new THREE.Vector3();\n\n return function (box) {\n\n var planes = this.frustum.planes;\n var contained = 0;\n\n for (var i = 0; i < 6; i++) {\n\n var plane = planes[i];\n\n p1.x = plane.normal.x > 0 ? box.min.x : box.max.x;\n p2.x = plane.normal.x > 0 ? box.max.x : box.min.x;\n p1.y = plane.normal.y > 0 ? box.min.y : box.max.y;\n p2.y = plane.normal.y > 0 ? box.max.y : box.min.y;\n p1.z = plane.normal.z > 0 ? box.min.z : box.max.z;\n p2.z = plane.normal.z > 0 ? box.max.z : box.min.z;\n\n var d1 = plane.distanceToPoint(p1);\n var d2 = plane.distanceToPoint(p2);\n\n // if both outside plane, no intersection\n\n if (d1 < 0 && d2 < 0) {\n\n return FrustumIntersector.OUTSIDE;\n\n }\n\n if (d1 > 0 && d2 > 0) {\n\n contained++;\n\n }\n }\n\n return contained == 6 ? FrustumIntersector.CONTAINS : FrustumIntersector.INTERSECTS;\n };\n\n\n}();\n\nfunction getCorner(box, i, target) {\n target.x = i & 1 ? box.max.x : box.min.x;\n target.y = i & 2 ? box.max.y : box.min.y;\n target.z = i & 4 ? box.max.z : box.min.z;\n return target;\n}\n\nfunction pointOutsideCutPlane(point, cutPlane) {\n var dp = point.x * cutPlane.x + point.y * cutPlane.y + point.z * cutPlane.z + cutPlane.w;\n return dp > 1e-6;\n}\n\nvar boxOutsideCutPlane = function () {\n\n var _tmp;\n return function (box, plane) {\n\n if (!_tmp) _tmp = new THREE.Vector3();\n\n // for each corner...\n for (var i = 0; i < 8; i++) {\n // stop if corner i is outside\n var corner = getCorner(box, i, _tmp);\n if (!pointOutsideCutPlane(corner, plane)) {\n return false;\n }\n }\n // all corners are in the outer half-space\n return true;\n };\n}();\n\n// Returns true if the given box is fully in the outer half-space of an active cut plane\nFrustumIntersector.prototype.boxOutsideCutPlanes = function (box) {\n if (!this.cutPlanes) {\n return false;\n }\n\n for (var i = 0; i < this.cutPlanes.length; i++) {\n var plane = this.cutPlanes[i];\n if (boxOutsideCutPlane(box, plane)) {\n return true;\n }\n }\n return false;\n};","import * as globals from '../globals';\nimport { isMobileDevice } from \"../../compat\";\nimport * as THREE from \"three\";\n\n/**\n * Maintains a list of buffer geometries and running totals of their memory usage, etc.\n * Each geometry gets an integer ID to be used as reference in packed fragment lists.\n * @param {number} numObjects Number of objects (may be 0 if not known in advance).\n * @param {boolean} is2d True for 2D datasets.\n * @param {boolean} [disableStreaming] Set to true for small models to enforce full GPU upload.\n * @constructor\n */\nexport function GeometryList(numObjects, is2d, disableStreaming, isUnitBoxes) {\n // array of BufferGeometry instances. Indexed by svfid.\n this.geoms = [null]; //keep index 0 reserved for invalid id\n\n this.numGeomsInMemory = 0; // total number of geoms added via addGeometry(..) (may be = GPU_MEMORY_HIGH) {\n //We are above the upper limit, so mesh is automatically\n //assigned to streaming draw\n geometry.streamingDraw = true;\n geometry.streamingIndex = true;\n } else {\n //Between the lower and upper limits,\n //Score mesh importance based on its size\n //and number of instances it has. If the score\n //is high, we will prefer to put the mesh on the GPU\n //so that we don't schlep it across the bus all the time.\n var weightScore;\n\n if (!this.is2d) {\n weightScore = geometry.byteSize * (numInstances || 1);\n } else {\n //In the case of 2D, there are no instances, so we just keep\n //piling into the GPU until we reach the \"high\" mark.\n weightScore = 100001;\n }\n\n if (weightScore < 100000) {\n geometry.streamingDraw = true;\n geometry.streamingIndex = true;\n }\n }\n};\n\n/**\n * Stores geometry in this.geoms, updates overall GPU/CPU statistics (this.geometry etc.),\n * changes the geometry object:\n * - Sets geometry.streamingDraw/streamingIndex (to control whether to draw the mesh from system mem or GPU)\n * - Sets geometry.svfid, so that each geom knows its index.\n * - Deletes the bbox and bsphere to safe memory\n * Assumptions:\n * - It is not expected to be called multiple times for the same svfid. This would mess up some statistics.\n * @param {LmvBufferGeometry} geometry - Must not be null. A geometry cannot be added\n * to more than one GeometryList. (see below why)\n * @param {number} numInstances - default 1 if undef.\n * @param {number} svfid - Geometry will be stored in this.geoms[svfid].\n * If undef or <=0, geometry is appended at the end of this.geoms.\n */\nGeometryList.prototype.addGeometry = function (geometry, numInstances, svfid) {\n this.chooseMemoryType(geometry, numInstances, this.gpuNumMeshes, this.gpuMeshMemory);\n\n // track overall GPU workload\n var size = geometry.byteSize + globals.GEOMETRY_OVERHEAD;\n if (!geometry.streamingDraw) {\n if (isMobileDevice())\n size += geometry.byteSize;\n this.gpuMeshMemory += geometry.byteSize;\n this.gpuNumMeshes += 1;\n }\n\n this.numGeomsInMemory++;\n\n // if no svfid is defined\n if (svfid === undefined || svfid <= 0)\n svfid = this.geoms.length;\n\n // store geometry (may increase array length)\n this.geoms[svfid] = geometry;\n\n if (this.geomBoxes) {\n // resize this.geombboxes if necessary\n var fill = this.geomBoxes.length / 6 | 0;\n if (fill < this.geoms.length) {\n var end = this.geoms.length * 3 / 2 | 0;\n var nb = new Float32Array(6 * end);\n nb.set(this.geomBoxes);\n // Make all of the new bounds empty\n var empty = new THREE.Box3();\n empty.makeEmpty();\n while (fill < end) {\n nb[fill * 6] = empty.min.x;\n nb[fill * 6 + 1] = empty.min.y;\n nb[fill * 6 + 2] = empty.min.z;\n nb[fill * 6 + 3] = empty.max.x;\n nb[fill * 6 + 4] = empty.max.y;\n nb[fill++ * 6 + 5] = empty.max.z;\n }\n this.geomBoxes = nb;\n }\n\n // copy geometry bbox to this.geomBoxes\n var bb = geometry.boundingBox;\n if (!bb) {\n if (!geometry.hash) {\n console.error(\"Mesh without bbox and without hash should not be.\");\n }\n this.geomBoxes[svfid * 6] = -0.5;\n this.geomBoxes[svfid * 6 + 1] = -0.5;\n this.geomBoxes[svfid * 6 + 2] = -0.5;\n this.geomBoxes[svfid * 6 + 3] = 0.5;\n this.geomBoxes[svfid * 6 + 4] = 0.5;\n this.geomBoxes[svfid * 6 + 5] = 0.5;\n } else {\n this.geomBoxes[svfid * 6] = bb.min.x;\n this.geomBoxes[svfid * 6 + 1] = bb.min.y;\n this.geomBoxes[svfid * 6 + 2] = bb.min.z;\n this.geomBoxes[svfid * 6 + 3] = bb.max.x;\n this.geomBoxes[svfid * 6 + 4] = bb.max.y;\n this.geomBoxes[svfid * 6 + 5] = bb.max.z;\n }\n }\n\n //Free the bbx objects if we don't want them.\n if (globals.memoryOptimizedLoading && !this.is2d) {\n geometry.boundingBox = null;\n geometry.boundingSphere = null;\n }\n\n // track system-side memory\n this.geomMemory += size;\n\n // track polygon count\n //TODO: Asssignment into the svf is temporary until the dependencies\n //are unentangled\n var ib = geometry.attributes['index'] && geometry.attributes['index'].array || geometry.ib;\n var perPoly = geometry.isLines ? 2 : 3;\n var polyCount;\n if (ib) {\n polyCount = ib.length / perPoly;\n } else if (geometry.vb) {\n polyCount = geometry.vb.length / (perPoly * geometry.stride);\n } else {\n polyCount = geometry.attributes['position'].length / (3 * perPoly);\n }\n this.geomPolyCount += polyCount;\n this.instancePolyCount += polyCount * (numInstances || 1);\n\n // Record the count that can be decrease properly when geometry removed.\n geometry.polyCount = polyCount;\n geometry.instanceCount = numInstances || 1;\n\n geometry.svfid = svfid;\n\n return svfid;\n};\n\n/**\n * Removes the geometry with svfid 'idx' from the list.\n * Note: Unlike addGeometry, this method only updates this.numGeomsInMemory. All other statistics keep the same.\n * @param {int} idx - Geometry ID.\n * @returns {int} Size of the removed geometry, or 0.\n */\nGeometryList.prototype.removeGeometry = function (idx, renderer) {\n // if there is no geom assigned, just return 0\n var geometry = this.getGeometry(idx);\n if (!geometry) {\n return 0;\n }\n var size = geometry.byteSize + globals.GEOMETRY_OVERHEAD;\n renderer && renderer.deallocateGeometry(geometry);\n if (!geometry.streamingDraw) {\n if (isMobileDevice())\n size += geometry.byteSize;\n this.gpuMeshMemory -= geometry.byteSize;\n this.gpuNumMeshes -= 1;\n }\n\n // remove geometry from the list\n this.geoms[idx] = null;\n\n // decrease its related counts\n this.geomMemory -= size;\n this.numGeomsInMemory--;\n this.geomPolyCount -= geometry.polyCount;\n this.instancePolyCount -= geometry.instanceCount * geometry.polyCount;\n\n return size;\n};\n\n\n/**\n * Returns bounding box of a geometry.\n * @param {number} geomid - Geometry ID.\n * @param {THREE.Box3|LmvBox3} dst - Set to empty is there is no geometry of this id.\n */\nGeometryList.prototype.getModelBox = function (geomid, dst) {\n\n //In case of OTG models, we do not store the geometry bounds, because\n //they are all unit boxes.\n if (!this.geomBoxes) {\n // Note: Since 0 is reserved as invalid geometry-index, the geometries start at 1\n // and this.numObjects itself is still a valid index. Therefore <=.\n if (geomid >= 1 && geomid <= this.numObjects) {\n dst.min.x = -0.5;\n dst.min.y = -0.5;\n dst.min.z = -0.5;\n dst.max.x = 0.5;\n dst.max.y = 0.5;\n dst.max.z = 0.5;\n } else {\n dst.makeEmpty();\n }\n return;\n }\n\n // return empty box if geomid is out of bounds. If the id is in bounds\n // then the stored bbox is empty if the geometry hasn't been loaded \n if (geomid === 0 || this.geomBoxes.length / 6 <= geomid) {\n dst.makeEmpty();\n return;\n }\n\n // extract bbox values from Float32Array this.geomboxes\n var off = geomid * 6;\n var bb = this.geomBoxes;\n dst.min.x = bb[off];\n dst.min.y = bb[off + 1];\n dst.min.z = bb[off + 2];\n dst.max.x = bb[off + 3];\n dst.max.y = bb[off + 4];\n dst.max.z = bb[off + 5];\n};\n\n// Tell renderer to release all GPU buffers. \n// renderer: instaneof FireFlyWebGLRenderer\nGeometryList.prototype.dispose = function (renderer) {\n if (!renderer)\n return;\n\n for (var i = 0, iEnd = this.geoms.length; i < iEnd; i++) {\n if (this.geoms[i])\n renderer.deallocateGeometry(this.geoms[i]);\n }\n};\n\nGeometryList.prototype.printStats = function () {\n THREE.log(\"Total geometry size: \" + this.geomMemory / (1024 * 1024) + \" MB\");\n THREE.log(\"Number of meshes: \" + (this.geoms.length - 1));\n THREE.log(\"Num Meshes on GPU: \" + this.gpuNumMeshes);\n THREE.log(\"Net GPU geom memory used: \" + this.gpuMeshMemory);\n};","\nimport { SelectionMode } from \"./SelectionMode\";\nimport { logger } from \"../../logger/Logger\";\n\nvar NODE_TYPE_ASSEMBLY = 0x0, // Real world object as assembly of sub-objects\nNODE_TYPE_INSERT = 0x1, // Insert of multiple-instanced object\nNODE_TYPE_LAYER = 0x2, // A layer (specific abstraction collection)\nNODE_TYPE_COLLECTION = 0x3, // An abstract collection of objects (e.g. “Doors”)\nNODE_TYPE_COMPOSITE = 0x4, // A real world object whose internal structure is not relevant to end user\nNODE_TYPE_MODEL = 0x5, // Root of tree representing an entire Model. An aggregate model can contain multiple nested models.\nNODE_TYPE_GEOMETRY = 0x6, // Leaf geometry node\nNODE_TYPE_BITS = 0x7, //mask for all bits used by node type\n\nNODE_FLAG_NOSELECT = 0x20000000,\nNODE_FLAG_OFF = 0x40000000,\nNODE_FLAG_HIDE = 0x80000000,\n\n// Flags defined and used in LMV\nNODE_FLAG_LOCK_VISIBLE = 0x00001000,\nNODE_FLAG_LOCK_EXPLODE = 0x00002000,\nNODE_FLAG_LOCK_SELECT = 0x00004000;\n\n/**\n * \n * @constructor\n * @memberof Autodesk.Viewing.Private\n * @alias Autodesk.Viewing.Private.InstanceTree\n */\nexport function InstanceTree(nodeAccess, objectCount, maxDepth) {\n\n this.nodeAccess = nodeAccess;\n this.maxDepth = maxDepth;\n this.objectCount = objectCount;\n this.numHidden = 0;\n this.numOff = 0;\n\n // when not using precomputed nodeBoxes, fragments are used for on-the-fly bbox computation\n this.fragList = null;\n}\n\n\nInstanceTree.prototype.setFlagNode = function (dbId, flag, value) {\n\n var old = this.nodeAccess.getNodeFlags(dbId);\n\n // \"!!\" converts to bool\n if (!!(old & flag) == value)\n return false;\n\n if (value)\n this.nodeAccess.setNodeFlags(dbId, old | flag);else\n\n this.nodeAccess.setNodeFlags(dbId, old & ~flag);\n\n return true;\n};\n\nInstanceTree.prototype.setFlagGlobal = function (flag, value) {\n var na = this.nodeAccess;\n\n var i = 0,iEnd = na.numNodes;\n if (value) {\n for (; i < iEnd; i++) {\n na.setNodeFlags(i, na.getNodeFlags(i) | flag);\n }\n } else {\n var notflag = ~flag;\n for (; i < iEnd; i++) {\n na.setNodeFlags(i, na.getNodeFlags(i) & notflag);\n }\n }\n};\n\n/**\n * When a node is OFF, it is completely skipped for display purposes\n */\nInstanceTree.prototype.setNodeOff = function (dbId, value) {\n var res = this.setFlagNode(dbId, NODE_FLAG_OFF, value);\n if (res) {\n if (value)\n this.numOff++;else\n\n this.numOff--;\n }\n return res;\n};\n\nInstanceTree.prototype.isNodeOff = function (dbId) {\n return !!(this.nodeAccess.getNodeFlags(dbId) & NODE_FLAG_OFF);\n};\n\n\n/**\n * When a node is HIDDEN it will display in ghosted style\n * if display of hidden objects is on\n */\nInstanceTree.prototype.setNodeHidden = function (dbId, value) {\n var res = this.setFlagNode(dbId, NODE_FLAG_HIDE, value);\n if (res) {\n if (value)\n this.numHidden++;else\n\n this.numHidden--;\n }\n return res;\n};\n\n/**\n * Whether a node id is hidden.\n * @param {number} dbId - The node's database id\n * @returns {boolean} \n * @alias Autodesk.Viewing.Private.InstanceTree#isNodeHidden\n */\nInstanceTree.prototype.isNodeHidden = function (dbId) {\n return !!(this.nodeAccess.getNodeFlags(dbId) & NODE_FLAG_HIDE);\n};\n\nInstanceTree.prototype.lockNodeSelection = function (dbId, value) {\n return this.setFlagNode(dbId, NODE_FLAG_LOCK_SELECT, value);\n};\n\nInstanceTree.prototype.isNodeSelectionLocked = function (dbId) {\n return !!(this.nodeAccess.getNodeFlags(dbId) & NODE_FLAG_LOCK_SELECT);\n};\n\n/**\n * When a node's visibility is locked it can not be hidden\n */\nInstanceTree.prototype.lockNodeVisible = function (dbId, value) {\n return this.setFlagNode(dbId, NODE_FLAG_LOCK_VISIBLE, value);\n};\n\n/**\n * Whether a node id's explode is locked.\n * @param {number} dbId - The node's database id\n * @returns {boolean} \n * @alias Autodesk.Viewing.Private.InstanceTree#isNodeHidden\n */\nInstanceTree.prototype.isNodeVisibleLocked = function (dbId) {\n return !!(this.nodeAccess.getNodeFlags(dbId) & NODE_FLAG_LOCK_VISIBLE);\n};\n\n/**\n * Whether a node id's visibility is locked.\n * @param {number} dbId - The node's database id\n * @returns {boolean} \n * @alias Autodesk.Viewing.Private.InstanceTree#isNodeHidden\n */\nInstanceTree.prototype.isNodeExplodeLocked = function (dbId) {\n return !!(this.nodeAccess.getNodeFlags(dbId) & NODE_FLAG_LOCK_EXPLODE);\n};\n\n/**\n * When a node's explode is locked it won't explode\n */\nInstanceTree.prototype.lockNodeExplode = function (dbId, value) {\n return this.setFlagNode(dbId, NODE_FLAG_LOCK_EXPLODE, value);\n};\n\n/**\n * Gets the type associated with the node, such as assmebly, layer, model, geometry, etc.\n * \n * @param {number} dbId - The node's database id\n * @returns {number} \n * @alias Autodesk.Viewing.Private.InstanceTree#getNodeType\n */\nInstanceTree.prototype.getNodeType = function (dbId) {\n return this.nodeAccess.getNodeFlags(dbId) & NODE_TYPE_BITS;\n};\n\n/**\n * Whether the node is a selectable entity.\n * \n * @param {number} dbId - The node's database id\n * @returns {boolean} \n * @alias Autodesk.Viewing.Private.InstanceTree#isNodeSelectable\n */\nInstanceTree.prototype.isNodeSelectable = function (dbId) {\n return !(this.nodeAccess.getNodeFlags(dbId) & NODE_FLAG_NOSELECT);\n};\n\n/**\n * Gets the database id of the node's parent.\n * \n * @param {number} dbId - The node's database id\n * @returns {number} \n * @alias Autodesk.Viewing.Private.InstanceTree#getNodeParentId\n */\nInstanceTree.prototype.getNodeParentId = function (dbId) {\n return this.nodeAccess.getParentId(dbId);\n};\n\n/**\n * Gets the model's root database id.\n * \n * @returns {number} \n * @alias Autodesk.Viewing.Private.InstanceTree#getRootId\n */\nInstanceTree.prototype.getRootId = function () {\n return this.nodeAccess.rootId;\n};\n\n/**\n * Gets the name associated to the id.\n * \n * @param {number} dbId - The node's database id\n * @returns {string} \n * @alias Autodesk.Viewing.Private.InstanceTree#getNodeName\n */\nInstanceTree.prototype.getNodeName = function (dbId, includeCount) {\n return this.nodeAccess.name(dbId, includeCount);\n};\n\n/**\n * Gets get number of children under the specified id.\n * \n * @param {number} dbId - The node's database id\n * @returns {number} \n * @alias Autodesk.Viewing.Private.InstanceTree#getChildCount\n */\nInstanceTree.prototype.getChildCount = function (dbId) {\n return this.nodeAccess.getNumChildren(dbId);\n};\n\n\nvar _tmpArray = new Array(6);\n\n/**\n * Sets the bounding box values for a particular id on the 2nd argument provided.\n * There is no return value.\n * \n * @param {number} dbId - The node's database id\n * @param {Float32Array} dst - An array holding 6 number values: (min-x, min-y, min-z, max-x, max-y, max-z)\n * \n * @alias Autodesk.Viewing.Private.InstanceTree#getNodeBox\n */\nInstanceTree.prototype.getNodeBox = function (dbId, dst) {\n\n // If precomputed boxes are available, just return the box directly.\n if (this.nodeAccess.nodeBoxes) {\n this.nodeAccess.getNodeBox(dbId, dst);\n return;\n }\n\n // If fragList is available, compute nodeBox recursively from fragBoxes\n var fl = this.fragList;\n if (fl) {\n dst[0] = dst[1] = dst[2] = Infinity;\n dst[3] = dst[4] = dst[5] = -Infinity;\n this.enumNodeFragments(dbId, function (fragId) {\n fl.getOriginalWorldBounds(fragId, _tmpArray);\n dst[0] = Math.min(dst[0], _tmpArray[0]);\n dst[1] = Math.min(dst[1], _tmpArray[1]);\n dst[2] = Math.min(dst[2], _tmpArray[2]);\n dst[3] = Math.max(dst[3], _tmpArray[3]);\n dst[4] = Math.max(dst[4], _tmpArray[4]);\n dst[5] = Math.max(dst[5], _tmpArray[5]);\n }, true);\n return;\n }\n\n logger.error('getNodeBox() requires fragBoxes or nodeBoxes');\n};\n\n\nInstanceTree.prototype.getNodeIndex = function (dbId) {\n return this.nodeAccess.getIndex(dbId);\n};\n\n/**\n * Callback function for {@link Autodesk.Viewing.Private.InstanceTree#enumNodeFragments}\n * @callback Autodesk.Viewing.Private.InstanceTree~onEnumNodeFragments\n * @param {number} fragId - The fragment's id.\n */\n\n/**\n * \n * @param {number} node - The id of a node.\n * @param {Autodesk.Viewing.Private.InstanceTree~onEnumNodeFragments} callback - Function that will be called for each fragment.\n * @param {boolean} [recursive=false] - Whether the callback function gets called for child nodes, too. \n * \n * @alias Autodesk.Viewing.Private.InstanceTree#enumNodeFragments\n */\nInstanceTree.prototype.enumNodeFragments = function (node, callback, recursive) {\n\n //TODO: Temporary until we are consistently using dbId\n var dbId;\n if (typeof node == \"number\")\n dbId = node;else\n if (node)\n dbId = node.dbId;\n\n var self = this;\n\n function traverse(dbId) {\n\n var res = self.nodeAccess.enumNodeFragments(dbId, callback);\n\n if (res)\n return res;\n\n if (recursive) {\n res = self.enumNodeChildren(dbId, function (child_dbId) {\n return traverse(child_dbId);\n });\n\n if (res)\n return res;\n }\n }\n\n return traverse(dbId);\n\n};\n\n/**\n * Callback function for {@link Autodesk.Viewing.Private.InstanceTree#enumNodeChildren}\n * @callback Autodesk.Viewing.Private.InstanceTree~onEnumNodeChildren\n * @param {number} dbId - A database id\n */\n\n/**\n * \n * @param {number} node - The id of a node.\n * @param {Autodesk.Viewing.Private.InstanceTree~onEnumNodeChildren} callback - Function that will be called for each child node.\n * @param {boolean} [recursive=false] - Whether the callback function gets called for indirect child nodes, too. \n * \n * @alias Autodesk.Viewing.Private.InstanceTree#enumNodeChildren\n */\nInstanceTree.prototype.enumNodeChildren = function (node, callback, recursive) {\n\n //TODO: Temporary until we are consistently using dbId\n var dbId;\n if (typeof node == \"number\")\n dbId = node;else\n if (node)\n dbId = node.dbId;\n\n var self = this;\n\n if (recursive) {\n if (callback(dbId))\n return dbId;\n }\n\n function traverse(dbId) {\n\n var res = self.nodeAccess.enumNodeChildren(dbId, function (childId) {\n if (callback(childId))\n return childId;\n\n if (recursive)\n return traverse(childId);\n });\n\n if (res)\n return res;\n }\n\n return traverse(dbId);\n};\n\n\n//Given a leaf node, find the correct parent\n//node to select according to the given selection mode\nInstanceTree.prototype.findNodeForSelection = function (dbId, selectionMode) {\n\n //Default legacy mode -- select exactly the node we got asked for.\n if (selectionMode === SelectionMode.LEAF_OBJECT)\n return dbId;\n\n var res = dbId;\n var node, nt;\n\n if (selectionMode === SelectionMode.FIRST_OBJECT) {\n //1. Find the leaf node of the selection tree containing it and then follow the chain of parents all the way up to the root to get the complete path from root to leaf node.\n //2. Start at the root and walk down the path until the first node that is not a Model, Layer or Collection. Select it.\n var idpath = [];\n\n node = dbId;\n while (node) {\n idpath.push(node);\n node = this.getNodeParentId(node);\n }\n\n for (var i = idpath.length - 1; i >= 0; i--) {\n nt = this.getNodeType(idpath[i]);\n if (nt !== NODE_TYPE_MODEL &&\n nt !== NODE_TYPE_LAYER &&\n nt !== NODE_TYPE_COLLECTION) {\n res = idpath[i];\n break;\n }\n }\n } else\n\n if (selectionMode === SelectionMode.LAST_OBJECT) {\n // Start at the leaf and walk up the path until the first node that is Composite. Select it. If there’s no Composite node in the path select the leaf.\n\n node = dbId;\n while (node) {\n nt = this.getNodeType(node);\n if (nt === NODE_TYPE_COMPOSITE) {\n res = node;\n break;\n }\n node = this.getNodeParentId(node);\n }\n\n }\n\n return res;\n\n};\n\n// When not using precomputed bboxes, the fragment boxes are needed for on-the-fly computation of node boxes.\nInstanceTree.prototype.setFragmentList = function (fragList) {\n this.fragList = fragList;\n};","function _classCallCheck(instance, Constructor) {if (!(instance instanceof Constructor)) {throw new TypeError(\"Cannot call a class as a function\");}}function _defineProperties(target, props) {for (var i = 0; i < props.length; i++) {var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if (\"value\" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);}}function _createClass(Constructor, protoProps, staticProps) {if (protoProps) _defineProperties(Constructor.prototype, protoProps);if (staticProps) _defineProperties(Constructor, staticProps);return Constructor;}\nimport { utf16to8, utf8BlobToStr } from \"../../file-loaders/lmvtk/common/StringUtils\";\n\n\nexport var FlatStringStorage = /*#__PURE__*/function () {\n\n function FlatStringStorage(initial) {_classCallCheck(this, FlatStringStorage);\n if (initial) {\n this.buf = initial.buf;\n this.idx = initial.idx;\n this.next = initial.next;\n } else {\n this.buf = new Uint8Array(256);\n this.next = 0;\n this.idx = [0];\n }\n }_createClass(FlatStringStorage, [{ key: \"allocate\", value: function allocate(\n\n len) {\n if (this.buf.length - this.next < len) {\n var nsz = Math.max(this.buf.length * 3 / 2, this.buf.length + len);\n var nb = new Uint8Array(nsz);\n nb.set(this.buf);\n this.buf = nb;\n }\n } }, { key: \"add\", value: function add(\n\n s) {\n if (s === null || typeof s === \"undefined\") {\n return 0;\n }\n\n if (!s.length) {\n this.idx.push(this.next);\n return this.idx.length - 1;\n }\n\n var len = utf16to8(s, null);\n this.allocate(len);\n this.next += utf16to8(s, this.buf, this.next);\n this.idx.push(this.next);\n return this.idx.length - 1;\n } }, { key: \"get\", value: function get(\n\n i) {\n if (!i) {\n return undefined;\n }\n\n var start = this.idx[i - 1];\n var end = this.idx[i];\n if (start === end)\n return \"\";\n return utf8BlobToStr(this.buf, start, end - start);\n } }, { key: \"flatten\", value: function flatten()\n\n {\n this.idx = arrayToBuffer(this.idx);\n //TODO: we could also clip this.buf to the actually used size, but that requires reallocation\n } }]);return FlatStringStorage;}();\n\n\n\n\n//\n// struct Node {\n// int dbId;\n// int parentDbId;\n// int firstChild; //if negative it's a fragment list\n// int numChildren;\n// int flags; \n// };\n// sizeof(Node) == 20\nvar SIZEOF_NODE = 5, //integers\nOFFSET_DBID = 0,\nOFFSET_PARENT = 1,\nOFFSET_FIRST_CHILD = 2,\nOFFSET_NUM_CHILD = 3,\nOFFSET_FLAGS = 4;\n\n// note: objectCount and fragmentCount are not used\nexport function InstanceTreeStorage(objectCount, fragmentCount) {\n\n this.nodes = [];\n this.nextNode = 0;\n\n this.children = [];\n this.nextChild = 0;\n\n this.dbIdToIndex = {};\n\n this.names = [];\n this.s2i = {}; //duplicate string pool\n this.strings = new FlatStringStorage();\n this.nameSuffixes = []; //integers\n\n //Occupy index zero so that we can use index 0 as undefined\n this.getIndex(0);\n}\n\nInstanceTreeStorage.prototype.getIndex = function (dbId) {\n\n var index = this.dbIdToIndex[dbId];\n\n if (index)\n return index;\n\n index = this.nextNode++;\n\n //Allocate space for new node\n this.nodes.push(dbId); //store the dbId as first integer in the Node structure\n //Add four blank integers to be filled by setNode\n for (var i = 1; i < SIZEOF_NODE; i++) {\n this.nodes.push(0);}\n\n this.dbIdToIndex[dbId] = index;\n\n return index;\n};\n\nInstanceTreeStorage.prototype.setNode = function (dbId, parentDbId, name, flags, childrenIds, fragIds) {\n\n var index = this.getIndex(dbId);\n\n var baseOffset = index * SIZEOF_NODE;\n\n var numChildren = childrenIds.length;\n var hasFragments = fragIds && fragIds.length;\n if (hasFragments) {\n numChildren += fragIds.length;\n }\n\n this.nodes[baseOffset + OFFSET_PARENT] = parentDbId;\n this.nodes[baseOffset + OFFSET_FIRST_CHILD] = this.nextChild;\n this.nodes[baseOffset + OFFSET_NUM_CHILD] = hasFragments ? -numChildren : numChildren;\n this.nodes[baseOffset + OFFSET_FLAGS] = flags;\n\n var i;\n for (i = 0; i < childrenIds.length; i++) {\n this.children[this.nextChild++] = this.getIndex(childrenIds[i]);}\n\n //Store fragIds as negative numbers so we can differentiate them when looking through\n //the array later.\n if (hasFragments) {\n for (i = 0; i < fragIds.length; i++) {\n this.children[this.nextChild++] = -fragIds[i] - 1;} //index 0 stored as -1, etc., since 0 is not negative\n }\n\n if (this.nextChild > this.children.length) {\n // TODO: this code may run in a worker, replace console with something else\n console.error(\"Child index out of bounds -- should not happen\");\n }\n\n this.processName(index, name);\n};\n\nInstanceTreeStorage.prototype.processName = function (index, name) {\n\n //Attempt to decompose the name into a base string + integer,\n //like for example \"Base Wall [12345678]\" or \"Crank Shaft:1\"\n //We will try to reduce memory usage by storing \"Base Wall\" just once.\n var base;\n var suffix;\n\n //Try Revit style [1234] first\n var iStart = -1;\n var iEnd = -1;\n\n if (name) {//name should not be empty, but hey, it happens.\n iEnd = name.lastIndexOf(\"]\");\n iStart = name.lastIndexOf(\"[\");\n\n //Try Inventor style :1234\n if (iStart === -1 || iEnd === -1) {\n iStart = name.lastIndexOf(\":\");\n iEnd = name.length;\n }\n }\n\n //TODO: Any other separators? What does AutoCAD use?\n\n if (iStart >= 0 && iEnd > iStart) {\n base = name.slice(0, iStart + 1);\n var ssuffix = name.slice(iStart + 1, iEnd);\n suffix = parseInt(ssuffix, 10);\n\n //make sure we get the same thing back when\n //converting back to string, otherwise don't \n //decompose it.\n if (!suffix || suffix + \"\" !== ssuffix) {\n base = name;\n suffix = 0;\n }\n } else {\n base = name;\n suffix = 0;\n }\n\n\n var idx = this.s2i[base];\n if (idx === undefined) {\n idx = this.strings.add(base);\n this.s2i[base] = idx;\n }\n\n this.names[index] = idx;\n this.nameSuffixes[index] = suffix;\n};\n\n\nfunction arrayToBuffer(a) {\n var b = new Int32Array(a.length);\n b.set(a);\n return b;\n}\n\n// note none of these arguments are used\nInstanceTreeStorage.prototype.flatten = function (dbId, parentDbId, name, flags, childrenIds, isLeaf) {\n this.nodes = arrayToBuffer(this.nodes);\n this.children = arrayToBuffer(this.children);\n this.names = arrayToBuffer(this.names);\n this.nameSuffixes = arrayToBuffer(this.nameSuffixes);\n this.strings.flatten();\n this.s2i = null; //we don't need this temporary map once we've built the strings list\n};\n\n\n\nexport function InstanceTreeAccess(nodeArray, rootId, nodeBoxes) {\n this.nodes = nodeArray.nodes;\n this.children = nodeArray.children;\n this.dbIdToIndex = nodeArray.dbIdToIndex;\n this.names = nodeArray.names;\n this.nameSuffixes = nodeArray.nameSuffixes;\n this.strings = new FlatStringStorage(nodeArray.strings);\n this.rootId = rootId;\n this.numNodes = this.nodes.length / SIZEOF_NODE;\n this.visibleIds = null;\n\n // only used if bboxes are precomputed\n this.nodeBoxes = nodeBoxes;\n}\n\nInstanceTreeAccess.prototype.getNumNodes = function () {\n return this.numNodes;\n};\n\nInstanceTreeAccess.prototype.getIndex = function (dbId) {\n return this.dbIdToIndex[dbId];\n};\n\nInstanceTreeAccess.prototype.name = function (dbId, includeCount) {\n var idx = this.dbIdToIndex[dbId];\n var base = this.strings.get(this.names[idx]);\n var suffix = this.nameSuffixes[idx];\n var name;\n if (suffix) {\n //NOTE: update this logic if more separators are supported in processName above\n var lastChar = base.charAt(base.length - 1);\n if (lastChar === \"[\")\n name = base + suffix + \"]\";else\n\n name = base + suffix;\n } else {\n name = base;\n }\n\n if (includeCount) {\n if (!this.childCounts) {\n this.computeChildCounts();\n }\n if (this.childCounts[dbId] > 0) {\n name += \" (\" + this.childCounts[dbId] + \")\";\n }\n }\n\n return name;\n};\n\nInstanceTreeAccess.prototype.getParentId = function (dbId) {\n var idx = this.dbIdToIndex[dbId];\n return this.nodes[idx * SIZEOF_NODE + OFFSET_PARENT];\n};\n\nInstanceTreeAccess.prototype.getNodeFlags = function (dbId) {\n var idx = this.dbIdToIndex[dbId];\n return this.nodes[idx * SIZEOF_NODE + OFFSET_FLAGS];\n};\n\nInstanceTreeAccess.prototype.setNodeFlags = function (dbId, flags) {\n var idx = this.dbIdToIndex[dbId];\n if (idx) {\n this.nodes[idx * SIZEOF_NODE + OFFSET_FLAGS] = flags;\n }\n};\n\nInstanceTreeAccess.prototype.getNumChildren = function (dbId) {\n\n var idx = this.dbIdToIndex[dbId];\n var numChildren = this.nodes[idx * SIZEOF_NODE + OFFSET_NUM_CHILD];\n\n //If numChildren is non-negative, then all children are nodes (not fragments)\n if (numChildren >= 0)\n return numChildren;\n\n //Node has mixed fragments and child nodes, so we have to loop and collect just the node children\n var firstChild = this.nodes[idx * SIZEOF_NODE + OFFSET_FIRST_CHILD];\n\n numChildren = Math.abs(numChildren);\n\n var numNodeChildren = 0;\n\n for (var i = 0; i < numChildren; i++) {\n var childIdx = this.children[firstChild + i];\n\n //did we reach the fragment ids sub-list?\n if (childIdx < 0)\n break;\n\n numNodeChildren++;\n }\n\n return numNodeChildren;\n};\n\nInstanceTreeAccess.prototype.getNumFragments = function (dbId) {\n var idx = this.dbIdToIndex[dbId];\n\n var numChildren = this.nodes[idx * SIZEOF_NODE + OFFSET_NUM_CHILD];\n\n //If numChildren is non-negative, there aren't any fragments belonging to this node\n if (numChildren >= 0)\n return 0;\n\n //Node has mixed fragments and child nodes, so we have to loop and collect just the node children\n var firstChild = this.nodes[idx * SIZEOF_NODE + OFFSET_FIRST_CHILD];\n\n numChildren = Math.abs(numChildren);\n\n var numFragChildren = 0;\n\n //Iterate backwards, because fragment children are at the back of the children list\n for (var i = numChildren - 1; i >= 0; i--) {\n var childIdx = this.children[firstChild + i];\n\n //did we reach the inner node children ids sub-list?\n if (childIdx >= 0)\n break;\n\n numFragChildren++;\n }\n\n return numFragChildren;\n};\n\n// NOTE: This can only be used if precomputed bboxes are available.\nInstanceTreeAccess.prototype.getNodeBox = function (dbId, dst) {\n var idx = this.getIndex(dbId);\n var off = idx * 6;\n for (var i = 0; i < 6; i++) {\n dst[i] = this.nodeBoxes[off + i];}\n};\n\n//Returns an array containing the dbIds of all objects\n//that are physically represented in the scene. Not all\n//objects in the property database occur physically in each graphics viewable.\nInstanceTreeAccess.prototype.getVisibleIds = function () {\n if (!this.visibleIds) {\n this.visibleIds = Object.keys(this.dbIdToIndex).map(function (k) {return parseInt(k);});\n }\n\n return this.visibleIds;\n};\n\n\nInstanceTreeAccess.prototype.enumNodeChildren = function (dbId, callback) {\n var idx = this.dbIdToIndex[dbId];\n var firstChild = this.nodes[idx * SIZEOF_NODE + OFFSET_FIRST_CHILD];\n var numChildren = this.nodes[idx * SIZEOF_NODE + OFFSET_NUM_CHILD];\n\n numChildren = Math.abs(numChildren);\n\n for (var i = 0; i < numChildren; i++) {\n var childIdx = this.children[firstChild + i];\n\n //did we reach the fragment ids sub-list?\n if (childIdx < 0)\n break;\n\n var childDbId = this.nodes[childIdx * SIZEOF_NODE + OFFSET_DBID];\n if (callback(childDbId, dbId, idx)) {\n return dbId;\n }\n }\n};\n\nInstanceTreeAccess.prototype.enumNodeFragments = function (dbId, callback) {\n var idx = this.dbIdToIndex[dbId];\n var firstChild = this.nodes[idx * SIZEOF_NODE + OFFSET_FIRST_CHILD];\n var numChildren = this.nodes[idx * SIZEOF_NODE + OFFSET_NUM_CHILD];\n\n //If numChildren is negative, it means there are fragments in the node\n if (numChildren < 0) {\n numChildren = -numChildren;\n for (var i = 0; i < numChildren; i++) {\n var childIdx = this.children[firstChild + i];\n\n //skip past children that are inner nodes (not fragments)\n if (childIdx > 0)\n continue;\n\n //Convert fragId from -1 based negative back to the actual fragId\n if (callback(-childIdx - 1, dbId, idx)) {\n return dbId;\n }\n }\n }\n};\n\nInstanceTreeAccess.prototype.computeBoxes = function (fragBoxes) {\n\n if (!this.nodeBoxes) {\n this.nodeBoxes = new Float32Array(6 * this.numNodes);\n }\n\n var nodeAccess = this;\n var idx = nodeAccess.getIndex(nodeAccess.rootId);\n var nodeBoxes = nodeAccess.nodeBoxes;\n\n function traverseChildren(child_dbId, parentDbID, parentIdx) {\n\n var childIdx = nodeAccess.getIndex(child_dbId);\n\n //Recurse, then add all child boxes to make this node's box\n computeTreeBBoxesRec(child_dbId, childIdx);\n\n var box_offset = parentIdx * 6;\n var child_box_offset = childIdx * 6;\n for (var k = 0; k < 3; k++) {\n if (nodeBoxes[box_offset + k] > nodeBoxes[child_box_offset + k])\n nodeBoxes[box_offset + k] = nodeBoxes[child_box_offset + k];\n if (nodeBoxes[box_offset + k + 3] < nodeBoxes[child_box_offset + k + 3])\n nodeBoxes[box_offset + k + 3] = nodeBoxes[child_box_offset + k + 3];\n }\n }\n\n function traverseFragments(fragId, dbId, idx) {\n var frag_box_offset = fragId * 6;\n var box_offset = idx * 6;\n\n for (var k = 0; k < 3; k++) {\n if (nodeBoxes[box_offset + k] > fragBoxes[frag_box_offset + k])\n nodeBoxes[box_offset + k] = fragBoxes[frag_box_offset + k];\n if (nodeBoxes[box_offset + k + 3] < fragBoxes[frag_box_offset + k + 3])\n nodeBoxes[box_offset + k + 3] = fragBoxes[frag_box_offset + k + 3];\n }\n }\n\n function computeTreeBBoxesRec(dbId, idx) {\n\n var box_offset = idx * 6;\n nodeBoxes[box_offset] = nodeBoxes[box_offset + 1] = nodeBoxes[box_offset + 2] = Infinity;\n nodeBoxes[box_offset + 3] = nodeBoxes[box_offset + 4] = nodeBoxes[box_offset + 5] = -Infinity;\n\n if (nodeAccess.getNumChildren(dbId)) {\n nodeAccess.enumNodeChildren(dbId, traverseChildren, true);\n }\n\n //Leaf node -- don't think it's possible for a node to have\n //both children and leaf fragments, but we do handle that here.\n if (nodeAccess.getNumFragments(dbId)) {\n nodeAccess.enumNodeFragments(dbId, traverseFragments);\n }\n\n }\n\n computeTreeBBoxesRec(nodeAccess.rootId, idx);\n};\n\nInstanceTreeAccess.prototype.computeChildCounts = function () {\n if (!this.childCounts) {\n this.childCounts = new Uint32Array(this.numNodes);\n }\n\n var nodeAccess = this;\n var idx = nodeAccess.getIndex(nodeAccess.rootId);\n var childCounts = nodeAccess.childCounts;\n\n function traverseChildren(child_dbId, parentDbID, parentIdx) {\n\n var childIdx = nodeAccess.getIndex(child_dbId);\n\n //Recurse, then add all child boxes to make this node's box\n var count = computeChildCountsRec(child_dbId, childIdx);\n\n childCounts[parentDbID] += count;\n }\n\n\n function computeChildCountsRec(dbId, idx) {\n\n var flags = nodeAccess.getNodeFlags(dbId);\n var myCount = 0;\n\n if (flags === 0x4 /*NODE_TYPE_COMPOSITE*/) {\n //If it's a composite node, treat it as a single\n //opaque object whose contents don't matter to the user\n //for counting purposes.\n myCount = 1;\n } else {\n\n if (nodeAccess.getNumChildren(dbId)) {\n nodeAccess.enumNodeChildren(dbId, traverseChildren, true);\n }\n\n //Leaf node\n if (nodeAccess.getNumFragments(dbId)) {\n myCount = 1;\n }\n }\n\n return myCount + childCounts[dbId];\n }\n\n computeChildCountsRec(nodeAccess.rootId, idx);\n};","\nexport function allocateUintArray(size, maxInt) {\n if (maxInt <= 255) {\n return new Uint8Array(size);\n } else if (maxInt <= 65535) {\n return new Uint16Array(size);\n }\n\n return new Uint32Array(size);\n}\n\nexport function reallocateUintArrayMaybe(arr, val) {\n\n if (val <= 255)\n return arr;\n\n if (val <= 65535 && arr instanceof Uint8Array) {\n var ret = new Uint16Array(arr.length);\n ret.set(arr);\n return ret;\n }\n\n if (!arr instanceof Uint32Array) {\n var _ret = new Uint32Array(arr.length);\n _ret.set(arr);\n return _ret;\n }\n\n return arr;\n}","/**\n * @author bhouston / http://exocortex.com\n * @author WestLangley / http://github.com/WestLangley\n */\n/* Pruned version of THREE.Box3, for use in the LMV web worker */\n\nimport { LmvVector3 } from './LmvVector3';\n\nexport var LmvBox3 = function LmvBox3(min, max) {\n\n this.min = min !== undefined ? min : new LmvVector3(Infinity, Infinity, Infinity);\n this.max = max !== undefined ? max : new LmvVector3(-Infinity, -Infinity, -Infinity);\n\n};\n\nLmvBox3.prototype = {\n\n constructor: LmvBox3,\n\n set: function set(min, max) {\n\n this.min.copy(min);\n this.max.copy(max);\n\n return this;\n\n },\n\n setFromPoints: function setFromPoints(points) {\n\n this.makeEmpty();\n\n for (var i = 0, il = points.length; i < il; i++) {\n\n this.expandByPoint(points[i]);\n\n }\n\n return this;\n\n },\n\n setFromArray: function setFromArray(array, offset) {\n\n this.min.x = array[offset];\n this.min.y = array[offset + 1];\n this.min.z = array[offset + 2];\n\n this.max.x = array[offset + 3];\n this.max.y = array[offset + 4];\n this.max.z = array[offset + 5];\n\n return this;\n\n },\n\n copyToArray: function copyToArray(array, offset) {\n\n array[offset] = this.min.x;\n array[offset + 1] = this.min.y;\n array[offset + 2] = this.min.z;\n\n array[offset + 3] = this.max.x;\n array[offset + 4] = this.max.y;\n array[offset + 5] = this.max.z;\n\n },\n\n setFromCenterAndSize: function () {\n\n var v1 = new LmvVector3();\n\n return function (center, size) {\n\n var halfSize = v1.copy(size).multiplyScalar(0.5);\n\n this.min.copy(center).sub(halfSize);\n this.max.copy(center).add(halfSize);\n\n return this;\n\n };\n\n }(),\n\n clone: function clone() {\n\n return new this.constructor().copy(this);\n\n },\n\n copy: function copy(box) {\n\n this.min.copy(box.min);\n this.max.copy(box.max);\n\n return this;\n\n },\n\n makeEmpty: function makeEmpty() {\n\n this.min.x = this.min.y = this.min.z = Infinity;\n this.max.x = this.max.y = this.max.z = -Infinity;\n\n return this;\n\n },\n\n empty: function empty() {\n\n // this is a more robust check for empty than ( volume <= 0 ) because volume can get positive with two negative axes\n\n return this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z;\n\n },\n\n center: function center(optionalTarget) {\n\n var result = optionalTarget || new LmvVector3();\n return result.addVectors(this.min, this.max).multiplyScalar(0.5);\n\n },\n\n size: function size(optionalTarget) {\n\n var result = optionalTarget || new LmvVector3();\n return result.subVectors(this.max, this.min);\n\n },\n\n expandByPoint: function expandByPoint(point) {\n\n this.min.min(point);\n this.max.max(point);\n\n return this;\n\n },\n\n expandByVector: function expandByVector(vector) {\n\n this.min.sub(vector);\n this.max.add(vector);\n\n return this;\n\n },\n\n expandByScalar: function expandByScalar(scalar) {\n\n this.min.addScalar(-scalar);\n this.max.addScalar(scalar);\n\n return this;\n\n },\n\n containsPoint: function containsPoint(point) {\n\n if (point.x < this.min.x || point.x > this.max.x ||\n point.y < this.min.y || point.y > this.max.y ||\n point.z < this.min.z || point.z > this.max.z) {\n\n return false;\n\n }\n\n return true;\n\n },\n\n containsBox: function containsBox(box) {\n\n if (this.min.x <= box.min.x && box.max.x <= this.max.x &&\n this.min.y <= box.min.y && box.max.y <= this.max.y &&\n this.min.z <= box.min.z && box.max.z <= this.max.z) {\n\n return true;\n\n }\n\n return false;\n\n },\n\n getParameter: function getParameter(point, optionalTarget) {\n\n // This can potentially have a divide by zero if the box\n // has a size dimension of 0.\n\n var result = optionalTarget || new LmvVector3();\n\n return result.set(\n (point.x - this.min.x) / (this.max.x - this.min.x),\n (point.y - this.min.y) / (this.max.y - this.min.y),\n (point.z - this.min.z) / (this.max.z - this.min.z));\n\n\n },\n\n isIntersectionBox: function isIntersectionBox(box) {\n\n // using 6 splitting planes to rule out intersections.\n\n if (box.max.x < this.min.x || box.min.x > this.max.x ||\n box.max.y < this.min.y || box.min.y > this.max.y ||\n box.max.z < this.min.z || box.min.z > this.max.z) {\n\n return false;\n\n }\n\n return true;\n\n },\n\n clampPoint: function clampPoint(point, optionalTarget) {\n\n var result = optionalTarget || new LmvVector3();\n return result.copy(point).clamp(this.min, this.max);\n\n },\n\n distanceToPoint: function () {\n\n var v1 = new LmvVector3();\n\n return function (point) {\n\n var clampedPoint = v1.copy(point).clamp(this.min, this.max);\n return clampedPoint.sub(point).length();\n\n };\n\n }(),\n\n intersect: function intersect(box) {\n\n this.min.max(box.min);\n this.max.min(box.max);\n\n return this;\n\n },\n\n union: function union(box) {\n\n this.min.min(box.min);\n this.max.max(box.max);\n\n return this;\n\n },\n\n applyMatrix4: function () {\n\n var points = [\n new LmvVector3(),\n new LmvVector3(),\n new LmvVector3(),\n new LmvVector3(),\n new LmvVector3(),\n new LmvVector3(),\n new LmvVector3(),\n new LmvVector3()];\n\n\n return function (matrix) {\n\n // NOTE: I am using a binary pattern to specify all 2^3 combinations below\n points[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(matrix); // 000\n points[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(matrix); // 001\n points[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(matrix); // 010\n points[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(matrix); // 011\n points[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(matrix); // 100\n points[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(matrix); // 101\n points[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(matrix); // 110\n points[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(matrix); // 111\n\n this.makeEmpty();\n this.setFromPoints(points);\n\n return this;\n\n };\n\n }(),\n\n translate: function translate(offset) {\n\n this.min.add(offset);\n this.max.add(offset);\n\n return this;\n\n },\n\n equals: function equals(box) {\n\n return box.min.equals(this.min) && box.max.equals(this.max);\n\n } };","/**\n * @author mrdoob / http://mrdoob.com/\n * @author supereggbert / http://www.paulbrunt.co.uk/\n * @author philogb / http://blog.thejit.org/\n * @author jordi_ros / http://plattsoft.com\n * @author D1plo1d / http://github.com/D1plo1d\n * @author alteredq / http://alteredqualia.com/\n * @author mikael emtinger / http://gomo.se/\n * @author timknip / http://www.floorplanner.com/\n * @author bhouston / http://exocortex.com\n * @author WestLangley / http://github.com/WestLangley\n */\n/* Pruned version of THREE.Matrix4, for use in the LMV web worker */\n\nimport { LmvVector3 } from './LmvVector3';\n\nexport var LmvMatrix4 = function LmvMatrix4(useDoublePrecision) {\n\n if (useDoublePrecision) {\n\n this.elements = new Float64Array([\n\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1]);\n\n\n\n } else {\n\n this.elements = new Float32Array([\n\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1]);\n\n\n\n }\n\n this.isDoublePrecision = !!useDoublePrecision;\n\n};\n\nLmvMatrix4.prototype = {\n\n constructor: LmvMatrix4,\n\n set: function set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {\n\n var te = this.elements;\n\n te[0] = n11;te[4] = n12;te[8] = n13;te[12] = n14;\n te[1] = n21;te[5] = n22;te[9] = n23;te[13] = n24;\n te[2] = n31;te[6] = n32;te[10] = n33;te[14] = n34;\n te[3] = n41;te[7] = n42;te[11] = n43;te[15] = n44;\n\n return this;\n\n },\n\n identity: function identity() {\n\n this.set(\n\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1);\n\n\n\n return this;\n\n },\n\n copy: function copy(m) {\n\n this.elements.set(m.elements);\n\n return this;\n\n },\n\n makeRotationFromQuaternion: function makeRotationFromQuaternion(q) {\n\n var te = this.elements;\n\n var x = q.x,y = q.y,z = q.z,w = q.w;\n var x2 = x + x,y2 = y + y,z2 = z + z;\n var xx = x * x2,xy = x * y2,xz = x * z2;\n var yy = y * y2,yz = y * z2,zz = z * z2;\n var wx = w * x2,wy = w * y2,wz = w * z2;\n\n te[0] = 1 - (yy + zz);\n te[4] = xy - wz;\n te[8] = xz + wy;\n\n te[1] = xy + wz;\n te[5] = 1 - (xx + zz);\n te[9] = yz - wx;\n\n te[2] = xz - wy;\n te[6] = yz + wx;\n te[10] = 1 - (xx + yy);\n\n // last column\n te[3] = 0;\n te[7] = 0;\n te[11] = 0;\n\n // bottom row\n te[12] = 0;\n te[13] = 0;\n te[14] = 0;\n te[15] = 1;\n\n return this;\n\n },\n\n multiply: function multiply(n) {\n\n return this.multiplyMatrices(this, n);\n\n },\n\n multiplyMatrices: function multiplyMatrices(a, b) {\n\n var ae = a.elements;\n var be = b.elements;\n var te = this.elements;\n\n var a11 = ae[0],a12 = ae[4],a13 = ae[8],a14 = ae[12];\n var a21 = ae[1],a22 = ae[5],a23 = ae[9],a24 = ae[13];\n var a31 = ae[2],a32 = ae[6],a33 = ae[10],a34 = ae[14];\n var a41 = ae[3],a42 = ae[7],a43 = ae[11],a44 = ae[15];\n\n var b11 = be[0],b12 = be[4],b13 = be[8],b14 = be[12];\n var b21 = be[1],b22 = be[5],b23 = be[9],b24 = be[13];\n var b31 = be[2],b32 = be[6],b33 = be[10],b34 = be[14];\n var b41 = be[3],b42 = be[7],b43 = be[11],b44 = be[15];\n\n te[0] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;\n te[4] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;\n te[8] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;\n te[12] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;\n\n te[1] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;\n te[5] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;\n te[9] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;\n te[13] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;\n\n te[2] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;\n te[6] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;\n te[10] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;\n te[14] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;\n\n te[3] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;\n te[7] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;\n te[11] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;\n te[15] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;\n\n return this;\n\n },\n\n multiplyToArray: function multiplyToArray(a, b, r) {\n\n var te = this.elements;\n\n this.multiplyMatrices(a, b);\n\n r[0] = te[0];r[1] = te[1];r[2] = te[2];r[3] = te[3];\n r[4] = te[4];r[5] = te[5];r[6] = te[6];r[7] = te[7];\n r[8] = te[8];r[9] = te[9];r[10] = te[10];r[11] = te[11];\n r[12] = te[12];r[13] = te[13];r[14] = te[14];r[15] = te[15];\n\n return this;\n\n },\n\n multiplyScalar: function multiplyScalar(s) {\n\n var te = this.elements;\n\n te[0] *= s;te[4] *= s;te[8] *= s;te[12] *= s;\n te[1] *= s;te[5] *= s;te[9] *= s;te[13] *= s;\n te[2] *= s;te[6] *= s;te[10] *= s;te[14] *= s;\n te[3] *= s;te[7] *= s;te[11] *= s;te[15] *= s;\n\n return this;\n\n },\n\n determinant: function determinant() {\n\n var te = this.elements;\n\n var n11 = te[0],n12 = te[4],n13 = te[8],n14 = te[12];\n var n21 = te[1],n22 = te[5],n23 = te[9],n24 = te[13];\n var n31 = te[2],n32 = te[6],n33 = te[10],n34 = te[14];\n var n41 = te[3],n42 = te[7],n43 = te[11],n44 = te[15];\n\n //TODO: make this more efficient\n //( based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm )\n\n return (\n n41 * (\n +n14 * n23 * n32 -\n n13 * n24 * n32 -\n n14 * n22 * n33 +\n n12 * n24 * n33 +\n n13 * n22 * n34 -\n n12 * n23 * n34) +\n\n n42 * (\n +n11 * n23 * n34 -\n n11 * n24 * n33 +\n n14 * n21 * n33 -\n n13 * n21 * n34 +\n n13 * n24 * n31 -\n n14 * n23 * n31) +\n\n n43 * (\n +n11 * n24 * n32 -\n n11 * n22 * n34 -\n n14 * n21 * n32 +\n n12 * n21 * n34 +\n n14 * n22 * n31 -\n n12 * n24 * n31) +\n\n n44 * (\n -n13 * n22 * n31 -\n n11 * n23 * n32 +\n n11 * n22 * n33 +\n n13 * n21 * n32 -\n n12 * n21 * n33 +\n n12 * n23 * n31));\n\n\n\n\n },\n\n transpose: function transpose() {\n\n var te = this.elements;\n var tmp;\n\n tmp = te[1];te[1] = te[4];te[4] = tmp;\n tmp = te[2];te[2] = te[8];te[8] = tmp;\n tmp = te[6];te[6] = te[9];te[9] = tmp;\n\n tmp = te[3];te[3] = te[12];te[12] = tmp;\n tmp = te[7];te[7] = te[13];te[13] = tmp;\n tmp = te[11];te[11] = te[14];te[14] = tmp;\n\n return this;\n\n },\n\n flattenToArrayOffset: function flattenToArrayOffset(array, offset) {\n\n var te = this.elements;\n\n array[offset] = te[0];\n array[offset + 1] = te[1];\n array[offset + 2] = te[2];\n array[offset + 3] = te[3];\n\n array[offset + 4] = te[4];\n array[offset + 5] = te[5];\n array[offset + 6] = te[6];\n array[offset + 7] = te[7];\n\n array[offset + 8] = te[8];\n array[offset + 9] = te[9];\n array[offset + 10] = te[10];\n array[offset + 11] = te[11];\n\n array[offset + 12] = te[12];\n array[offset + 13] = te[13];\n array[offset + 14] = te[14];\n array[offset + 15] = te[15];\n\n return array;\n\n },\n\n setPosition: function setPosition(v) {\n\n var te = this.elements;\n\n te[12] = v.x;\n te[13] = v.y;\n te[14] = v.z;\n\n return this;\n\n },\n\n getInverse: function getInverse(m, throwOnInvertible) {\n\n // based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm\n var te = this.elements;\n var me = m.elements;\n\n var n11 = me[0],n12 = me[4],n13 = me[8],n14 = me[12];\n var n21 = me[1],n22 = me[5],n23 = me[9],n24 = me[13];\n var n31 = me[2],n32 = me[6],n33 = me[10],n34 = me[14];\n var n41 = me[3],n42 = me[7],n43 = me[11],n44 = me[15];\n\n te[0] = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44;\n te[4] = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44;\n te[8] = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44;\n te[12] = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34;\n te[1] = n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44;\n te[5] = n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44;\n te[9] = n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44;\n te[13] = n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34;\n te[2] = n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44;\n te[6] = n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44;\n te[10] = n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44;\n te[14] = n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34;\n te[3] = n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43;\n te[7] = n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43;\n te[11] = n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43;\n te[15] = n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33;\n\n var det = n11 * te[0] + n21 * te[4] + n31 * te[8] + n41 * te[12];\n\n if (det == 0) {\n\n var msg = \"Matrix4.getInverse(): can't invert matrix, determinant is 0\";\n\n if (throwOnInvertible || false) {\n\n throw new Error(msg);\n\n } else {\n\n console.warn(msg);\n\n }\n\n this.identity();\n\n return this;\n }\n\n this.multiplyScalar(1 / det);\n\n return this;\n\n },\n\n scale: function scale(v) {\n\n var te = this.elements;\n var x = v.x,y = v.y,z = v.z;\n\n te[0] *= x;te[4] *= y;te[8] *= z;\n te[1] *= x;te[5] *= y;te[9] *= z;\n te[2] *= x;te[6] *= y;te[10] *= z;\n te[3] *= x;te[7] *= y;te[11] *= z;\n\n return this;\n\n },\n\n getMaxScaleOnAxis: function getMaxScaleOnAxis() {\n\n var te = this.elements;\n\n var scaleXSq = te[0] * te[0] + te[1] * te[1] + te[2] * te[2];\n var scaleYSq = te[4] * te[4] + te[5] * te[5] + te[6] * te[6];\n var scaleZSq = te[8] * te[8] + te[9] * te[9] + te[10] * te[10];\n\n return Math.sqrt(Math.max(scaleXSq, Math.max(scaleYSq, scaleZSq)));\n\n },\n\n makeTranslation: function makeTranslation(x, y, z) {\n\n this.set(\n\n 1, 0, 0, x,\n 0, 1, 0, y,\n 0, 0, 1, z,\n 0, 0, 0, 1);\n\n\n\n return this;\n\n },\n\n makeRotationX: function makeRotationX(theta) {\n\n var c = Math.cos(theta),s = Math.sin(theta);\n\n this.set(\n\n 1, 0, 0, 0,\n 0, c, -s, 0,\n 0, s, c, 0,\n 0, 0, 0, 1);\n\n\n\n return this;\n\n },\n\n makeRotationY: function makeRotationY(theta) {\n\n var c = Math.cos(theta),s = Math.sin(theta);\n\n this.set(\n\n c, 0, s, 0,\n 0, 1, 0, 0,\n -s, 0, c, 0,\n 0, 0, 0, 1);\n\n\n\n return this;\n\n },\n\n makeRotationZ: function makeRotationZ(theta) {\n\n var c = Math.cos(theta),s = Math.sin(theta);\n\n this.set(\n\n c, -s, 0, 0,\n s, c, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1);\n\n\n\n return this;\n\n },\n\n makeRotationAxis: function makeRotationAxis(axis, angle) {\n\n // Based on http://www.gamedev.net/reference/articles/article1199.asp\n\n var c = Math.cos(angle);\n var s = Math.sin(angle);\n var t = 1 - c;\n var x = axis.x,y = axis.y,z = axis.z;\n var tx = t * x,ty = t * y;\n\n this.set(\n\n tx * x + c, tx * y - s * z, tx * z + s * y, 0,\n tx * y + s * z, ty * y + c, ty * z - s * x, 0,\n tx * z - s * y, ty * z + s * x, t * z * z + c, 0,\n 0, 0, 0, 1);\n\n\n\n return this;\n\n },\n\n makeScale: function makeScale(x, y, z) {\n\n this.set(\n\n x, 0, 0, 0,\n 0, y, 0, 0,\n 0, 0, z, 0,\n 0, 0, 0, 1);\n\n\n\n return this;\n\n },\n\n compose: function compose(position, quaternion, scale) {\n\n this.makeRotationFromQuaternion(quaternion);\n this.scale(scale);\n this.setPosition(position);\n\n return this;\n\n },\n\n decompose: function () {\n\n var vector = new LmvVector3();\n var matrix = new LmvMatrix4(true);\n\n return function (position, quaternion, scale) {\n\n var te = this.elements;\n\n var sx = vector.set(te[0], te[1], te[2]).length();\n var sy = vector.set(te[4], te[5], te[6]).length();\n var sz = vector.set(te[8], te[9], te[10]).length();\n\n // if determine is negative, we need to invert one scale\n var det = this.determinant();\n if (det < 0) {\n sx = -sx;\n }\n\n position.x = te[12];\n position.y = te[13];\n position.z = te[14];\n\n // scale the rotation part\n\n matrix.elements.set(this.elements); // at this point matrix is incomplete so we can't use .copy()\n\n var invSX = 1 / sx;\n var invSY = 1 / sy;\n var invSZ = 1 / sz;\n\n matrix.elements[0] *= invSX;\n matrix.elements[1] *= invSX;\n matrix.elements[2] *= invSX;\n\n matrix.elements[4] *= invSY;\n matrix.elements[5] *= invSY;\n matrix.elements[6] *= invSY;\n\n matrix.elements[8] *= invSZ;\n matrix.elements[9] *= invSZ;\n matrix.elements[10] *= invSZ;\n\n quaternion.setFromRotationMatrix(matrix);\n\n scale.x = sx;\n scale.y = sy;\n scale.z = sz;\n\n return this;\n\n };\n\n }(),\n\n //Added for LMV\n transformPoint: function transformPoint(pt) {\n\n // input: THREE.Matrix4 affine matrix\n\n var x = pt.x,y = pt.y,z = pt.z;\n\n var e = this.elements;\n\n pt.x = e[0] * x + e[4] * y + e[8] * z + e[12];\n pt.y = e[1] * x + e[5] * y + e[9] * z + e[13];\n pt.z = e[2] * x + e[6] * y + e[10] * z + e[14];\n\n return pt;\n },\n\n //Added for LMV\n transformDirection: function transformDirection(v) {\n\n // input: THREE.Matrix4 affine matrix\n // vector interpreted as a direction\n\n var x = v.x,y = v.y,z = v.z;\n\n var e = this.elements;\n\n v.x = e[0] * x + e[4] * y + e[8] * z;\n v.y = e[1] * x + e[5] * y + e[9] * z;\n v.z = e[2] * x + e[6] * y + e[10] * z;\n\n var len = Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z);\n if (len > 0) {\n var ilen = 1.0 / len;\n v.x *= ilen;\n v.y *= ilen;\n v.z *= ilen;\n }\n\n return v;\n },\n\n equals: function equals(matrix) {\n\n var te = this.elements;\n var me = matrix.elements;\n\n for (var i = 0; i < 16; i++) {\n\n if (te[i] !== me[i]) return false;\n\n }\n\n return true;\n\n },\n\n fromArray: function fromArray(array) {\n\n this.elements.set(array);\n\n return this;\n\n },\n\n toArray: function toArray() {\n\n var te = this.elements;\n\n return [\n te[0], te[1], te[2], te[3],\n te[4], te[5], te[6], te[7],\n te[8], te[9], te[10], te[11],\n te[12], te[13], te[14], te[15]];\n\n\n },\n\n clone: function clone() {\n\n return new LmvMatrix4(this.isDoublePrecision).fromArray(this.elements);\n\n } };","/**\n * @author mrdoob / http://mrdoob.com/\n * @author *kile / http://kile.stravaganza.org/\n * @author philogb / http://blog.thejit.org/\n * @author mikael emtinger / http://gomo.se/\n * @author egraether / http://egraether.com/\n * @author WestLangley / http://github.com/WestLangley\n */\n/* Pruned version of THREE.Vector3, for use in the LMV web worker */\n\nexport var LmvVector3 = function LmvVector3(x, y, z) {\n\n this.x = x || 0;\n this.y = y || 0;\n this.z = z || 0;\n\n};\n\nLmvVector3.prototype = {\n\n constructor: LmvVector3,\n\n set: function set(x, y, z) {\n\n this.x = x;\n this.y = y;\n this.z = z;\n\n return this;\n\n },\n\n setX: function setX(x) {\n\n this.x = x;\n\n return this;\n\n },\n\n setY: function setY(y) {\n\n this.y = y;\n\n return this;\n\n },\n\n setZ: function setZ(z) {\n\n this.z = z;\n\n return this;\n\n },\n\n setComponent: function setComponent(index, value) {\n\n switch (index) {\n\n case 0:this.x = value;break;\n case 1:this.y = value;break;\n case 2:this.z = value;break;\n default:throw new Error('index is out of range: ' + index);}\n\n\n\n },\n\n getComponent: function getComponent(index) {\n\n switch (index) {\n\n case 0:return this.x;\n case 1:return this.y;\n case 2:return this.z;\n default:throw new Error('index is out of range: ' + index);}\n\n\n\n },\n\n clone: function clone() {\n\n return new this.constructor(this.x, this.y, this.z);\n\n },\n\n copy: function copy(v) {\n\n this.x = v.x;\n this.y = v.y;\n this.z = v.z;\n\n return this;\n\n },\n\n add: function add(v, w) {\n\n if (w !== undefined) {\n\n console.warn('THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.');\n return this.addVectors(v, w);\n\n }\n\n this.x += v.x;\n this.y += v.y;\n this.z += v.z;\n\n return this;\n\n },\n\n addScalar: function addScalar(s) {\n\n this.x += s;\n this.y += s;\n this.z += s;\n\n return this;\n\n },\n\n addVectors: function addVectors(a, b) {\n\n this.x = a.x + b.x;\n this.y = a.y + b.y;\n this.z = a.z + b.z;\n\n return this;\n\n },\n\n addScaledVector: function addScaledVector(v, s) {\n\n this.x += v.x * s;\n this.y += v.y * s;\n this.z += v.z * s;\n\n return this;\n\n },\n\n sub: function sub(v, w) {\n\n if (w !== undefined) {\n\n console.warn('THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.');\n return this.subVectors(v, w);\n\n }\n\n this.x -= v.x;\n this.y -= v.y;\n this.z -= v.z;\n\n return this;\n\n },\n\n subScalar: function subScalar(s) {\n\n this.x -= s;\n this.y -= s;\n this.z -= s;\n\n return this;\n\n },\n\n subVectors: function subVectors(a, b) {\n\n this.x = a.x - b.x;\n this.y = a.y - b.y;\n this.z = a.z - b.z;\n\n return this;\n\n },\n\n multiply: function multiply(v, w) {\n\n if (w !== undefined) {\n\n console.warn('THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.');\n return this.multiplyVectors(v, w);\n\n }\n\n this.x *= v.x;\n this.y *= v.y;\n this.z *= v.z;\n\n return this;\n\n },\n\n multiplyScalar: function multiplyScalar(scalar) {\n\n this.x *= scalar;\n this.y *= scalar;\n this.z *= scalar;\n\n return this;\n\n },\n\n multiplyVectors: function multiplyVectors(a, b) {\n\n this.x = a.x * b.x;\n this.y = a.y * b.y;\n this.z = a.z * b.z;\n\n return this;\n\n },\n\n applyMatrix3: function applyMatrix3(m) {\n\n var x = this.x;\n var y = this.y;\n var z = this.z;\n\n var e = m.elements;\n\n this.x = e[0] * x + e[3] * y + e[6] * z;\n this.y = e[1] * x + e[4] * y + e[7] * z;\n this.z = e[2] * x + e[5] * y + e[8] * z;\n\n return this;\n\n },\n\n applyMatrix4: function applyMatrix4(m) {\n\n // input: THREE.Matrix4 affine matrix\n\n var x = this.x,y = this.y,z = this.z;\n\n var e = m.elements;\n\n this.x = e[0] * x + e[4] * y + e[8] * z + e[12];\n this.y = e[1] * x + e[5] * y + e[9] * z + e[13];\n this.z = e[2] * x + e[6] * y + e[10] * z + e[14];\n\n return this;\n\n },\n\n applyProjection: function applyProjection(m) {\n\n // input: THREE.Matrix4 projection matrix\n\n var x = this.x,y = this.y,z = this.z;\n\n var e = m.elements;\n var d = 1 / (e[3] * x + e[7] * y + e[11] * z + e[15]); // perspective divide\n\n this.x = (e[0] * x + e[4] * y + e[8] * z + e[12]) * d;\n this.y = (e[1] * x + e[5] * y + e[9] * z + e[13]) * d;\n this.z = (e[2] * x + e[6] * y + e[10] * z + e[14]) * d;\n\n return this;\n\n },\n\n applyQuaternion: function applyQuaternion(q) {\n\n var x = this.x;\n var y = this.y;\n var z = this.z;\n\n var qx = q.x;\n var qy = q.y;\n var qz = q.z;\n var qw = q.w;\n\n // calculate quat * vector\n\n var ix = qw * x + qy * z - qz * y;\n var iy = qw * y + qz * x - qx * z;\n var iz = qw * z + qx * y - qy * x;\n var iw = -qx * x - qy * y - qz * z;\n\n // calculate result * inverse quat\n\n this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy;\n this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz;\n this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx;\n\n return this;\n\n },\n\n transformDirection: function transformDirection(m) {\n\n // input: THREE.Matrix4 affine matrix\n // vector interpreted as a direction\n\n var x = this.x,y = this.y,z = this.z;\n\n var e = m.elements;\n\n this.x = e[0] * x + e[4] * y + e[8] * z;\n this.y = e[1] * x + e[5] * y + e[9] * z;\n this.z = e[2] * x + e[6] * y + e[10] * z;\n\n this.normalize();\n\n return this;\n\n },\n\n divide: function divide(v) {\n\n this.x /= v.x;\n this.y /= v.y;\n this.z /= v.z;\n\n return this;\n\n },\n\n divideScalar: function divideScalar(scalar) {\n\n if (scalar !== 0) {\n\n var invScalar = 1 / scalar;\n\n this.x *= invScalar;\n this.y *= invScalar;\n this.z *= invScalar;\n\n } else {\n\n this.x = 0;\n this.y = 0;\n this.z = 0;\n\n }\n\n return this;\n\n },\n\n min: function min(v) {\n\n if (this.x > v.x) {\n\n this.x = v.x;\n\n }\n\n if (this.y > v.y) {\n\n this.y = v.y;\n\n }\n\n if (this.z > v.z) {\n\n this.z = v.z;\n\n }\n\n return this;\n\n },\n\n max: function max(v) {\n\n if (this.x < v.x) {\n\n this.x = v.x;\n\n }\n\n if (this.y < v.y) {\n\n this.y = v.y;\n\n }\n\n if (this.z < v.z) {\n\n this.z = v.z;\n\n }\n\n return this;\n\n },\n\n clamp: function clamp(min, max) {\n\n // This function assumes min < max, if this assumption isn't true it will not operate correctly\n\n if (this.x < min.x) {\n\n this.x = min.x;\n\n } else if (this.x > max.x) {\n\n this.x = max.x;\n\n }\n\n if (this.y < min.y) {\n\n this.y = min.y;\n\n } else if (this.y > max.y) {\n\n this.y = max.y;\n\n }\n\n if (this.z < min.z) {\n\n this.z = min.z;\n\n } else if (this.z > max.z) {\n\n this.z = max.z;\n\n }\n\n return this;\n\n },\n\n clampScalar: function () {\n\n var min, max;\n\n return function clampScalar(minVal, maxVal) {\n\n if (min === undefined) {\n\n min = new LmvVector3();\n max = new LmvVector3();\n\n }\n\n min.set(minVal, minVal, minVal);\n max.set(maxVal, maxVal, maxVal);\n\n return this.clamp(min, max);\n\n };\n\n }(),\n\n floor: function floor() {\n\n this.x = Math.floor(this.x);\n this.y = Math.floor(this.y);\n this.z = Math.floor(this.z);\n\n return this;\n\n },\n\n ceil: function ceil() {\n\n this.x = Math.ceil(this.x);\n this.y = Math.ceil(this.y);\n this.z = Math.ceil(this.z);\n\n return this;\n\n },\n\n round: function round() {\n\n this.x = Math.round(this.x);\n this.y = Math.round(this.y);\n this.z = Math.round(this.z);\n\n return this;\n\n },\n\n roundToZero: function roundToZero() {\n\n this.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x);\n this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y);\n this.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z);\n\n return this;\n\n },\n\n negate: function negate() {\n\n this.x = -this.x;\n this.y = -this.y;\n this.z = -this.z;\n\n return this;\n\n },\n\n dot: function dot(v) {\n\n return this.x * v.x + this.y * v.y + this.z * v.z;\n\n },\n\n lengthSq: function lengthSq() {\n\n return this.x * this.x + this.y * this.y + this.z * this.z;\n\n },\n\n length: function length() {\n\n return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);\n\n },\n\n lengthManhattan: function lengthManhattan() {\n\n return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z);\n\n },\n\n normalize: function normalize() {\n\n return this.divideScalar(this.length());\n\n },\n\n setLength: function setLength(l) {\n\n var oldLength = this.length();\n\n if (oldLength !== 0 && l !== oldLength) {\n\n this.multiplyScalar(l / oldLength);\n\n }\n\n return this;\n\n },\n\n lerp: function lerp(v, alpha) {\n\n this.x += (v.x - this.x) * alpha;\n this.y += (v.y - this.y) * alpha;\n this.z += (v.z - this.z) * alpha;\n\n return this;\n\n },\n\n lerpVectors: function lerpVectors(v1, v2, alpha) {\n\n this.subVectors(v2, v1).multiplyScalar(alpha).add(v1);\n\n return this;\n\n },\n\n cross: function cross(v, w) {\n\n if (w !== undefined) {\n\n console.warn('THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.');\n return this.crossVectors(v, w);\n\n }\n\n var x = this.x,y = this.y,z = this.z;\n\n this.x = y * v.z - z * v.y;\n this.y = z * v.x - x * v.z;\n this.z = x * v.y - y * v.x;\n\n return this;\n\n },\n\n crossVectors: function crossVectors(a, b) {\n\n var ax = a.x,ay = a.y,az = a.z;\n var bx = b.x,by = b.y,bz = b.z;\n\n this.x = ay * bz - az * by;\n this.y = az * bx - ax * bz;\n this.z = ax * by - ay * bx;\n\n return this;\n\n },\n\n projectOnVector: function () {\n\n var v1, dot;\n\n return function projectOnVector(vector) {\n\n if (v1 === undefined) v1 = new LmvVector3();\n\n v1.copy(vector).normalize();\n\n dot = this.dot(v1);\n\n return this.copy(v1).multiplyScalar(dot);\n\n };\n\n }(),\n\n projectOnPlane: function () {\n\n var v1;\n\n return function projectOnPlane(planeNormal) {\n\n if (v1 === undefined) v1 = new LmvVector3();\n\n v1.copy(this).projectOnVector(planeNormal);\n\n return this.sub(v1);\n\n };\n\n }(),\n\n reflect: function () {\n\n // reflect incident vector off plane orthogonal to normal\n // normal is assumed to have unit length\n\n var v1;\n\n return function reflect(normal) {\n\n if (v1 === undefined) v1 = new LmvVector3();\n\n return this.sub(v1.copy(normal).multiplyScalar(2 * this.dot(normal)));\n\n };\n\n }(),\n\n distanceTo: function distanceTo(v) {\n\n return Math.sqrt(this.distanceToSquared(v));\n\n },\n\n distanceToSquared: function distanceToSquared(v) {\n\n var dx = this.x - v.x;\n var dy = this.y - v.y;\n var dz = this.z - v.z;\n\n return dx * dx + dy * dy + dz * dz;\n\n },\n\n setEulerFromRotationMatrix: function setEulerFromRotationMatrix(m, order) {\n\n console.error('THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.');\n\n },\n\n setEulerFromQuaternion: function setEulerFromQuaternion(q, order) {\n\n console.error('THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.');\n\n },\n\n getPositionFromMatrix: function getPositionFromMatrix(m) {\n\n console.warn('THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition().');\n\n return this.setFromMatrixPosition(m);\n\n },\n\n getScaleFromMatrix: function getScaleFromMatrix(m) {\n\n console.warn('THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale().');\n\n return this.setFromMatrixScale(m);\n\n },\n\n getColumnFromMatrix: function getColumnFromMatrix(index, matrix) {\n\n console.warn('THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().');\n\n return this.setFromMatrixColumn(index, matrix);\n\n },\n\n setFromMatrixPosition: function setFromMatrixPosition(m) {\n\n this.x = m.elements[12];\n this.y = m.elements[13];\n this.z = m.elements[14];\n\n return this;\n\n },\n\n setFromMatrixScale: function setFromMatrixScale(m) {\n\n var sx = this.set(m.elements[0], m.elements[1], m.elements[2]).length();\n var sy = this.set(m.elements[4], m.elements[5], m.elements[6]).length();\n var sz = this.set(m.elements[8], m.elements[9], m.elements[10]).length();\n\n this.x = sx;\n this.y = sy;\n this.z = sz;\n\n return this;\n\n },\n\n setFromMatrixColumn: function setFromMatrixColumn(index, matrix) {\n\n var offset = index * 4;\n\n var me = matrix.elements;\n\n this.x = me[offset];\n this.y = me[offset + 1];\n this.z = me[offset + 2];\n\n return this;\n\n },\n\n equals: function equals(v) {\n\n return v.x === this.x && v.y === this.y && v.z === this.z;\n\n },\n\n fromArray: function fromArray(array, offset) {\n\n if (offset === undefined) offset = 0;\n\n this.x = array[offset];\n this.y = array[offset + 1];\n this.z = array[offset + 2];\n\n return this;\n\n },\n\n toArray: function toArray(array, offset) {\n\n if (array === undefined) array = [];\n if (offset === undefined) offset = 0;\n\n array[offset] = this.x;\n array[offset + 1] = this.y;\n array[offset + 2] = this.z;\n\n return array;\n\n },\n\n fromAttribute: function fromAttribute(attribute, index, offset) {\n\n if (offset === undefined) offset = 0;\n\n index = index * attribute.itemSize + offset;\n\n this.x = attribute.array[index];\n this.y = attribute.array[index + 1];\n this.z = attribute.array[index + 2];\n\n return this;\n\n } };","export var MeshFlags = {\n // FragmentList flags\n //visibility/highlight bitmask flags\n\n //Byte 0\n\n //NOTE: This is confusing and it should be fixed, but when the MESH_VISIBLE bit is off, the mesh\n //will draw in ghosted mode. To completely skip drawing a mesh, set the HIDE flag.\n MESH_VISIBLE: 1,\n MESH_HIGHLIGHTED: 2,\n MESH_HIDE: 4,\n MESH_ISLINE: 8,\n MESH_MOVED: 0x10, // indicates if an animation matrix is set\n MESH_RENDERFLAG: 0x20,\n MESH_NOTLOADED: 0x40, // the mesh has not yet loaded or has been unloaded\n MESH_ISPOINT: 0x80, // indicates that the mesh is vertex-only\n\n //Byte 1\n //TODO: Two bits are enough to hold ISLINE, ISWIDELINE and ISPOINT, we don't need to waste three,\n //but there is no point to optimizing this as long as the required flags go over one byte.\n MESH_ISWIDELINE: 0x100, // indicates that the mesh is wide line\n MESH_TRAVERSED: 0x200, // only used for paging: drawn fragments are tagged and then skipped by forEach() until the flag is being reset (e.g. on scene/camera changes)\n MESH_DRAWN: 0x400 // only used for paging: drawn fragments are tagged. At the end of all render passes flag is copied to MESH_TRAVERSED.\n // The Memory Limited Extension uses the high order three bits of this byte\n};","function _classCallCheck(instance, Constructor) {if (!(instance instanceof Constructor)) {throw new TypeError(\"Cannot call a class as a function\");}}function _defineProperties(target, props) {for (var i = 0; i < props.length; i++) {var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if (\"value\" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);}}function _createClass(Constructor, protoProps, staticProps) {if (protoProps) _defineProperties(Constructor.prototype, protoProps);if (staticProps) _defineProperties(Constructor, staticProps);return Constructor;}import * as THREE from \"three\";\n\n\nvar pt = new THREE.Vector3();\nvar tmpBox = new Float32Array(6);\n\n\nvar STRATEGY_HIERARCHY = 'hierarchy'; // InstanceTree-approach\nvar STRATEGY_RADIAL = 'radial'; // FragList-approach\n\nvar _strategy = STRATEGY_HIERARCHY;\n\n/**\n * Contains logic for exploding a model, which separate model parts away from the\n * center, by using the model's hierarchy to drive the displacement.\n *\n * @private\n */\nexport var ModelExploder = /*#__PURE__*/function () {\n\n function ModelExploder() {_classCallCheck(this, ModelExploder);\n\n }\n\n /**\n * Sets the algorithm identifier that will explode all models.\n *\n * @param {string} newStrategy - Algorithm identifier. Refer to STRETEGY_XXXX const values above.\n *\n * @returns {boolean} true if the strategy changed\n */_createClass(ModelExploder, null, [{ key: \"setStrategy\", value: function setStrategy(\n newStrategy) {\n if (_strategy !== newStrategy) {\n _strategy = newStrategy;\n return true;\n }\n }\n\n /**\n * @returns {string} An identifier for the algorithm being used to explode models.\n */ }, { key: \"getStrategy\", value: function getStrategy()\n {\n return _strategy;\n }\n\n /**\n * @param {Autodesk.Viewing.Model} model - The model that will get its parts (dbIds) exploded.\n * @param {Number} scale - Value between 0 (no explotion) to 1 (fully exploded).\n */ }, { key: \"explode\", value: function explode(\n model, scale) {\n\n var it = model.getData().instanceTree;\n\n var fragList = model.getFragmentList();\n\n var mc = model.getVisibleBounds(true).center();\n\n //If we have a full part hierarchy we can use a\n //better grouping strategy when exploding\n if (_strategy === STRATEGY_HIERARCHY && it && scale !== 0) {\n\n _explodeWithInstanceTree(it, fragList, scale, mc);\n } else\n {\n\n // _strategy === STRATEGY_RADIAL\n _explodeWithFragList(fragList, it, scale, mc);\n }\n } }]);return ModelExploder;}();\n\n\n\n/**\n * Applies explotion by leveraging the instanceTree.\n *\n * @param {InstanceTree} it\n * @param {FragmentList} fragList\n * @param {number} scale - Value between 0 and 1.\n * @param {THREE.Vector3} mc - Model's Center point\n *\n * @private\n */\nfunction _explodeWithInstanceTree(it, fragList, scale, mc) {\n\n //Input scale is in the range 0-1, where 0\n //means no displacement, and 1 maximum reasonable displacement.\n scale *= 2;\n\n // If scale is small (close to 0), the shift is only applied to the topmost levels of the hierarchy.\n // With increasing s, we involve more and more hierarchy levels, i.e., children are recursively shifted \n // away from their parent node centers.\n // Since explodeValue is integer, it will behave discontinous during a transition from s=0 to s=1.\n // To keep the overall transition continuous, we use the fractional part of scaledExplodeDepth\n // to smoothly fade-in the transition at each hierarchy level. \n\n // levels beyond explodeDepth, we stop shifting children away from their parent.\n // \n var scaledExplodeDepth = scale * (it.maxDepth - 1) + 1; // [1, 2 * it.maxDepth - 1]\n if (it.maxDepth === 1) {\n // Hack to get flat-instanceTrees to explode\n scaledExplodeDepth = scale;\n }\n var explodeDepth = 0 | scaledExplodeDepth; // [1, 2 * it.maxDepth - 1]\n var currentSegmentFraction = scaledExplodeDepth - explodeDepth; // [0, 1)\n\n // Define recursive function to traverse object hierarchy. Each object is shifted away \n // from the bbox center of its parent.\n // number nodeId: dbId of the current instanceTree node\n // int depth: tracks hierarchy level (0 for root)\n // vec3 (cx,cy,cz): center of the parent object (after applying the displacement to the parent object) \n // vec3 (ox,oy,oz): accumuled displacement from all parents on the path to root\n function explodeRec(nodeId, depth, cx, cy, cz, ox, oy, oz) {\n\n var oscale = scale * 2; //TODO: also possibly related to depth\n if (depth == explodeDepth)\n oscale *= currentSegmentFraction; //smooth transition of this tree depth from non-exploded to exploded state\n\n // get bbox center of this node\n it.getNodeBox(nodeId, tmpBox);\n var mycx = 0.5 * (tmpBox[0] + tmpBox[3]);\n var mycy = 0.5 * (tmpBox[1] + tmpBox[4]);\n var mycz = 0.5 * (tmpBox[2] + tmpBox[5]);\n\n // The root node (depth==0) has no parent to shift away from.\n // For child nodes with level > explodDepth, we don't apply additional displacement anymore - just pass the displacement of the parents.\n if (depth > 0 && depth <= explodeDepth) {\n // add displacement to move this object away from its parent's bbox center (cx, cy, cz)\n var dx = (mycx - cx) * oscale;\n var dy = (mycy - cy) * oscale;\n var dz = (mycz - cz) * oscale;\n\n //var omax = Math.max(dx, Math.max(dy, dz));\n // sum up offsets: The final displacement of a node is accumulated by its own shift and \n // the shifts of all nodes up to the root.\n ox += dx;\n oy += dy;\n oz += dz;\n }\n\n if (it.isNodeExplodeLocked(nodeId)) {\n ox = oy = oz = 0;\n }\n\n // continue recursion with child objects (if any)\n it.enumNodeChildren(nodeId, function (dbId) {\n explodeRec(dbId, depth + 1, mycx, mycy, mycz, ox, oy, oz);\n }, false);\n\n pt.x = ox;\n pt.y = oy;\n pt.z = oz;\n\n // set translation as anim transform for all fragments associated with the current node\n it.enumNodeFragments(nodeId, function (fragId) {\n\n fragList.updateAnimTransform(fragId, null, null, pt);\n\n }, false);\n\n }\n\n explodeRec(it.getRootId(), 0, mc.x, mc.y, mc.z, 0, 0, 0); // run on root to start recursion\n}\n\n\n/**\n * Applies explotion by leveraging the FragmentList (no hierarchy). \n *\n * @param {FragmentList} fragList\n * @param {InstanceTree} it - Only used to check whether a dbId is \"locked\" and should not be exploded.\n * @param {number} scale - Value between 0 and 1.\n * @param {THREE.Vector3} mc - Model's Center point\n */\nfunction _explodeWithFragList(fragList, it, scale, mc) {\n\n // Float32Array array with 6 floats per bbox.\n var boxes = fragList.fragments.boxes;\n\n // The dbId to check for locked explode may come from the vizmesh\n // or the fragId2dbId array, depending on how the model was loaded.\n var vizmeshes;\n var dbIds;\n if (fragList.useThreeMesh)\n vizmeshes = fragList.vizmeshes;else\n\n dbIds = fragList.fragments.fragId2dbId;\n\n for (var i = 0, iEnd = fragList.getCount(); i < iEnd; i++) {\n\n // For scale to 0, if the node explode is locked.\n if (scale == 0 || it && it.isNodeExplodeLocked(\n vizmeshes ? vizmeshes[i] && vizmeshes[i].dbId : dbIds[i])) {\n // reset to unexploded state, i.e., remove all animation transforms\n fragList.updateAnimTransform(i);\n\n } else {\n\n // get start index of the bbox for fragment i. \n var box_offset = i * 6;\n\n // get bbox center of fragment i\n var cx = 0.5 * (boxes[box_offset] + boxes[box_offset + 3]);\n var cy = 0.5 * (boxes[box_offset + 1] + boxes[box_offset + 4]);\n var cz = 0.5 * (boxes[box_offset + 2] + boxes[box_offset + 5]);\n\n // compute translation vector for this fragment:\n // We shift the fragment's bbox center c=(cx,cy,cz) away from the overall model center mc,\n // so that the distance between the two will finally be scaled up by a factor of (1.0 + scale).\n //\n pt.x = scale * (cx - mc.x);\n pt.y = scale * (cy - mc.y);\n pt.z = scale * (cz - mc.z);\n\n fragList.updateAnimTransform(i, null, null, pt);\n }\n }\n}","import { FrustumIntersector } from './FrustumIntersector';\nimport * as THREE from \"three\";\n\nexport function ModelIteratorBVH() {\n\n var _frags;\n\n // Nodes in the BVH, in an array for easy access to all of them.\n // There are up to two trees, one for opaques, one for transparent objects.\n // These are normally listed top-down, in a flattened list, e.g., if all the objects\n // in the scene were transparent, _bvhNodes[0] = 0, and the 0 node would have not\n // children and no primitives, as this node would contain all the opaque fragments,\n // of which there are none. The transparent tree is always in _bvhNodes[1], and might\n // look something like this:\n // 1\n // 2 3\n // 4 5 6 7\n // with the children 4-7 each containing a RenderBatch of some number of fragments. Note\n // that inner nodes can also have RenderBatches.\n var _bvhNodes = null;\n // There's indirection for each RenderBatch. A RenderBatch contains a number of fragments.\n // Rather than an array per RenderBatch, a single array is accessed by all RenderBatches.\n // The primitives are in a list sorted by surface area. We preserve this. In this\n // _bvhFragOrder array we by a flattened list of children fragment indices. So child 4,\n // above, might have 3 objects, and their indices might be [291 12 55].\n // primStart and primCount access this array.\n // Also see bvh_partition and the comment there.\n var _bvhFragOrder = null;\n // _bvhScenes is a sparse array of RenderBatches, each RenderBatch has a few fragments.\n // Only those elements in the array that have a RenderBatch are defined.\n var _bvhScenes = null;\n // What is the containment state of this node, if known? Is either CONTAINMENT_UNKNOWN\n // or INTERSECTS or CONTAINS. If CONTAINS, we don't have to run the frustum cull\n // test, saving a few percent in speed.\n var _bvhContainment = null;\n var _bvhNodeQueue = null,_bvhNodeAreas = null,_bvhHead,_bvhTail;\n var _bvhLIFO = 1;\n var _bvhPrioritizeScreenSize = true;\n var _bvhOpaqueDone = false;\n var _bvhOpaqueSkipped = false; // true if skipOpaqueShapes has been called in the current traversal.\n var _tmpBox = new THREE.Box3();\n var _tmpBox2 = new THREE.Box3();\n var _frustum;\n var _done = false;\n var _RenderBatch;\n //var _time0 = 0;\n var _resetVisStatus = true;\n\n\n this.initialize = function (renderModelLinear, nodes, primitives, options) {\n\n _frags = renderModelLinear.getFragmentList();\n // Take the RenderBatch class from the model, so on demand loading can\n // use a different class to handle redraws propertly\n _RenderBatch = renderModelLinear.RenderBatch;\n\n if (options && options.hasOwnProperty(\"prioritize_screen_size\")) {\n _bvhPrioritizeScreenSize = options.prioritize_screen_size;\n }\n\n _bvhFragOrder = primitives;\n _bvhScenes = new Array(nodes.nodeCount);\n _bvhContainment = new Int8Array(nodes.nodeCount);\n _bvhNodes = nodes;\n _bvhNodeQueue = new Int32Array(nodes.nodeCount + 1);\n _bvhNodeAreas = new Float32Array(nodes.nodeCount);\n\n for (var i = 0; i < nodes.nodeCount; i++) {\n var primCount = nodes.getPrimCount(i);\n // does this node have real objects in it?\n if (primCount) {\n _bvhScenes[i] = new _RenderBatch(_frags, _bvhFragOrder, nodes.getPrimStart(i), primCount);\n // These are set manually, because we will not be adding fragments to the\n // render batch one by one -- the fragments are already loaded.\n _bvhScenes[i].lastItem = _bvhScenes[i].start + primCount;\n _bvhScenes[i].numAdded = primCount;\n _bvhScenes[i].nodeIndex = i;\n if (nodes.getFlags(i) & 8) {\n _bvhScenes[i].sortObjects = true; //scene contains transparent objects\n }\n nodes.getBoxArray(i, _bvhScenes[i].bboxes);\n }\n }\n\n };\n\n // note: fragId and mesh are not used in this function\n this.addFragment = function (fragId, mesh) {\n };\n\n\n this.reset = function (frustum) {\n _frustum = frustum;\n _bvhHead = 0;_bvhTail = 0;\n // means \"unknown containment state\"\n _bvhContainment[0] = _bvhContainment[1] = FrustumIntersector.CONTAINMENT_UNKNOWN;\n // prime the pump: the first entry is set to BVH node 0,\n // which is the first node in the first hierarchy (the opaque one) that we'll examine.\n // The ++ here is just for consistency; we could have set tail to 1\n // and used 0 as the index. _bvhTail will immediately get decremented to 0 by nextBatch;\n // it's incremented here to initially pass the while() loop there.\n _bvhNodeQueue[_bvhTail++] = 0;\n _bvhOpaqueDone = false;\n _bvhOpaqueSkipped = false;\n _done = false;\n //_time0 = Date.now();\n if (_resetVisStatus) {\n var scenes = _bvhScenes;\n var len = scenes.length;\n for (var i = 0; i < len; ++i) {\n var scene = scenes[i];\n if (scene && scene.resetVisStatus) {\n scene.resetVisStatus();\n }\n }\n _resetVisStatus = false;\n }\n };\n\n\n // Used to insert nodes into the (sorted) render queue based on\n // a heuristic other than strict front to back or back to front order.\n // Currently we always use this for sorting by screen area.\n function insertNode(idx) {\n\n //This is basically a single sub-loop of an insertion sort.\n\n var val = _bvhNodeAreas[idx];\n var j = _bvhTail;\n\n if (_bvhLIFO) {\n // For LIFO we insert the largest at the end of the list, since they\n // are the first to be popped\n while (j > _bvhHead && _bvhNodeAreas[_bvhNodeQueue[j - 1]] > val) {\n _bvhNodeQueue[j] = _bvhNodeQueue[j - 1];\n j--;\n }\n } else {\n // For FIFO we insert the largest at the front of the list.\n while (j > _bvhHead && _bvhNodeAreas[_bvhNodeQueue[j - 1]] < val) {\n _bvhNodeQueue[j] = _bvhNodeQueue[j - 1];\n j--;\n }\n }\n\n _bvhNodeQueue[j] = idx;\n _bvhTail++;\n }\n\n this.nextBatch = function () {\n\n if (!_bvhOpaqueSkipped && !_bvhOpaqueDone && _bvhHead === _bvhTail) {\n //If we are done with the opaque nodes, queue the transparent ones\n //before processing the contents of the last opaque node\n _bvhNodeQueue[_bvhTail++] = 1; //root of transparent subtree is at index 1\n _bvhOpaqueDone = true;\n }\n\n // _bvhHead and _bvhTail are indices into the BVH node list. For the opaque objects\n // these start at 0 and 1, respectively. The idea here is to work through the bounding\n // volume hierarchy, with inner nodes sorted into the list by large-to-small screen area\n // (or front-to-back, or back-to-front) order as we go. The way this loop ends is when\n // nothing is on the BVH node stack, or a render batch of stuff to render is found.\n // The next time this method is called, the current _bvhHead and _bvhTail values pick\n // up where they left off, continuing to traverse the tree, until another batch is found\n // or the stack (list) is emptied.\n // Note: this is a breadth-first traversal, but render batches can and do get returned\n // before the whole tree is traversed, because these can be found in inner nodes.\n // This means that there may be nodes with larger screen areas that come later on.\n while (_bvhHead !== _bvhTail) {\n\n // Retrieve node index for what to process in the BVH. _bvhNodeQueue contains the indices\n // of the node(s) in the BVH that are to be processed. \n // For LIFO, for example, when the nodeIdx is first retrieved, _bvhTail initially\n // goes to 0, and so grabs the index at location 0 in _bvhNodeQueue, typically the top of\n // the opaque tree. The rest of this loop may add to this queue, and/or return fragments to\n // render, in which case it exits. If nothing got returned (yet) and the loop continues,\n // the next time around through this loop, the last\n // BVH node put on this _bvhNodeQueue stack (if LIFO is true) is retrieved (if not LIFO,\n // the first object on the list is retrieved and _bvhHead is incremented).\n // Inner nodes will add their two children in proper order to _bvhNodeQueue and increment _bvhTail, twice.\n var nodeIdx = _bvhLIFO || _bvhOpaqueDone ? _bvhNodeQueue[--_bvhTail] : _bvhNodeQueue[_bvhHead++];\n\n // Is box already found to be contained? This happens when a box's parent is fully contained.\n // We can then avoid the frustum test.\n var intersects = _bvhContainment[nodeIdx];\n if (intersects !== FrustumIntersector.CONTAINS) {\n // could be outside or intersecting, so do test\n _bvhNodes.getBoxThree(nodeIdx, _tmpBox);\n intersects = _frustum.intersectsBox(_tmpBox);\n }\n\n //Node is entirely outside, go on to the next node\n if (intersects !== FrustumIntersector.OUTSIDE) {\n var child = _bvhNodes.getLeftChild(nodeIdx);\n var isInner = child !== -1;\n var firstIdx, secondIdx;\n\n //Is it inner node? Add children for processing.\n if (isInner) {\n var flags = _bvhNodes.getFlags(nodeIdx);\n var reverseAxis = _frustum.viewDir[flags & 3] < 0 ? 1 : 0;\n var firstChild = flags >> 2 & 1;\n var transparent = flags >> 3 & 1;\n var depthFirst = _bvhLIFO || _bvhOpaqueDone ? 1 : 0;\n var areaFirst = 0,areaSecond = 0;\n\n // For opaque objects, use the screen size to sort the two children,\n // or front to back order (back to front for transparent objects).\n if (_bvhPrioritizeScreenSize && !_bvhOpaqueDone) {\n\n //If traversing based on visible screen area, we have to\n //compute the area for each child and insert them into\n //the queue accordingly.\n\n firstIdx = child + firstChild;\n secondIdx = child + 1 - firstChild;\n\n _bvhNodes.getBoxThree(firstIdx, _tmpBox);\n _bvhNodeAreas[firstIdx] = areaFirst = _frustum.projectedBoxArea(_tmpBox, intersects === FrustumIntersector.CONTAINS);\n _bvhNodes.getBoxThree(secondIdx, _tmpBox);\n _bvhNodeAreas[secondIdx] = areaSecond = _frustum.projectedBoxArea(_tmpBox, intersects === FrustumIntersector.CONTAINS);\n\n // \"worst case\" containment is recorded for later examination.\n _bvhContainment[firstIdx] = _bvhContainment[secondIdx] = intersects;\n\n // Insert each node in the right place based on screen area,\n // so that the queue (or stack, if LIFO traversal) is kept sorted\n // at every step of the way.\n // Note that with LIFO, for example, the larger object is put last on\n // the list (a stack), since we want to pop this one off first.\n if (areaFirst > 0)\n insertNode(firstIdx);\n\n if (areaSecond > 0)\n insertNode(secondIdx);\n } else {\n\n //Traversal by view direction.\n\n //Reverse order if looking in the negative of the child split axis\n //Reverse order if we are traversing last first\n //If node contains transparent objects, then reverse the result so we traverse back to front.\n //In other words, reverse the order if an odd number of flags are true.\n if (reverseAxis ^ depthFirst ^ transparent)\n firstChild = 1 - firstChild;\n\n firstIdx = child + firstChild;\n secondIdx = child + 1 - firstChild;\n\n _bvhNodeQueue[_bvhTail++] = firstIdx;\n _bvhNodeAreas[firstIdx] = -1; //TODO: This has to be something based on camera distance\n //so that we can draw transparent back to front when multiple models are mixed\n\n _bvhNodeQueue[_bvhTail++] = secondIdx;\n _bvhNodeAreas[secondIdx] = -1;\n\n // \"worst case\" containment is recorded for later examination.\n _bvhContainment[firstIdx] = _bvhContainment[secondIdx] = intersects;\n }\n\n }\n\n // Are there graphics in the node? Then return its scene, i.e. its RenderBatch.\n // Inner nodes with children can and do have render batches of their own.\n // This works against a pure screen=area or front-to-back ordering, as\n // these fragments will always get returned first, before further traversal of the tree.\n var prims = _bvhNodes.getPrimCount(nodeIdx);\n if (prims !== 0) {\n var scene = _bvhScenes[nodeIdx];\n\n scene.renderImportance = _frustum.projectedBoxArea(scene.getBoundingBox(), intersects === FrustumIntersector.CONTAINS);\n\n //NOTE: Frustum culling for the RenderBatch is done in\n //RenderBatch.applyVisibility, so we don't need it here.\n //Just return the batch and it will get cull checked later.\n //TODO: May be we want to move the check to here, but then the linear iterator will also need to start checking.\n /*\n var whichBox = (_drawMode === RenderFlags.RENDER_HIDDEN) ? scene.getBoundingBoxHidden() : scene.getBoundingBox();\n //If the geometry is attached to an inner node and we know\n //it's not fully contained, we can narrow down the intersection\n //by checking the box of just the inner node's geometry.\n //The check for the node box itself also includes the children so it could be bigger.\n if (intersects !== CONTAINS && isInner)\n intersects = _frustum.intersectsBox(whichBox);\n //Turn off frustum culling for the batch if it's fully contained\n scene.frustumCulled = (intersects !== FrustumIntersector.CONTAINS);\n if (intersects !== FrustumIntersector.OUTSIDE)\n return scene;\n */\n\n\n\n\n return scene;\n }\n }\n\n if (!_bvhOpaqueDone && !_bvhOpaqueSkipped && _bvhHead === _bvhTail) {\n //If we are done with the opaque nodes, queue the transparent ones\n //before processing the contents of the last opaque node\n _bvhNodeQueue[_bvhTail++] = 1; //root of transparent subtree is at index 1\n _bvhOpaqueDone = true;\n }\n\n }\n\n //var time1 = Date.now();\n //var msg = \"BVH traversal time: \" + (time1 - _time0);\n //console.log(msg);\n\n _done = true;\n return null;\n };\n\n this.skipOpaqueShapes = function () {\n if (!_bvhOpaqueDone && !_bvhOpaqueSkipped) {\n // start traversal of transparent hierarchy\n _bvhHead = 0;\n _bvhTail = 0;\n _bvhNodeQueue[_bvhTail++] = 1; //root of transparent subtree is at index 1\n _bvhOpaqueSkipped = true;\n }\n };\n\n function updateBVHRec(nodeIdx) {\n\n var child = _bvhNodes.getLeftChild(nodeIdx);\n\n if (child !== -1) {\n updateBVHRec(child);\n updateBVHRec(child + 1);\n }\n\n _tmpBox.makeEmpty();\n\n if (child !== -1) {\n _bvhNodes.getBoxThree(child, _tmpBox2);\n _tmpBox.union(_tmpBox2);\n\n _bvhNodes.getBoxThree(child + 1, _tmpBox2);\n _tmpBox.union(_tmpBox2);\n }\n\n var prims = _bvhNodes.getPrimCount(nodeIdx);\n if (prims) {\n _tmpBox.union(_bvhScenes[nodeIdx].getBoundingBox());\n _tmpBox.union(_bvhScenes[nodeIdx].getBoundingBoxHidden());\n }\n\n _bvhNodes.setBoxThree(nodeIdx, _tmpBox);\n }\n\n this.getVisibleBounds = function (visibleBounds, visibleBoundsWithHidden) {\n\n for (var i = 0; i < _bvhScenes.length; i++) {\n\n var s = _bvhScenes[i];\n\n if (!s)\n continue;\n\n s.calculateBounds();\n\n var bb = s.getBoundingBox();\n visibleBounds.union(bb);\n\n visibleBoundsWithHidden.union(bb);\n visibleBoundsWithHidden.union(s.getBoundingBoxHidden());\n }\n\n //Also update all bounding volume tree nodes' bounds.\n //If objects move too much this will make the BVH less effective.\n //However, this only happens during explode or animation, so it shouldn't\n //be an issue. We can always rebuild the BVH in case objects really move a lot.\n updateBVHRec(0); //opaque root\n updateBVHRec(1); //transparent root\n\n };\n\n this.rayCast = function (raycaster, intersects, dbIdFilter) {\n\n var nodeStack = [1, 0];\n var pt = new THREE.Vector3();\n\n while (nodeStack.length) {\n var nodeIdx = nodeStack.pop();\n\n _bvhNodes.getBoxThree(nodeIdx, _tmpBox);\n\n // Expand bounding box a bit, to take into account axis aligned lines\n _tmpBox.expandByScalar(0.5);\n var xPt = raycaster.ray.intersectBox(_tmpBox, pt);\n\n if (xPt === null)\n continue;\n\n var child = _bvhNodes.getLeftChild(nodeIdx);\n if (child !== -1) {\n nodeStack.push(child);\n nodeStack.push(child + 1);\n }\n\n var prims = _bvhNodes.getPrimCount(nodeIdx);\n if (prims !== 0) {\n var scene = _bvhScenes[nodeIdx];\n scene.raycast(raycaster, intersects, dbIdFilter);\n }\n }\n\n };\n /*\n this.getRenderProgress = function() {\n return _renderCounter / _bvhScenes.length;\n };\n */\n this.getSceneCount = function () {\n return _bvhScenes.length;\n };\n\n this.getGeomScenes = function () {\n return _bvhScenes;\n };\n\n this.done = function () {\n return _done;\n };\n\n this.resetVisStatus = function () {\n _resetVisStatus = true;\n };\n\n}","function _classCallCheck(instance, Constructor) {if (!(instance instanceof Constructor)) {throw new TypeError(\"Cannot call a class as a function\");}}function _defineProperties(target, props) {for (var i = 0; i < props.length; i++) {var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if (\"value\" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);}}function _createClass(Constructor, protoProps, staticProps) {if (protoProps) _defineProperties(Constructor.prototype, protoProps);if (staticProps) _defineProperties(Constructor, staticProps);return Constructor;}import { RenderBatch } from './RenderBatch';\nimport { isMobileDevice } from '../../compat';\n\n\n//TODO: better heuristic for group size might be needed\n//But it should be based on polygon count as well as\n//fragment count. But polygon count is not known\n//until we get the meshes later on.\nvar MAX_FRAGS_PER_GROUP = 500;\n\nvar calculateFragsPerScene = function calculateFragsPerScene(is2d) {\n // choose _fragsPerScene based on scene type and device\n var fragsPerScene = MAX_FRAGS_PER_GROUP;\n if (is2d)\n fragsPerScene /= 6; //2d meshes are all fully packed, so we can't draw so many per batch.\n if (isMobileDevice()) {\n fragsPerScene /= 3; //This is tuned for ~15fps on Nexus 7.\n }\n fragsPerScene = Math.floor(fragsPerScene);\n return fragsPerScene > 0 ? fragsPerScene : MAX_FRAGS_PER_GROUP;\n};\n\n/**\n * All rendering and other scene related data associated with a 3D model or 2D Drawing.\n * The \"linear\" variant uses simple non-hierarchical linear scene traversal when rendering a frame.\n * Good for small scenes, incrementally loaded scenes, and 2D drawings where draw order matters.\n * @constructor\n */\nexport var ModelIteratorLinear = /*#__PURE__*/function () {\n\n function ModelIteratorLinear(renderModel) {_classCallCheck(this, ModelIteratorLinear);\n\n this._frags = renderModel.getFragmentList();\n // Take the RenderBatch class from the model, so on demand loading can\n // use a different class to handle redraws properly\n this._RenderBatch = renderModel.RenderBatch;\n this._model = renderModel;\n this._is2d = this._model.is2d();\n this._fragsPerScene = calculateFragsPerScene(renderModel.is2d());\n this._fragOrder = [];\n this._geomScenes = [];\n this._secondPassIndex = null; // Used to mark where in _geomScenes the second pass scenes start.\n\n var fragCount = this._frags.getCount();\n\n // index of the scene in _geomScenes that the next nextBatch() call will return.\n this._currentScene = 0;\n\n //Custom re-order of the fragments for optimized rendering.\n //those are indices into the immutable vizmeshes fragment list.\n //Trivial largest to smallest order\n var fragOrder = new Int32Array(fragCount);\n for (var i = 0; i < fragCount; i++) {\n fragOrder[i] = i;\n }\n\n this.setFragmentOrder(fragOrder, fragCount);\n }_createClass(ModelIteratorLinear, [{ key: \"setFragmentOrder\", value: function setFragmentOrder(\n\n fragOrder, fragmentCount) {\n this._fragCount = fragmentCount;\n\n //NOTE: We use the array container as reference to pass to RenderBatches, because the\n //typed array can get resized when loading data with unknown size\n this._fragOrder[0] = fragOrder;\n\n //Create a RenderBatch for each batch of fragments.\n //We will then draw each batch in turn to get a progressive\n //effect. The number of fragments per batch should be close\n //to what we can draw in a single frame while maintaining interactivity.\n //This linear list of batches is used for 2D scenes and for 3D scenes\n //while they are loading. After load is done, the linear traversal is replaced\n //by a view-based bounding volume hierarchy traversal.\n\n // Given the maximum fragCount per batch, compute the required number of batches to fit in all fragments\n var numScenes = Math.floor((this._fragCount + this._fragsPerScene - 1) / this._fragsPerScene);\n\n // create array with a RenderBatch per fragment group.\n // Note that this will only create all batches if the full fragCount is known in advance. Otherwise, they have to be created\n // later via addFragment() calls.\n this._geomScenes.length = numScenes;\n for (var i = 0; i < numScenes; i++) {\n var startIndex = i * this._fragsPerScene;\n var scene = this._geomScenes[i] = new this._RenderBatch(this._frags, this._fragOrder, startIndex, this._fragsPerScene);\n var lastIndex = startIndex + this._fragsPerScene;\n\n // Crop last batch at the end, so that it does not exceed the fragment count. The last batch has usually not full\n // length, unless fragCount is a multiple of\n if (lastIndex > this._fragCount)\n lastIndex = this._fragCount;\n scene.lastItem = lastIndex;\n }\n }\n\n // Only needed if the full fragment count is not known in advance.\n // For incremental loading, this method makes sure that \n // - fragOrder has required size \n // - fragOrder defines trivial ordering of all frags added so far\n // - _geomScenes contains a batch containing the new fragment\n //\n // Assumptions: Fragments are currently added by increasing fragId. Otherwise, _geomScenes might contain null-elements,\n // which may cause exceptions, e.g., in nextBatch() and getVisibleBounds().\n }, { key: \"addFragment\", value: function addFragment(fragId) {\n //The frag order indices array will not auto-resize (it's ArrayBuffer)\n //so we have to do it manually\n if (this._fragOrder[0].length <= fragId)\n {\n var nlen = 2 * this._fragOrder[0].length;\n if (nlen <= fragId)\n nlen = fragId + 1;\n\n var ninds = new Int32Array(nlen);\n ninds.set(this._fragOrder[0]);\n this._fragOrder[0] = ninds;\n\n //We only set this when the fragment index goes\n //beyond the initial fragment size -- assuming\n //that the initial bounds passed into the RenderQueue constructor\n //is valid for the initial fragment list.\n this.visibleBoundsDirty = true;\n }\n //Note: this assumes trivial ordering\n //We cannot set/add meshes if reordering of the indices has already happened.\n //This is OK, because trivial ordering with unknown initial fragment count\n //happens only for 2D models where we preserve trivial draw order anyway.\n this._fragOrder[0][fragId] = fragId;\n\n\n //Find a parent for the mesh -- in the case of SVF\n //fragments we just map fragment index to increasing\n //scene index, since fragments are already ordered\n //in the way we want to draw them\n var sceneIndex = Math.floor(fragId / this._fragsPerScene);\n if (this._geomScenes) {\n var scene = this._geomScenes[sceneIndex];\n if (!scene || scene.isSecondPass) {\n // Note that it's okay that the batch may also reference fragments that were not added yet. \n // The RenderBatch does not require all fragments to be in memory already.\n scene = new this._RenderBatch(this._frags, this._fragOrder, sceneIndex * this._fragsPerScene, this._fragsPerScene);\n\n if (this._secondPassIndex === null) {\n this._geomScenes[sceneIndex] = scene;\n } else {\n // If we are already using a second pass, need to add this new scene as well. This will most probably\n // rarely happen, but this should cover that case anyway.\n this.insertSceneToSecondPass(sceneIndex, scene);\n }\n }\n // Did scene get set reasonably?\n if (scene) {\n // Notify batch about new fragment, so that the batch updates internal state like summed bbox and material sorting\n scene.onFragmentAdded(fragId);\n if (this._secondPassIndex !== null) {\n this._geomScenes[this._secondPassIndex + sceneIndex].onFragmentAdded(fragId);\n }\n }\n }\n } }, { key: \"insertSceneToSecondPass\", value: function insertSceneToSecondPass(\n\n sceneIndex, scene) {\n // The two passes are located one after the other in geomScenes, to keep the iterator logic simple.\n // That means that if we need to add a scene, we first split the two passes, insert the scene into\n // each pass, and join them again.\n // This makes no assumption where in the array the scene is added. The only assumption is that the two\n // passes are in sync, that is, they are of the same length.\n var firstPassScenes = this._geomScenes.slice(0, this._secondPassIndex);\n var secondPassScenes = this._geomScenes.slice(this._secondPassIndex);\n\n firstPassScenes[sceneIndex] = scene;\n secondPassScenes[sceneIndex] = this.cloneForSecondPass(scene);\n this._secondPassIndex = firstPassScenes.length;\n this._geomScenes = firstPassScenes.concat(secondPassScenes);\n }\n\n // restart iterator\n }, { key: \"reset\", value: function reset(frustum, camera) {\n this._currentScene = 0;\n if (this._is2d && this._geomScenes[0]) {\n this._geomScenes[0].drawEnd = 0;\n if (this._secondPassIndex !== null) {\n this._geomScenes[this._secondPassIndex].drawEnd = 0;\n }\n }\n\n if (this._resetVisStatus) {\n var scenes = this._geomScenes;\n var len = scenes.length;\n for (var i = 0; i < len; ++i) {\n var scene = scenes[i];\n if (scene && scene.resetVisStatus) {\n scene.resetVisStatus();\n }\n }\n this._resetVisStatus = false;\n }\n } }, { key: \"getSceneCount\", value: function getSceneCount()\n\n {\n return this._geomScenes.length;\n } }, { key: \"getGeomScenes\", value: function getGeomScenes()\n\n {\n return this._geomScenes;\n } }, { key: \"resetVisStatus\", value: function resetVisStatus()\n\n {\n this._resetVisStatus = true;\n } }, { key: \"done\", value: function done()\n\n {\n // If we are filling f2d batches, then we aren't done until the model is loaded\n if (this._is2d && !this._model.isLoadDone())\n return false;\n // Once the model is loaded, we are done when the last batch is drawn\n var res;\n return this._currentScene >= this._geomScenes.length - 1 && (\n !(res = this._geomScenes[this._currentScene]) || res.drawStart >= res.lastItem);\n } }, { key: \"nextBatch\",\n\n // Returns the next RenderBatch from _geomScenes or null when reaching the end.\n value: function nextBatch() {\n if (this._currentScene >= this.getSceneCount())\n return null;\n\n // As long as fragments are added in order of increasing id, res will never be null.\n var res = this._geomScenes[this._currentScene];\n\n if (!this._is2d) {\n // Render importance is used to decide what to render next when using progressive rendering with multiple models. (see RenderScene.renderSome)\n // For linear iterator, is treated as equally important.\n res.renderImportance = 0;\n ++this._currentScene;\n } else {\n var needsTwoPasses = this.areTwoPassesNeeded();\n // 2D scene, so we only want to proceed to the next batch when this current batch is filled.\n if (res.lastItem >= res.start + res.count) {\n ++this._currentScene;\n if (this._geomScenes[this._currentScene])\n this._geomScenes[this._currentScene].drawEnd = this._geomScenes[this._currentScene].start;\n }\n res.drawStart = res.drawEnd;\n res.drawEnd = res.lastItem;\n if (res.hasOwnProperty(\"drawStart\") && res.lastItem <= res.drawStart) {\n var isEndOfFirstPass = needsTwoPasses && !this._isSecondPass;\n if (isEndOfFirstPass) {\n // Start the second pass\n this._currentScene = this._secondPassIndex;\n return this.nextBatch();\n }\n return null; // all object in the batch have been drawn\n }\n\n // For the first pass change it to a large number to make sure it's rendered before 3D models (fixes transparency issues when mixing 2D/3D models)\n // For the second pass, set it to -1, so it's rendered after 3D models that are being loaded, since those also use the linear iterator and set\n // the importance to 0.\n var renderLast = !this._model.areAllVisible() || this._isSecondPass; // When the whole page is ghosted also render last\n res.renderImportance = renderLast ? -1.0 : 1e20;\n res.needsTwoPasses = needsTwoPasses;\n }\n\n return res;\n } }, { key: \"areTwoPassesNeeded\", value: function areTwoPassesNeeded()\n\n {\n // Currently used only for paper transparency.\n // Could be expanded for any case with transparency.\n var needsTwoPasses = this._model.hasPaperTransparency();\n if (needsTwoPasses && this._secondPassIndex === null) {\n // Add the second pass scenes only when deemed necessary\n this.addSecondPassScenes();\n }\n\n this._isSecondPass = !!(needsTwoPasses && this._currentScene >= this._secondPassIndex);\n\n return needsTwoPasses;\n } }, { key: \"cloneForSecondPass\", value: function cloneForSecondPass(\n\n scene) {\n if (!scene) return;\n\n var clone = scene.clone();\n clone.isSecondPass = true;\n return clone;\n } }, { key: \"addSecondPassScenes\", value: function addSecondPassScenes()\n\n {\n var numScenes = this._geomScenes.length;\n if (!numScenes) {\n return;\n }\n\n this._geomScenes = this._geomScenes.concat(this._geomScenes.map(this.cloneForSecondPass));\n this._secondPassIndex = numScenes;\n }\n\n // Computes the summed bboxes of all batches of the iterator and writes them to the out params:\n // - visibleBounds: instanceof THREE.Box3, bbox of all fragments excluding the ghosted ones.\n // - visibleBoundsWithHidden: instanceof THREE.Box3, bbox of all fragments \n //\n // [HB:] BBoxes are computed without considering MESH_HIDE flag in any way, see RenderBatch.calculateBounds(). Is this intended?\n }, { key: \"getVisibleBounds\", value: function getVisibleBounds(visibleBounds, visibleBoundsWithHidden) {\n\n //Case where we are not using BVH\n\n var len = this.getSceneCount();\n for (var i = 0; i < len; i++) {\n\n // make sure that the bboxes of the batch is up-to-date\n this._geomScenes[i].calculateBounds();\n\n // sum up bbox of fragments excluding ghosted\n var bb = this._geomScenes[i].getBoundingBox();\n visibleBounds.union(bb);\n\n // sum up bbox of all fragments\n visibleBoundsWithHidden.union(bb);\n visibleBoundsWithHidden.union(this._geomScenes[i].getBoundingBoxHidden());\n\n }\n }\n\n // Perform raycast on all batches. See RenderBatch.raycast() for params.\n }, { key: \"rayCast\", value: function rayCast(raycaster, intersects, dbIdFilter) {\n var len = this.getSceneCount();\n for (var i = 0; i < len; i++) {\n this._geomScenes[i].raycast(raycaster, intersects, dbIdFilter);\n }\n } }]);return ModelIteratorLinear;}();","import { VBIntersector } from './VBIntersector';\nimport { FrustumIntersector } from './FrustumIntersector';\nimport { MeshFlags } from \"./MeshFlags\";\nimport { RenderFlags } from \"./RenderFlags\";\nimport { logger } from \"../../logger/Logger\";\nimport { LmvBox3 as Box3 } from './LmvBox3';\n\n\nvar _tmpBox = new Box3();\nvar _depths = null;\n\n/**\n * Represents a subset of objects from a larger list, for e.g. a draw call batch\n * to send to the renderer. It's like a small view into an ordered FragmentList.\n *\n * frags -- FragmentList of all available meshes (1:1 correspondance with LMV fragments)\n * fragOrder -- Array of indices, pointing into the array of fragments\n * start -- start index in the array of indices\n * count -- how many mesh indices (after start index) are contained in the subset.\n * @constructor\n */\nexport function RenderBatch(frags, fragOrder, start, count) {\n\n this.frags = frags;\n this.indices = fragOrder; // may be a typed array (usually, Int32Array) or generic Array containing \n // the actual typed array in index 0, see getIndices(). May be null, which means indices[i]==i.\n this.start = start;\n this.count = count;\n this.lastItem = start; // Defines the (exclusive) range end used in this.forEach(). If a batch is complete, i.e. all fragments are added, \n // we usually have this.lastItem = this.start + this.count. But it may be smaller if dynamic adding is being used.\n // The final value of this.lastItem is set from outside by the creator (see e.g., ModelIteratorLinear or ModelIteratorBVH)\n // NOTE: this.lastItem must be set before this.forEach() has any effect.\n\n //Compatibility with THREE.Scene. Optional override material (instanceof THREE.ShaderMaterial) temporarily used by renderers.\n this.overrideMaterial = null;\n\n //Whether sort by material ID has been done\n this.sortDone = false;\n this.numAdded = 0; // number of added batches since last material sort\n\n this.avgFrameTime = undefined; // Average time spent for rendering this batch. Maintained externally by RenderScene.renderSome()\n\n this.nodeIndex = undefined; // Optional: Unique index of this RenderBatch (used by modelIteratorBVH/ConsolidationIterator)\n\n // Summed worldBoxes\n // First 6 terms are the visible bounds, second 6 terms are the hidden bounds\n this.bboxes = new Array(12);\n this.bboxes[0] = this.bboxes[1] = this.bboxes[2] = Infinity;\n this.bboxes[3] = this.bboxes[4] = this.bboxes[5] = -Infinity;\n this.bboxes[6] = this.bboxes[7] = this.bboxes[8] = Infinity;\n this.bboxes[9] = this.bboxes[10] = this.bboxes[11] = -Infinity;\n\n\n //Tells the renderer whether to sort by Z before drawing.\n //We only set this for RenderBatches containing transparent objects.\n this.sortObjects = false;\n\n this.sortDone = false;\n this.sortByShaderDone = false;\n\n //Tells the renderer whether to do per-mesh frustum culling.\n //In some cases when we know the whole batch is completely\n //contained in the viewing frustum, we turn this off.\n this.frustumCulled = true;\n\n //Used by ground shadow code path\n this.forceVisible = false;\n\n // FragmentList do not always contain THREE.Meshes for each shape. They may also just contain plain BufferGeometry \n // and THREE.ShaderMaterial. In this case, the renderer must handle the this batch using immediate mode rendering.\n // (see FragmentList.getVizmesh() and WebGLRenderer.render() for details)\n this.renderImmediate = !frags.useThreeMesh;\n\n //Set per frame during scene traversal\n this.renderImportance = 0.0;\n}\n\nRenderBatch.prototype.clone = function () {\n var renderBatch = new RenderBatch(this.frags, this.indices, this.start, this.count);\n renderBatch.sortDone = this.sortDone;\n renderBatch.sortByShaderDone = this.sortByShaderDone;\n renderBatch.lastItem = this.lastItem;\n renderBatch.visibleStats = this.visibleStats;\n renderBatch.numAdded = this.numAdded;\n renderBatch.bboxes = this.bboxes.slice();\n\n return renderBatch;\n};\n\nRenderBatch.prototype.getIndices = function () {\n // Note that isArray returns false for typed arrays like Int32Array.\n // isArray() is used to here to check whether indices is\n // a) a typed array itself or\n // b) a generic array containing the actual typed array in index 0.\n return Array.isArray(this.indices) ? this.indices[0] : this.indices;\n};\n\n// Sorts \nRenderBatch.prototype.sortByMaterial = function () {\n\n //Render batch must be complete before we can sort it\n if (this.numAdded < this.count)\n return;\n\n var frags = this.frags;\n var indices = this.getIndices();\n\n if (!indices) {\n logger.warn(\"Only indexed RenderSubsets can be sorted.\");\n return;\n }\n\n // apply sort only to the range used by this batch\n var tmp = indices.subarray(this.start, this.start + this.count);\n Array.prototype.sort.call(tmp, function (a, b) {\n var ma = frags.getMaterialId(a);\n var mb = frags.getMaterialId(b);\n\n if (ma === undefined)\n return mb ? 1 : 0;\n if (mb === undefined)\n return -1;\n\n return ma - mb;\n });\n\n //indices.set(tmp, this.start); // not needed because tmp already points to the same buffer\n\n // indicate that indices are sorted by material and no batches have beend added since then.\n this.numAdded = 0;\n this.sortDone = true;\n};\n\n//Sorts meshes in the render batch by shader ID, to avoid\n//unnecessary shader switching in the renderer when looping over a batch.\n//This can only be performed once the RenderBatch is full/complete and\n//all shaders are known.\nRenderBatch.prototype.sortByShader = function () {\n\n //Render batch must be complete before we can sort it\n if (!this.sortDone || this.sortByShaderDone)\n return;\n\n var frags = this.frags;\n var indices = this.getIndices();\n\n var tmp = indices.subarray(this.start, this.start + this.count);\n\n Array.prototype.sort.call(tmp, function (a, b) {\n var ma = frags.getMaterial(a);\n var mb = frags.getMaterial(b);\n\n var pd = ma.program.id - mb.program.id;\n if (pd)\n return pd;\n\n return ma.id - mb.id;\n });\n\n //indices.set(tmp, this.start);\n\n this.numAdded = 0;\n this.sortByShaderDone = true;\n};\n\n\n// Sorts this.indices by increasing depth for the current view.\n// Input: frustumIn instanceof FrustumIntersector\nRenderBatch.prototype.sortByDepth = function (frustumIn) {\n\n var frags = this.frags;\n var indices = this.getIndices();\n var frustum = frustumIn;\n var bbox = _tmpBox;\n\n if (!indices) {\n logger.warn(\"Only indexed RenderSubsets can be sorted.\");\n return;\n }\n\n // allocate this.depth to store a depth value for each fragment index in indicesView\n if (!_depths || _depths.length < this.count)\n _depths = new Float32Array(this.count);\n\n var depths = _depths;\n var start = this.start;\n\n // For each fragId indicesView[i], compute the depth and store it in depth[i]\n this.forEachNoMesh( // use frustum to calculate depth per fragment\n function calcDepth(fragId, i) {\n if (!frags.getGeometry(fragId))\n depths[i] = -Infinity;else\n {\n frags.getWorldBounds(fragId, bbox);\n depths[i] = frustum.estimateDepth(bbox);\n }\n });\n\n\n // Does not work, this call sorts on depths[indicesViews[i]], not depths[i],\n // where 'i' is an index into both the depths and indicesViews lists.\n //Array.prototype.sort.call(this.indicesView, sortCB);\n\n // Insertion sort appears to be about 7x or more faster\n // for lists of 64 or less objects vs. defining a sort() function.\n // Asking if there's a faster way. Traian mentioned quicksort > 8\n // objects; I might give this a try.\n var tempDepth, tempIndex;\n for (var j = 1; j < this.count; j++) {\n var k = j;\n while (k > 0 && depths[k - 1] < depths[k]) {\n\n // swap elem at position k one position backwards (for indices and depths)\n tempDepth = depths[k - 1];\n depths[k - 1] = depths[k];\n depths[k] = tempDepth;\n\n tempIndex = indices[start + k - 1];\n indices[start + k - 1] = indices[start + k];\n indices[start + k] = tempIndex;\n\n k--;\n }\n }\n\n //indices.set(this.indicesView, this.start); // Not needed because indicesView is already a view into this range\n};\n\n//Adds the given THREE.Box3 to the renderBatch bounding box or hidden object bounding box\nRenderBatch.prototype.addToBox = function (box, hidden) {\n var offset = hidden ? 6 : 0;\n var bb = this.bboxes;\n bb[0 + offset] = Math.min(bb[0 + offset], box.min.x);\n bb[1 + offset] = Math.min(bb[1 + offset], box.min.y);\n bb[2 + offset] = Math.min(bb[2 + offset], box.min.z);\n\n bb[3 + offset] = Math.max(bb[3 + offset], box.max.x);\n bb[4 + offset] = Math.max(bb[4 + offset], box.max.y);\n bb[5 + offset] = Math.max(bb[5 + offset], box.max.z);\n};\n\nRenderBatch.prototype.getBoundingBox = function (dst) {\n dst = dst || _tmpBox;\n var bb = this.bboxes;\n dst.min.x = bb[0];\n dst.min.y = bb[1];\n dst.min.z = bb[2];\n\n dst.max.x = bb[3];\n dst.max.y = bb[4];\n dst.max.z = bb[5];\n\n return dst;\n};\n\nRenderBatch.prototype.getBoundingBoxHidden = function (dst) {\n dst = dst || _tmpBox;\n var bb = this.bboxes;\n var offset = 6;\n dst.min.x = bb[0 + offset];\n dst.min.y = bb[1 + offset];\n dst.min.z = bb[2 + offset];\n\n dst.max.x = bb[3 + offset];\n dst.max.y = bb[4 + offset];\n dst.max.z = bb[5 + offset];\n\n return dst;\n};\n\n//Use only for incremental adding to linearly ordered (non-BVH) scenes!\nRenderBatch.prototype.onFragmentAdded = function () {\n\n return function (fragId) {\n\n // update bbox\n this.frags.getWorldBounds(fragId, _tmpBox);\n this.addToBox(_tmpBox, false);\n\n // mark \n this.sortDone = false;\n\n //NOTE: This only works with trivial fragment ordering (linear render queues).\n //Otherwise the item index does not necessarily match the fragId due to the \n //reordering jump table (this.indices).\n if (this.lastItem <= fragId) {\n this.lastItem = fragId + 1;\n if (this.visibleStats !== undefined)\n this.visibleStats = 0; // reset visibility, since a new fragment might change it\n this.numAdded++;\n }\n };\n}();\n\n\n/**\n * Iterates over fragments.\n * @param {function} callback - function(mesh, id) called for each fragment geometry.\n * - mesh: instanceof THREE.Mesh (as obtained from FragmentList.getVizmesh)\n * - id: fragment id\n * @param {number} drawMode - Optional flag (see FragmentList.js), e.g., MESH_VISIBLE. If specified, we only traverse fragments for which this flag is set.\n * @param {bool} includeEmpty - Default: false, i.e. fragments are skipped if they have no mesh available via getVizmesh().\n */\nRenderBatch.prototype.forEach = function (callback, drawMode, includeEmpty) {\n\n var indices = this.getIndices();\n\n var frags = this.frags;\n var sortByShaderPossible = !this.sortByShaderDone;\n\n //var showPF = (frags.showPF === undefined ) ? -1 : frags.showPF;\n\n //If the most likely rendering flags are true, use a shortened version of the for-loop.\n var i, iEnd, idx, m;\n if (!drawMode && !includeEmpty && !sortByShaderPossible) {\n for (i = this.start, iEnd = this.lastItem; i < iEnd; i++) {\n idx = indices ? indices[i] : i;\n\n // for debug only, if the PF is to be displayed, then check if this fragment is in the designated PF\n //if ((showPF !== -1) && (showPF !== frags.fragments.packIds[idx])) {\n // continue;\n //}\n\n var m = frags.getVizmesh(idx);\n\n if (m && m.geometry) {\n callback(m, idx);\n }\n }\n } else {\n for (i = drawMode === MeshFlags.MESH_RENDERFLAG && this.hasOwnProperty(\"drawStart\") ? this.drawStart : this.start, iEnd = this.lastItem; i < iEnd; i++) {\n idx = indices ? indices[i] : i;\n\n // for debug only, if the PF is to be displayed, then check if this fragment is in the designated PF\n //if ((showPF !== -1) && (showPF !== frags.fragments.packIds[idx])) {\n // continue;\n //}\n\n var m = frags.getVizmesh(idx);\n\n if (sortByShaderPossible && (!m || !m.material || !m.material.program || m.geometry_proxy))\n sortByShaderPossible = false;\n\n // if drawMode is given, iterate vizflags that match\n if ((includeEmpty || m && m.geometry) && (\n !drawMode || frags.isFlagSet(idx, drawMode))) {\n\n callback(m, idx);\n }\n }\n }\n\n //If all materials shaders are already available, we can sort by shader\n //to minimize shader switches during rendering. This sort will only\n //execute once and changing materials later will break the sorted order again.\n if (sortByShaderPossible)\n this.sortByShader();\n};\n\n/**\n * Iterates over fragments. Like forEach(), but takes a different callback.\n * @param {function} callback - function(fragId, idx) called for each fragment geometry.\n * - fragId: fragment id\n * - idx: running index from 0 .. (lastItem-start)\n * @param {number} drawMode - Optional flag (see FragmentList.js), e.g., MESH_VISIBLE. If specified, we only traverse fragments for which this flag is set.\n * @param {bool} includeEmpty - Default: false, i.e. fragments are skipped if they have no mesh available via getVizmesh().\n */\nRenderBatch.prototype.forEachNoMesh = function (callback, drawMode, includeEmpty) {\n\n var indices = this.getIndices();\n var frags = this.frags;\n\n for (var i = this.start, iEnd = this.lastItem; i < iEnd; i++) {\n var fragId = indices ? indices[i] : i;\n\n // get geometry - in this case just to check if it is available\n var geometry;\n if (frags.useThreeMesh) {\n var m = frags.getVizmesh(fragId);\n if (m)\n geometry = m.geometry;\n } else\n {\n geometry = frags.getGeometry(fragId);\n }\n\n // if drawMode is given, iterate vizflags that match\n if ((includeEmpty || geometry) && (\n !drawMode || frags.isFlagSet(fragId, drawMode))) {\n\n callback(fragId, i - this.start);\n }\n }\n};\n\n/**\n * Checks if given ray hits a bounding box of any of the fragments.\n * @param {THREE.RayCaster} raycaster\n * @param {Object[]} intersects - An object array that contains intersection result objects.\n * Each result r stores properties like r.point, r.fragId, r.dbId. (see VBIntersector.js for details)\n * @param {number[]} [dbIdFilter] - Array of dbIds. If specieed, only fragments with dbIds inside the filter are checked.\n */\nRenderBatch.prototype.raycast = function () {\n\n return function (raycaster, intersects, dbIdFilter) {\n\n //Assumes bounding box is up to date.\n if (raycaster.ray.isIntersectionBox(this.getBoundingBox()) === false)\n return;\n\n var self = this;\n var tmpBox = _tmpBox;\n\n // traverse all visible meshes\n this.forEach(function (m, fragId) {\n\n // Don't intersect hidden objects\n if (self.frags.isFlagSet(fragId, MeshFlags.MESH_HIDE))\n return;\n\n //Check the dbIds filter if given\n if (dbIdFilter && dbIdFilter.length) {\n //Theoretically this can return a list of IDs (for 2D meshes)\n //but this code will not be used for 2D geometry intersection.\n var dbId = 0 | self.frags.getDbIds(fragId);\n\n //dbIDs will almost always have just one integer in it, so\n //indexOf should be fast enough.\n if (dbIdFilter.indexOf(dbId) === -1)\n return;\n }\n\n // raycast worldBox first.\n self.frags.getWorldBounds(fragId, tmpBox);\n\n // Expand bounding box a bit, to take into account axis aligned lines\n tmpBox.expandByScalar(0.5);\n\n if (raycaster.ray.isIntersectionBox(tmpBox)) {\n // worldbox was hit. do raycast with actucal geometry.\n VBIntersector.rayCast(m, raycaster, intersects);\n }\n }, MeshFlags.MESH_VISIBLE);\n };\n}();\n\n/**\n * Computes/updates the bounding boxes of this batch.\n */\nRenderBatch.prototype.calculateBounds = function () {\n\n // pointers to make some objects available for the callback below.\n var vizflags;\n var frags;\n var tmpBox;\n var self;\n\n // adds box of a fragment to bounds or bounds, depennding on its vizflags.\n function cb(fragId) {\n\n frags.getWorldBounds(fragId, tmpBox);\n\n var f = vizflags[fragId];\n\n self.addToBox(tmpBox, !(f & 1 /*MESH_VISIBLE*/));\n }\n\n return function () {\n // init boxes for visible and ghosted meshes\n this.bboxes[0] = this.bboxes[1] = this.bboxes[2] = Infinity;\n this.bboxes[3] = this.bboxes[4] = this.bboxes[5] = -Infinity;\n this.bboxes[6] = this.bboxes[7] = this.bboxes[8] = Infinity;\n this.bboxes[9] = this.bboxes[10] = this.bboxes[11] = -Infinity;\n\n // make members and tempBox accessible for cb\n vizflags = this.frags.vizflags;\n frags = this.frags;\n tmpBox = _tmpBox;\n self = this;\n\n // Why including null geometry?: If we would exclude fragments whose geometry is not loaded yet, we would need to refresh all bboxes permanently during loading.\n // Since we know bboxes earlier than geometry (for SFF at FragmentList construction time and for Otg as soon as BVH data is available), including empty meshes\n // ensures that the bbox result is not affected by geometry loading state for 3D.\n this.forEachNoMesh(cb, 0, true);\n };\n}();\n\n/**\n * Sets the MESH_RENDERFLAG for a single fragment, depeneding on the drawMode and the other flags of the fragment.\n * @param {number} drawMode - One of the modes defined in RenderFlags.js, e.g. RENDER_NORMAL\n * @param {number} vizflags - vizflags bitmask. \n * @param {number} idx - index into vizflags, for which we want to determine the MESH_RENDERFLAG.\n * @param {bool} hideLines\n * @param {bool} hidePoints\n * @returns {bool} Final, evaluated visibility.\n */\nfunction evalVisibility(drawMode, vizflags, idx, hideLines, hidePoints) {\n\n var v;\n // Strange bug in MS Edge when the debugger is active. Down below where we\n // or in the MESH_RENDERFLAG, ~MESH_RENDERFLAG was getting used in stead.\n // Copying the value to a local variable fixed the issue.\n var rflag = MeshFlags.MESH_RENDERFLAG;\n var vfin = vizflags[idx] & ~rflag;\n switch (drawMode) {\n\n case RenderFlags.RENDER_HIDDEN:\n v = !(vfin & MeshFlags.MESH_VISIBLE); //visible (bit 0 on)\n break;\n case RenderFlags.RENDER_HIGHLIGHTED:\n v = vfin & MeshFlags.MESH_HIGHLIGHTED; //highlighted (bit 1 on)\n break;\n default:\n v = (vfin & (MeshFlags.MESH_VISIBLE | MeshFlags.MESH_HIGHLIGHTED | MeshFlags.MESH_HIDE)) == 1; //visible but not highlighted, and not a hidden line (bit 0 on, bit 1 off, bit 2 off)\n break;}\n\n\n if (hideLines) {\n var isLine = vfin & (MeshFlags.MESH_ISLINE | MeshFlags.MESH_ISWIDELINE);\n v = v && !isLine;\n }\n\n if (hidePoints) {\n var isPoint = vfin & MeshFlags.MESH_ISPOINT;\n v = v && !isPoint;\n }\n\n //Store evaluated visibility into bit 7 of the vizflags\n //to use for immediate rendering\n vizflags[idx] = vfin | (v ? rflag : 0);\n\n return v;\n}\n\n\n/**\n * Checks if fragment is outside the frustum.\n * @param {bool} checkCull - indicates if culling is enabled. If false, return value is always false.\n * @param {FrustumIntersector} frustum\n * @param {FragmentList} frags\n * @param {number} idx - index into frags.\n * @param {bool} doNotCut - do not apply cutplanes\n * @returns {bool} True if the given fragment is outside the frustum and culling is enabled.\n */\nfunction evalCulling(checkCull, frustum, frags, idx, doNotCut) {\n\n var culled = false;\n\n frags.getWorldBounds(idx, _tmpBox);\n if (checkCull && !frustum.intersectsBox(_tmpBox)) {\n culled = true;\n }\n\n // apply cutplane culling\n // TODO: We ignore checkCull, because checkCull is set to false if the RenderBatch is fully\n // inside the frustum - which still tells nothing about the cutplanes.\n // Ideally, we should a corresponding hierarchical check per cutplane too.\n if (!culled && !doNotCut && frustum.boxOutsideCutPlanes(_tmpBox)) {\n culled = true;\n }\n\n //This code path disabled because it was found to slow things down overall.\n /*\n else {\n // Check whether the projected area is smaller than a threshold,\n // if yes, do not render it.\n var area = frustum.projectedBoxArea(_tmpBox, !checkCull);\n area *= frustum.areaConv;\n if (area < frustum.areaCullThreshold) {\n culled = true;\n }\n }\n */\n\n return culled;\n}\n\n\n/**\n * Updates visibility for all fragments of this RenderBatch. \n * This means:\n * 1. It returns true if all meshes are hidden (false otherwise)\n *\n * 2. If the whole batch box is outside the frustum, nothing else is done.\n * (using this.getBoundingBox() or this.getBoundingBoxHidden(), depending on drawMode)\n *\n * 3. For all each checked fragment with fragId fid and mesh m, the final visibility is stored...\n * a) In the m.visible flag.\n * b) In the MESH_RENDERFLAG of the vizflags[fid]\n * This is only done for fragments with geometry. \n * @param {number} drawMode - One of the modes defined in RenderFlags.js, e.g. RENDER_NORMAL\n * @param {FrustumIntersector} frustum\n * @returns {bool} True if all meshes are hidden (false otherwise).\n */\nRenderBatch.prototype.applyVisibility = function () {\n\n var frags, vizflags, frustum, drawMode, checkCull, allHidden, doNotCut;\n\n // Callback to apply visibility for a single fragment\n //\n // Input: Geometry and index of a fragment, i.e.\n // m: instanceof THREE.Mesh (see FragmentList.getVizmesh). May be null.\n // idx: index of the fragment in the fragment list. \n //\n // What is does:\n // 1. bool m.visible is updated based on flags and frustum check (if m!=null)\n // 2. The MESH_RENDERFLAG flag is updated for this fragment, i.e., is true for meshes with m.visible==true\n // 3. If there is no geometry and there is a custom callback (checkCull) \n // 4. Set allHidden to false if any mesh passes as visible.\n function applyVisCB(m, idx) {\n\n // if there's no mesh or no geometry, just call the custom callback.\n // [HB:] I think it would be clearer to remove the frags.useThreeMesh condition here.\n // It's not really intuitive that for (m==0) the callback is only called for frags.useThreeMesh.\n // Probably the reason is just that this code section has just been implemented for the useThreeMesh\n // case and the other one was irrelevant.\n if (!m && frags.useThreeMesh || !m.geometry) {\n return;\n }\n\n // apply frustum check for this fragment\n var culled = evalCulling(checkCull, frustum, frags, idx, doNotCut);\n\n // if outside, set m.visbile and the MESH_RENDERFLAG of the fragment to false\n if (culled) {\n if (m) {\n m.visible = false;\n } else {\n logger.warn(\"Unexpected null mesh\");\n }\n // unset MESH_RENDERFLAG\n vizflags[idx] = vizflags[idx] & ~MeshFlags.MESH_RENDERFLAG;\n\n return;\n }\n\n // frustum check passed. But it might still be invisible due to vizflags and/or drawMode. \n // Note that evalVisibility also updates the MESH_RENDERFLAG already.\n var v = evalVisibility(drawMode, vizflags, idx, frags.linesHidden, frags.pointsHidden);\n\n if (m)\n m.visible = !!v;\n\n // Set to false if any mesh passes as visible\n allHidden = allHidden && !v;\n }\n\n // Similar to applyVisCB above, but without geometry param, so that we don't set any m.visible property.\n function applyVisCBNoMesh(idx) {\n\n // if no geometry is assigned, just call custom cb (if specified) and stop here.\n if (!frags.getGeometryId(idx)) {\n return;\n }\n\n // apply frustum check for this fragment\n var culled = evalCulling(checkCull, frustum, frags, idx, doNotCut);\n\n // if culled, set visflags MESH_RENDERFLAG to false \n if (culled) {\n vizflags[idx] = vizflags[idx] & ~MeshFlags.MESH_RENDERFLAG;\n return;\n }\n\n // frustum check passed. But it might still be invisible due to vizflags and/or drawMode. \n // Note that evalVisibility also updates the MESH_RENDERFLAG already.\n var v = evalVisibility(drawMode, vizflags, idx, frags.linesHidden, frags.pointsHidden);\n\n // Set to false if any mesh passes as visible\n allHidden = allHidden && !v;\n }\n\n return function (drawModeIn, frustumIn) {\n\n //Used when parts of the same scene\n //have to draw in separate passes (e.g. during isolate).\n //Consider maintaining two render queues instead if the\n //use cases get too complex, because this approach\n //is not very scalable as currently done (it traverses\n //the entire scene twice, plus the flag flipping for each item).\n\n allHidden = true;\n frustum = frustumIn;\n drawMode = drawModeIn;\n\n var bbox = drawMode === RenderFlags.RENDER_HIDDEN ? this.getBoundingBoxHidden() : this.getBoundingBox();\n\n //Check if the entire render batch is contained inside\n //the frustum. This will save per-object checks.\n var containment = frustum.intersectsBox(bbox);\n if (containment === FrustumIntersector.OUTSIDE)\n return allHidden; //nothing to draw\n\n doNotCut = this.frags.doNotCut;\n if (!doNotCut && frustumIn.boxOutsideCutPlanes(bbox)) {\n return allHidden;\n }\n\n vizflags = this.frags.vizflags;\n frags = this.frags;\n checkCull = containment !== FrustumIntersector.CONTAINS;\n\n // The main difference between applyVisCB and applyVisCBNoMesh is that applyVisCB also updates mesh.visible for each mesh.\n // This does only make sense when using THREE.Mesh. Otherwise, the mesh containers are volatile anyway (see FragmentList.getVizmesh)\n if (!frags.useThreeMesh) {\n // Use callback that does not set mesh.visible\n this.forEachNoMesh(applyVisCBNoMesh, 0, false);\n } else {\n // Use callback that also sets mesh.visible.\n // Skip fragments without geometry unless a custom callback is defined (fragIdCB)\n this.forEach(applyVisCB, null);\n }\n\n frags = null;\n\n return allHidden;\n };\n}();","\nexport var RenderFlags = {\n RENDER_NORMAL: 0,\n RENDER_HIGHLIGHTED: 1,\n RENDER_HIDDEN: 2,\n RENDER_SHADOWMAP: 3,\n RENDER_FINISHED: 4 };","import * as globals from '../globals';\nimport { GeometryList } from './GeometryList';\nimport { FragmentList } from './FragmentList';\nimport { RenderBatch } from './RenderBatch';\nimport { consolidateFragmentList } from './consolidation/FragmentListConsolidation';\nimport { ConsolidationIterator } from './consolidation/ConsolidationIterator';\nimport { ModelIteratorLinear } from './ModelIteratorLinear';\nimport { ModelIteratorBVH } from './ModelIteratorBVH';\nimport { VBIntersector } from './VBIntersector';\nimport * as THREE from \"three\";\nimport { MeshFlags } from \"./MeshFlags\";\nimport { RenderFlags } from \"./RenderFlags\";\nimport { logger } from \"../../logger/Logger\";\nimport { LmvMatrix4 } from \"./LmvMatrix4\";\nimport { DynamicGlobalOffset } from \"../../application/DynamicGlobalOffset\";\n\n// TODO: move the logic that decides whether or not to stream somewhere closer to SVF;\n// Ideally, RenderModel and GeometryList should be agnostic to the file format.\n/*\n * Helper function to determine whether we should enable streamingDraw or upload the whole model to GPU.\n *\n * This function uses values from an SVF package to estimate the expected GPU load. If it is\n * small enough, it returns false. This means that the whole model is uploaded to GPU.\n *\n * If the model size is larger or unknown, we use a heuristic to determine which models are uploaded\n * to GPU and which are rendered from CPU-memory using the (slower) streamingDraw.\n * @param {number} packFileTotalSize\n * @param {number} numPrimitives\n * @param {number} numObjects\n */\nfunction needsStreamingDraw(packFileTotalSize, numPrimitives, numObjects) {\n if (packFileTotalSize) {\n //In pack files, primitive indices use 4 byte integers,\n //while we use 2 byte integers for rendering, so make this\n //correction when estimating GPU usage for geometry\n var estimatedGPUMem = packFileTotalSize - numPrimitives * 3 * 2;\n\n //If the model is certain to be below a certain size,\n //we will skip the heuristics that upload some meshes to\n //GPU and keep other in system mem, and just push it all to the GPU.\n if (estimatedGPUMem <= globals.GPU_MEMORY_LIMIT && numObjects < globals.GPU_OBJECT_LIMIT) {\n // We don't need streaming draw - model is small enough\n return false;\n }\n }\n\n return true;\n}\n\nvar isPointOutsidePlanecuts = function () {\n var v = new THREE.Vector4();\n return function (point, cutplanes) {\n v.copy(point); // copy already sets w=1 when copying from a Vector3\n for (var i = 0; i < cutplanes.length; i++) {\n if (cutplanes[i].dot(v) > 1e-6) {\n return true;\n }\n }\n\n return false;\n };\n}();\n\n// Counter to assign individual numbers to RenderModel in order of their creation\nvar nextModelId = 1;\n\n/** @class Extends application Model class by functionality for WebGL rendering.\n * Currently produced by loaders (F2DLoader, SvfLoader)\n *\n * @constructor\n */\nexport function RenderModel() {var _this = this;\n\n // Cached bboxes.\n var _visibleBounds = new THREE.Box3(); // excluding ghosted once\n var _visibleBoundsWithHidden = new THREE.Box3(); // full bbox\n var _tmpBox = new THREE.Box3(); // temp for internal use\n\n this.visibleBoundsDirty = false; // triggers recomputation of _visibleBounds and _visibleBoundsWithHidden, e.g., if fragment visibility changes.\n this.enforceBvh = false; // currently ignored, see this.resetIterator()\n\n var _numHighlighted = 0; // number of currently highlighted fragments. \n\n this.id = nextModelId++; // use next free Model id\n\n var _geoms = null; // {GeometryList} \n var _frags = null; // {FragmentList}\n\n // Iterators used for scene traversal. \n var _linearIterator = null; // {ModelIteratorLinear}, used by default and created in this.initialize()\n var _bvhIterator = null; // {ModelIteratorBVH}, used if setBVH() has been called and no new fragments have been added since then.\n var _iterator = null; // currently used iterator. points to one of the iterators above\n\n // Only used for consolidated models.\n var _consolidationIterator = null; // {ConsolidationIterator}\n var _consolidationMap = null; // cached intermediate results of consolidation pre-processing. Enables to quickly rebuild\n // _consolidationIterator when we had to temporarily remove it to free memory.\n\n // Maintained per scene traversal, initialized in ResetIterator()\n var _renderCounter = 0; // number of batches rendered since last resetIterator() call. Used to indicate rendering progress for progressive rendering.\n var _frustum = null; // {FrustumIntersector}. Assigned in this.ResetIterator(). Passed to RenderBatches for culling and depth-sorting. \n var _drawMode = RenderFlags.RENDER_NORMAL; // drawMode used in this traversal. See Viewer3DImpl.js\n var _bvhOn = false; // true when using _bvhiterator in the current traversal. [HB:] Shouldn't this better be local variable in ResetIterator()?\n\n // Cache for transform matrices\n var _identityMatrix = null; // {LmvMatrix4}\n var _modelAndPlacementTransform = null; // {LmvMatrix4}\n var _invModelAndPlacementTransform = null; // {LmvMatrix4}\n\n // Dynamic Placement: These settings override the corresponding cameras and matrices in this.getData if placement or globalOffset are modified after loading.\n // Only used if dynamic placement or offset changes are actually done. Note that placementTransform and globalOffset in this.getData always\n // store the values applied during loading and are not affected by setGlobalOffset() or setPlacementTransform() calls.\n this._placementTransform; // {LmvMatrix4}\n this._globalOffset; // {Vector3}\n\n // Note: GeometryList or FragmentList are maintained by the RenderModel and should not be modified from outside.\n // E.g., setting visibility or highlighting flags on FragmentList directly would break some state tracking. (e.g. see this.setVibility or this.setHighlighted)\n // The only current exception is done by loaders that add geometry to _geoms directly.\n this.getGeometryList = function () {return _geoms;};\n this.getFragmentList = function () {return _frags;};\n this.getModelId = function () {return this.id;};\n this.RenderBatch = RenderBatch; // This will be used by the model iterators\n // to create batches. Limited memory will change it.\n\n var _doNotCut = false; // When enabled, cutplanes should not affect the visibility of the model\n\n this.initialize = function () {\n // alloc GeometryList. Initially empty, but exposed via GetGeometryList().\n // The loaders use this to add LmvGeometryBuffers directly to the GeometryList later.\n // TODO: Make RenderModel agnostic to the SVF file format.\n var svf = this.getData();\n\n var numObjects = svf.numGeoms || 0;\n var disableStreaming = !needsStreamingDraw(svf.packFileTotalSize, svf.primitiveCount, numObjects);\n _geoms = new GeometryList(numObjects, this.is2d(), disableStreaming, this.isOTG());\n\n _frags = new FragmentList(this);\n\n var initialBbox = this.getBoundingBox();\n if (initialBbox) {\n _visibleBounds.copy(initialBbox);\n _visibleBoundsWithHidden.copy(initialBbox);\n }\n\n _iterator = _linearIterator = new ModelIteratorLinear(this);\n };\n\n this.getIterator = function () {\n return _iterator;\n };\n\n /**\n * Initialize from custom iterator. In this case, _geoms and _frags are not used and the \n * iterator implementation is responsible for producing and maintaining the geometry.\n *\n * @param {ModelIterator} iterator - iterator.nextBatch may return RenderBatch or THREE.Scene instances.\n *\n * Note: When using a custom iterator, per-fragment visiblity is not supported.\n */\n this.initFromCustomIterator = function (iterator) {\n _iterator = iterator;\n this.visibleBoundsDirty = true; // make sure that bbox is obtained from iterator\n };\n\n /** \n * Deletes all GPU resources.\n *\n * @param {FireflyWebGLRenderer} glRenderer\n */\n this.dtor = function (glrenderer) {\n if (_frags) {\n _frags.dispose(glrenderer);\n }\n // Custom iterators may have own GPU resources (see ModelIteratorTexQuad)\n if (_iterator && _iterator.dtor) {\n _iterator.dtor();\n _linearIterator = null;\n }\n // If this model was consolidated, dispose GPU memory of consolidation as well\n if (_consolidationIterator) {\n _consolidationIterator.dispose();\n }\n };\n\n\n /** \n * Activating a fragment means:\n * - Store geometry in the FragmentList\n * - Update summed RenderModel boxes\n * - Add fragment to iterator, so that it is considered in next traversal\n * See FragmentList.setMesh(..) for param details.\n *\n * Note:\n * - Can only be used with LinearIterator\n */\n this.activateFragment = function (fragId, meshInfo, overrideTransform) {\n if (!_frags) {\n return;\n }\n\n _frags.setMesh(fragId, meshInfo, overrideTransform);\n\n //The linear iterator can be updated to add meshes incrementally.\n //The BVH iterator is not mutable, yet.\n _iterator.addFragment(fragId);\n\n //update the world bbox\n {\n _frags.getWorldBounds(fragId, _tmpBox);\n _visibleBounds.union(_tmpBox);\n _visibleBoundsWithHidden.union(_tmpBox);\n }\n\n };\n\n // Used by the Fusion collaboration client\n this.setFragment = function (fragId, mesh, retainMesh) {\n\n if (fragId === undefined)\n fragId = this.getFragmentList().getNextAvailableFragmentId();\n\n _frags.setMesh(fragId, mesh, true, retainMesh);\n\n //The linear iterator can be updated to add meshes incrementally.\n //The BVH iterator is not mutable, yet.\n if (_linearIterator)\n _linearIterator.addFragment(fragId);\n if (_bvhIterator && !_frags.fragmentsHaveBeenAdded())\n _bvhIterator.addFragment(fragId);\n\n //update the world bbox\n {\n _frags.getWorldBounds(fragId, _tmpBox);\n _visibleBounds.union(_tmpBox);\n _visibleBoundsWithHidden.union(_tmpBox);\n }\n\n return fragId;\n };\n\n\n /** Replaces the default LinearIterator by a BVH iterator. */\n this.setBVH = function (nodes, primitives, options) {var _frags2;\n\n // Note that ResetIterator() might still set _iterator back to \n // the linear one if the BVH one cannot be used.\n _iterator = _bvhIterator = new ModelIteratorBVH();\n\n _iterator.initialize(this, nodes, primitives, options);\n\n // By default, the BVH contains boxes \"as loaded\", i.e. not consdering any model matrix.\n // If a model transform is applied, we have to make sure that the bvh boxes are recomputed.\n if ((_frags2 = _frags) === null || _frags2 === void 0 ? void 0 : _frags2.matrix) {\n this.invalidateBBoxes();\n }\n };\n\n /** \n * Starts the scene draw traversal, so that nextBatch() will return the first batch to render.\n * @param: {UnifiedCamera} camera - camera.position was needed for the heuristic to choose between linear iterator and BVH.\n * [HB:] The code is currently outcommented, so the param is currently unused.\n * @param: {FrustumIntersector} frustum - used by RenderBatches for frustum culling and z-sorting.\n * @param: {number} drawMode - E.g., RENDER_NORMAL. See RenderFlags.js\n */\n this.resetIterator = function (camera, frustum, drawMode) {\n\n //Decide whether to use the BVH for traversal\n //If we are far out from the scene, use pure big-to-small\n //importance order instead of front to back.\n _bvhOn = false;\n if (_bvhIterator && !_frags.fragmentsHaveBeenAdded()) {\n //TODO: BVH always on when available, because the linear iteration\n //does not respect transparent objects drawing last -- it just\n //draws in the order the fragments come in the SVF package\n /*\n if(this.enforceBvh || !_linearIterator) {\n _bvhOn = true;\n } else {\n var diag = _visibleBoundsWithHidden.size().length();\n var center = _visibleBoundsWithHidden.center();\n var dist = camera.position.distanceTo(center);\n if (dist < diag * 0.5)\n _bvhOn = true;\n }\n */\n _bvhOn = true;\n }\n\n // Note _linearIterator may also be null if a custom iterator is used.\n // in this case, we must leave _iterator unchanged.\n if (_bvhOn) {\n _iterator = _bvhIterator;\n } else if (_linearIterator) {\n _iterator = _linearIterator;\n }\n\n _renderCounter = 0;\n _drawMode = drawMode;\n _frustum = frustum;\n _iterator.reset(frustum, camera);\n\n // notify consolidation iterator that a new traversal has started\n if (_consolidationIterator) {\n _consolidationIterator.reset();\n }\n return _iterator;\n };\n\n\n /** Returns the next RenderBatch for scene rendering travseral. Used in RenderScene.renderSome().\n * Use this.resetIterator() to start traversal first.\n *\n * @returns {RenderBatch|null} Next batch to render or null if traversal is finished.\n */\n this.nextBatch = function () {\n\n // If the next batch of the iterator is fully invisble, we inc it until we \n // find a relevant batch to render or reach the end.\n while (1) {\n // get next batch from iterator\n var scene = _iterator.nextBatch();\n\n // update render progress counter\n _renderCounter++;\n\n // stop if iterator reached the end \n if (!scene)\n return null;\n\n // replace RenderBatch (= individual fragments) by consolidated scene, if available\n if (_consolidationIterator && scene instanceof RenderBatch) {\n scene = _consolidationIterator.consolidateNextBatch(scene, _frustum, _drawMode);\n }\n\n // Tag all produced scenes with modelId. This is used for cross-fading between models by\n // rendering them to separate targets.\n scene.modelId = this.id;\n\n if (scene instanceof THREE.Scene) {\n // The code for fragment visibility and sorting is only defined if scene is a RenderBatch.\n // For the case of THREE.Scene, we are done here, because\n // - Sorting in THREE.Scene is done by FireFlyRenderer.\n // - Per-fragment visiblity is not supported in this case\n return scene;\n }\n\n if (!this.applyVisibility(scene, _drawMode, _frustum))\n return scene;\n }\n };\n\n /**\n * Set the MESH_RENDERFLAG based on the current render phase\n * while frustum culling the fragments in the scene.\n * @param {RenderBatch} scene The scene to calculate the visibility for\n * @param {number} drawMode - E.g., RENDER_NORMAL. See RenderFlags.js\n * @param {FrustumIntersector} frustum - used by RenderBatches for frustum culling and z-sorting.\n * @return {boolean} True if all fragments in the scene are not visibile. False otherwise.\n */\n this.applyVisibility = function (scene, drawMode, frustum) {\n //TODO: move this into the iterator?\n var allHidden = scene.applyVisibility(\n drawMode,\n frustum);\n\n // For 3D scenes, sort fragments of this batch. \n // Note that fragments of F2D scenes must be drawn in original order.\n //TODO: Move this to the iterator?\n if (!allHidden && !this.is2d()) {\n //Generally opaque batches are sorted once by material, while\n //transparent batches are sorted back to front each frame\n if (scene.sortObjects && !this.getFragmentList().useThreeMesh)\n scene.sortByDepth(frustum);else\n if (!scene.sortDone)\n scene.sortByMaterial();\n }\n\n return allHidden;\n };\n\n /**\n * Remove shadow geometry (if exists) from model bounds.\n * \n * @param {THREE.Box3} bounds \n */\n this.trimPageShadowGeometry = function (bounds) {\n if (this.hasPageShadow()) {\n // This constant shadow size comes from LMV -> F2D.prototype.initSheet\n var shadowSize = 0.0075;\n bounds = bounds.clone();\n\n // If we have pageShadow, we must have page_dimensions & page_width.\n var pageWidth = this.getMetadata('page_dimensions', 'page_width');\n bounds.max.x -= pageWidth * shadowSize;\n bounds.min.y += pageWidth * shadowSize;\n }\n\n return bounds;\n };\n\n /**\n * @param: {bool} includeGhosted\n * @param: {bool} excludeShadow - Remove shadow geometry (if exists) from model bounds.\n * @returns {THREE.Box3} \n *\n * NOTE: The returned box is just a pointer to a member, not a copy!\n */\n this.getVisibleBounds = function (includeGhosted, excludeShadow) {\n\n if (this.visibleBoundsDirty) {\n\n _visibleBounds.makeEmpty();\n _visibleBoundsWithHidden.makeEmpty();\n\n _iterator.getVisibleBounds(_visibleBounds, _visibleBoundsWithHidden, includeGhosted);\n\n\n this.visibleBoundsDirty = false;\n\n }\n\n var bounds = includeGhosted ? _visibleBoundsWithHidden : _visibleBounds;\n\n if (excludeShadow) {\n bounds = this.trimPageShadowGeometry(bounds);\n }\n\n return bounds;\n };\n\n this.rayIntersect2D = function () {\n var plane = new THREE.Plane();\n var pointOnSheet = new THREE.Vector3();\n\n return function (raycaster, dbIds, intersections, getDbIdAtPointFor2D) {\n // A sheet is assumed to be, when loaded, pointing z-up on 0,0;\n var bbox = _this.getBoundingBox(true); // Get original bounding box\n var center = bbox.center();\n plane.normal.set(0, 0, 1);\n plane.constant = -center.z;\n\n var tr = _this.getModelToViewerTransform();\n if (tr) {\n plane.applyMatrix4(tr);\n }\n\n var point = raycaster.ray.intersectPlane(plane);\n if (point) {\n pointOnSheet.copy(point);\n var invTr = _this.getInverseModelToViewerTransform();\n if (invTr) {\n pointOnSheet.applyMatrix4(invTr);\n pointOnSheet.z = center.z; // Avoid numerical problems\n }\n if (bbox.containsPoint(pointOnSheet)) {var _frags3, _frags3$getMaterial;\n var cutplanes = (_frags3 = _frags) === null || _frags3 === void 0 ? void 0 : (_frags3$getMaterial = _frags3.getMaterial(0)) === null || _frags3$getMaterial === void 0 ? void 0 : _frags3$getMaterial.cutplanes; // Get cutplanes from first material\n if (cutplanes && isPointOutsidePlanecuts(point, cutplanes)) {\n return;\n }\n var distance = raycaster.ray.origin.distanceTo(point);\n if (distance < raycaster.near || distance > raycaster.far) {\n return;\n }\n\n var dbId, fragId;\n if (getDbIdAtPointFor2D) {// This is an optional callback\n var res = getDbIdAtPointFor2D(point);\n dbId = res[0];\n if (dbIds && dbIds.length > 0 && !dbIds.includes(dbId)) {// Filter according to passed array\n return;\n }\n\n var modelId = res[1]; // modelId is 0 if the idtarget[1] is not used\n if (modelId !== 0 && modelId !== _this.id) {\n // In the case where another model is in front of this one, the dbId we get here\n // will be for that model instead, so just ignore this result\n return;\n } else {var _frags4;\n fragId = (_frags4 = _frags) === null || _frags4 === void 0 ? void 0 : _frags4.fragments.dbId2fragId[dbId];\n }\n }\n\n var intersection = {\n intersectPoint: point, // Backwards compatibility\n point: point,\n distance: distance,\n dbId: dbId && _this.remapDbId(dbId),\n fragId: fragId,\n model: _this };\n\n\n if (intersections) {\n intersections.push(intersection);\n }\n\n return intersection;\n }\n }\n };\n }();\n\n /**\n * Performs a raytest and returns an object providing information about the closest hit. \n * \n * NOTE: We currently ignore hitpoints of fragments that are visible (MESH_VISIBLE==true) and not highlighted (MESH_HIGHLIGHTED==false). \n *\n * @param {THREE.RayCaster} raycaster\n * @param {bool} ignoreTransparent\n * @param {number[]} [dbIds] - Array of dbIds. If specified, only fragments with dbIds inside the filter are checked.\n * If the model data has no instanceTree, this is just a whitelist of explicit fragment ids.\n * Note that a hitpoint will also be returned if it's actually occluded by a fragment outside the filter.\n * @param {Array} [intersections] - Optional return array with all found intersections.\n * @param {function} [getDbIdAtPointFor2D] - Optional callback. For 2D models, to return the dbId and modelId in an array.\n *\n * @returns {Object|null} Intersection result object providing information about closest hit point. Properties:\n * - {number} fragId\n * - {Vector3} point\n * - {number} dbId\n * - {model} model - pointer to this RenderModel\n * (created/filled in VBIntersector.js, see for details)\n */\n // Add \"meshes\" parameter, after we get meshes of the object using id buffer,\n // then we just need to ray intersect this object instead of all objects of the model.\n this.rayIntersect = function (raycaster, ignoreTransparent, dbIds, intersections, getDbIdAtPointFor2D) {\n\n if (this.is2d()) {\n return this.rayIntersect2D(raycaster, dbIds, intersections, getDbIdAtPointFor2D);\n }\n // make sure that the cached overall bboxes are up-to-date.\n // [HB:] Why are they updated here, but not used in this method?\n if (this.visibleBoundsDirty)\n this.getVisibleBounds();\n\n // alloc array to collect intersection results\n var intersects = [];\n var i;\n\n // Restrict search to certain dbIds if specified...\n if (dbIds && dbIds.length > 0) {\n\n //Collect the mesh fragments for the given database ID node filter.\n var instanceTree = this.getInstanceTree();\n var fragIds = [];\n if (instanceTree) {\n for (i = 0; i < dbIds.length; i++) {\n instanceTree.enumNodeFragments(dbIds[i], function (fragId) {\n fragIds.push(fragId);\n }, true);\n }\n } else {\n //No instance tree -- treat dbIds as fragIds\n fragIds = dbIds;\n }\n\n //If there are multiple fragments it pays to still use\n //the bounding volume hierarchy to do the intersection,\n //because it can cull away entire fragments by bounding box,\n //instead of checking every single fragment triangle by triangle\n if (fragIds.length > 2) {//2 is just an arbitrary value, assuming checking 2 fragments is still cheap than full tree traversal\n _iterator.rayCast(raycaster, intersects, dbIds);\n } else {\n // The filter restricted the search to a very small number of fragments.\n // => Perform raytest on these fragments directly instead.\n for (i = 0; i < fragIds.length; i++) {\n var mesh = _frags.getVizmesh(fragIds[i]);\n if (!mesh)\n continue;\n var res = VBIntersector.rayCast(mesh, raycaster, intersects);\n if (res) {\n intersects.push(res);\n }\n }\n }\n\n } else {\n // no filter => perform raytest on all fragments\n _iterator.rayCast(raycaster, intersects);\n }\n\n // stop here if no hit was found\n if (!intersects.length)\n return null;\n\n // sort results by distance. \n intersects.sort(function (a, b) {return a.distance - b.distance;});\n\n //pick the nearest object that is visible as the selected.\n var allIntersections = !!intersections;\n intersections = intersections || [];\n\n for (i = 0; i < intersects.length; i++) {\n var fragId = intersects[i].fragId;\n var isVisible = this.isFragVisible(fragId); //visible set,\n\n // [HB:] Since we skip all meshes that are not flagged as visible, shouldn't we \n // better exclude them from the raycast in the first place?\n if (isVisible) {\n\n // skip transparent hits if specified\n var material = _frags.getMaterial(fragId);\n if (ignoreTransparent && material.transparent)\n continue;\n\n var intersect = intersects[i];\n\n // check against cutplanes\n var isCut = false;\n if (material && material.cutplanes) {\n isCut = isPointOutsidePlanecuts(intersect.point, material.cutplanes);\n }\n\n if (!isCut) {\n intersections.push(intersect);\n }\n\n intersect.model = this;\n\n if (!allIntersections && intersections.length > 0) {\n // result is the closest hit that passed all tests => done.\n break;\n }\n }\n }\n\n var result = intersections[0] || null;\n\n if (result) {\n // We might use multiple RenderModels => add this pointer as well.\n result.model = this;\n }\n\n return result;\n };\n\n\n /** Set highlighting flag for a fragment. \n * @param {number} fragId\n * @param {bool} value\n * @returns {bool} indicates if flag state changed\n */\n this.setHighlighted = function (fragId, value) {\n if (!_frags) {\n return false;\n }\n\n var changed = _frags.setFlagFragment(fragId, MeshFlags.MESH_HIGHLIGHTED, value);\n\n if (changed) {\n if (value)\n _numHighlighted++;else\n\n _numHighlighted--;\n }\n\n return changed;\n };\n\n /** Sets MESH_VISIBLE flag for a fragment (true=visible, false=ghosted) */\n // This function should probably not be called outside VisibityManager\n // in order to maintain node visibility state.\n this.setVisibility = function (fragId, value) {\n if (_frags) {\n _frags.setVisibility(fragId, value);\n this.visibleBoundsDirty = true;\n }\n };\n\n /** Sets MESH_VISIBLE flag for all fragments (true=visible, false=ghosted) */\n this.setAllVisibility = function (value) {\n if (_frags) {\n _frags.setAllVisibility(value);\n this.visibleBoundsDirty = true;\n }\n };\n\n /** Sets the MESH_HIDE flag for all fragments that a flagged as line geometry. \n * Note that the MESH_HIDE flag is independent of the MESH_VISIBLE flag (which switches between ghosted and fully visible) \n *\n * @param {bool} hide - value to which the MESH_HIDE flag will be set. Note that omitting this param would SHOW the lines, so\n * that you should always provide it to avoid confusion.\n */\n this.hideLines = function (hide) {\n if (_frags) {\n _frags.hideLines(hide);\n }\n };\n\n /** Sets the MESH_HIDE flag for all fragments that a flagged as point geometry. \n * Note that the MESH_HIDE flag is independent of the MESH_VISIBLE flag (which switches between ghosted and fully visible) \n *\n * @param {bool} hide - value to which the MESH_HIDE flag will be set. Note that omitting this param would SHOW the points, so\n * that you should always provide it to avoid confusion.\n */\n this.hidePoints = function (hide) {\n if (_frags) {\n _frags.hidePoints(hide);\n }\n };\n\n /** Returns if one or more fragments are highlighed. \n * returns {bool}\n *\n * Note: This method will only work correctly as long as all highlighting changes are done via this.setHighlighted, not on FragmentList directly.\n */\n this.hasHighlighted = function () {\n return !!_numHighlighted;\n };\n\n /** Returns true if a fragment is tagged as MESH_VISIBLE and not as MESH_HIGHLIGHTED. */\n // \n // [HB:] It's seems a bit unintuitive that the MESH_HIGHLIGHTED flag is checked here, but not considered by the other visibility-related methods.\n // For instance, consider the following scenarioes:\n // - After calling setVibility(frag, true), isFragVisible(frag) will still return false if frag was highlighed.\n // - If areAllVisible() returns true, there may still be fragments for which isFragVisible(frag) returns false.\n this.isFragVisible = function (frag) {\n return _frags.isFragVisible(frag);\n };\n\n /** Returns true if MESH_VISIBLE flag is set for all fragments. */\n this.areAllVisible = function () {\n\n // When using a custom iterator, we don't have per-fragment visibility control. \n // We assume constantly true in this case.\n if (!_frags) {\n return true;\n }\n\n return _frags.areAllVisible();\n };\n\n /** Direct access to all RenderBatches. Used by ground shadows and ground reflection.\n * @returns {RenderBatch[]}\n */\n this.getGeomScenes = function () {\n if (!_iterator || !_iterator.getGeomScenes) {\n return []; // Leaflet doesn't have geomScenes\n }\n\n return _iterator.getGeomScenes();\n };\n\n /** Get progress of current rendering traversal.\n * @returns {number} in [0,1]\n */\n this.getRenderProgress = function () {\n var progress = _renderCounter / _iterator.getSceneCount();\n // the renderCounter can become > scene count.\n return progress > 1.0 ? 1.0 : progress;\n };\n\n /**\n * @params {number} timeStamp\n * @returns {bool} true if the model needs a redraw\n */\n this.update = function (timeStamp) {\n // if there is an iterator that implements update method...\n if (_iterator && _iterator.update) {\n return _iterator.update(timeStamp);\n }\n // assume constant scene otherwise\n return false;\n };\n\n\n /** Highlight an object with a theming color that is blended with the original object's material.\n * @param {number} dbId\n * @param {THREE.Vector4} themingColor (r, g, b, intensity), all in [0,1]\n * @param {boolean} [recursive] - Should apply theming color recursively to all child nodes.\n */\n this.setThemingColor = function (dbId, color, recursive) {\n if (_frags) {\n // When using 2d with Otg db, we need to remap, because the vertex-buffers still contain otg.\n dbId = this.reverseMapDbId(dbId);\n\n var it = this.getInstanceTree();\n if (recursive && it) {\n it.enumNodeChildren(dbId, function (childDbId) {\n _frags.setThemingColor(childDbId, color);\n }, true);\n } else {\n _frags.setThemingColor(dbId, color);\n }\n } else if (_iterator.isModelIteratorTexQuad) {\n // dbId is ignored in this case, as well as intensity. Apply theming to whole model\n _iterator.setThemingColor(color);\n } else {\n logger.warn(\"Theming colors are not supported by this model type.\");\n }\n };\n\n /** Revert all theming colors.\n */\n this.clearThemingColors = function () {\n if (_frags) {\n _frags.clearThemingColors();\n } else if (_iterator.isModelIteratorTexQuad) {\n _iterator.clearThemingColor();\n\n }\n };\n\n /** Access to leaflet-specific functionality. Returns null if RenderModel is no leaflet. */\n this.getLeaflet = function () {\n if (_iterator.isModelIteratorTexQuad) {\n return _iterator;\n }\n return null;\n };\n\n /**\n * This function creates an internal copy of the FragmentList that is consolidated to reduce the\n * shape count as far as possible. This takes more memory, but may strongly accelerate rendering\n * for models with many small shapes.\n *\n * NOTE: For making consolidation effective, it should ideally be activated via the load options already.\n * This will automatically adjust the depth of the spatial hierarchy. Without that, the scene traversal\n * may still be slow and the performance gain much smaller.\n *\n * @param {MaterialManager} materials\n * @param {number} [byteLimit = 100 << 20] - Merging geometries is the most efficient technique in terms\n * of rendering performance. But, it can strongly increase\n * the memory consumption, particularly because merged\n * geometry cannot be shared, i.e. multiple instances of\n * a single geometry must be replicated per instance for merging.\n * Therefore, the memory spent for merging is restricted.\n * A higher value may make rendering faster, but increases (also GPU) memory\n * workload.\n * @param {boolean} [multithreaded] - Optional: If true, a part of the work is delegated to a worker thread.\n * This function will return faster, but the consolidation is marked as not usable\n * (see Consolidation.inProgress) until all worker results are returned.\n *\n * @param {FireFlyWebGLRenderer} glRenderer\n */\n this.consolidate = function (materials, byteLimit, glRenderer) {\n\n // consolidate fragment list\n var consolidation = consolidateFragmentList(this, materials, byteLimit, glRenderer, _consolidationMap);\n\n // make BVHIterator use the consolidation when possible\n _consolidationIterator = new ConsolidationIterator(_frags, consolidation);\n\n // cache some intermediate results. Consolidations are memory-intensive, so it can be necessary to temporarily\n // remove them to free memory. By caching intermediate results, we can rebuild them faster.\n _consolidationMap = consolidation.consolidationMap;\n };\n\n /**\n * Removes consolidation to free memory. Just some compact intermediate results are cached, so that the\n * consolidation can be rebuilt quickly.\n */\n this.unconsolidate = function () {\n if (!_consolidationIterator) {\n return;\n }\n\n _consolidationIterator.dispose();\n _consolidationIterator = null;\n };\n\n this.isConsolidated = function () {\n return !!_consolidationIterator;\n };\n\n this.getConsolidation = function () {\n return _consolidationIterator ? _consolidationIterator.getConsolidation() : null;\n };\n\n //F2D/PDF only -- mapping of F2D/PDF dbids to OTG property database v2 dbids\n this.setDbIdRemap = function (dbidOldToNew) {\n if (this.is2d()) {\n this.idRemap = dbidOldToNew;\n }\n };\n\n\n //F2D only -- maps ID stored in F2D vertex buffers to actual dbId as used\n //by v2/OTG property databases.\n this.remapDbId = function (dbId) {\n if (this.idRemap && dbId > 0 && dbId < this.idRemap.length)\n return this.idRemap[dbId];\n\n return dbId;\n };\n\n this.reverseMapDbId = function (dbId) {\n if (!this.idRemap || dbId <= 0)\n return dbId;\n\n if (!this.reverseMap) {\n this.reverseMap = {};\n for (var i = 0; i < this.idRemap.length; i++) {\n this.reverseMap[this.idRemap[i]] = i;}\n }\n\n return this.reverseMap[dbId];\n };\n\n\n /**\n * This function is only needed if...\n *\n * 1. You want to draw a fragment to an overlay scene that overdraws the original fragment, and\n * 2. Consolidation is used for this model.\n *\n * To avoid flickering artifacts, the geometry used for the overlay scene must exactly match with the\n * one used for the main scene rendering. However, when consolidation is used, this geometry may vary\n * and (slightly) differ from the original fragment geometry.\n *\n * This function updates the given render proxy to make it exactly match with the geometry used for the\n * the last main scene rendering. This involves to replace geometry, material, and matrix when necessary.\n *\n * NOTE: An updated proxy can exclusively be used for rendering. Do not use this function if you want to\n * access any vertex data directly.\n *\n * @param {THREE.Mesh} proxy - currently used proxy mesh to represent the fragment\n * @param {Number} fragId - fragment represented by this proxy */\n this.updateRenderProxy = function (proxy, fragId) {\n\n if (!_consolidationIterator) {\n // nothing to do - rendering will always use the original geometry anyway.\n return;\n }\n\n // fragment might be consolidated.\n _consolidationIterator.updateRenderProxy(proxy, fragId);\n };\n\n this.skipOpaqueShapes = function () {\n if (_iterator && _iterator.skipOpaqueShapes) {\n _iterator.skipOpaqueShapes();\n }\n };\n\n // Call this whenever you modifed shapes, e.g., by setting/changing an animation transform.\n // This makes sure that all hierarchical bboxes are updated.\n // Without this, shapes may incorrectly classified as invisble, so that they may disappear or are missed by selection.\n this.invalidateBBoxes = function () {\n this.visibleBoundsDirty = true;\n };\n\n /**\n * Change the paper visibility for a 2D sheet\n */\n this.changePaperVisibility = function (show) {\n if (this.is2d()) {var _frags5;\n (_frags5 = _frags) === null || _frags5 === void 0 ? void 0 : _frags5.setObject2DVisible(-1, show);\n }\n };\n\n this.hasPaperTransparency = function () {var _frags6;\n if (!this.is2d()) {\n return false;\n }\n\n var paperOpacity = ((_frags6 = _frags) === null || _frags6 === void 0 ? void 0 : _frags6.dbIdOpacity[-1]) || 1;\n\n return paperOpacity > 0 && paperOpacity < 1;\n };\n\n\n // Set a new model transform.\n // @param {THREE.Matrix4} [matrix] - If null, model matrix is cleared.\n this.setModelTransform = function (matrix) {\n if (_iterator.isModelIteratorTexQuad) {// Leaflet\n _iterator.setModelMatrix(matrix);\n } else {\n _frags.setModelMatrix(matrix);\n _consolidationIterator && _consolidationIterator.modelMatrixChanged();\n }\n // Recompute all bboxes\n this.invalidateBBoxes();\n this.getVisibleBounds(true);\n _modelAndPlacementTransform = null;\n _invModelAndPlacementTransform = null;\n };\n\n this.getModelTransform = function () {var _iterator2, _frags7;\n if ((_iterator2 = _iterator) === null || _iterator2 === void 0 ? void 0 : _iterator2.isModelIteratorTexQuad) {// Leaflet\n return _iterator.getModelMatrix();\n }\n\n return (_frags7 = _frags) === null || _frags7 === void 0 ? void 0 : _frags7.matrix;\n };\n\n this.getInverseModelTransform = function () {var _iterator3, _frags8;\n if ((_iterator3 = _iterator) === null || _iterator3 === void 0 ? void 0 : _iterator3.isModelIteratorTexQuad) {// Leaflet\n return _iterator.getInverseModelMatrix();\n }\n\n return (_frags8 = _frags) === null || _frags8 === void 0 ? void 0 : _frags8.getInverseModelMatrix();\n };\n\n /*\n * Returns current placementTransform. By default, this is the placementMatrix applied at load time,\n * but may be overriden if resetPlacement was called after loading.\n * Returned value must not be modified from outside.\n */\n this.getPlacementTransform = function () {\n _identityMatrix = _identityMatrix || new LmvMatrix4(true);\n return this._placementTransform || this.getData().placementTransform || _identityMatrix;\n };\n\n /*\n * Returns the globalOffset applied to the model. This may be the one applied at load time or\n * a dynamic globalOffset applied afterwards.\n * @returns {Vector3}\n */\n this.getGlobalOffset = function () {\n return this._globalOffset || this.getData().globalOffset;\n };\n\n /**\n * Change the placement matrix of the model. This overrides the placement transform applied at loadTime.\n * @param {LmvMatrix4} matrix - Note that you need 64-Bit precision for large values.\n * @param {Vector3} [globalOffset] - Optionally, the globalOffset can be reset in the same step.\n */\n this.setPlacementTransform = function (matrix) {\n\n // Create/Set override placementTransform\n this._placementTransform = (this._placementTransform || new LmvMatrix4(true)).copy(matrix);\n\n // Update dynamic model matrix based on current placementMatrix and globalOffset\n DynamicGlobalOffset.updateModelMatrix(this, matrix, this.getGlobalOffset());\n };\n\n /**\n * Change globalOffset that is applied to transform this model from global to viewer coordinates.\n */\n this.setGlobalOffset = function (newOffset) {\n this._globalOffset = this._globalOffset || new THREE.Vector3();\n this._globalOffset.copy(newOffset);\n\n // Update dynamic model matrix based on current placementMatrix and globalOffset\n var pt = this.getPlacementTransform();\n DynamicGlobalOffset.updateModelMatrix(this, pt, newOffset);\n };\n\n /**\n * Returns the model transform combined with placementWithOffset.\n * It converts the source model coordinate system to viewer coordinates\n * (the coordinates used for rendering, also including subtracted globalOffset)\n * @returns {THREE.Matrix4|null}\n */\n this.getModelToViewerTransform = function () {var _this$getData;\n if (_modelAndPlacementTransform) {// Return cached value if available\n return _modelAndPlacementTransform;\n }\n\n var modelTransform = this.getModelTransform();\n var placementWithOffset = (_this$getData = this.getData()) === null || _this$getData === void 0 ? void 0 : _this$getData.placementWithOffset;\n\n if (modelTransform || placementWithOffset) {\n _modelAndPlacementTransform = new THREE.Matrix4();\n\n if (modelTransform) {\n _modelAndPlacementTransform.multiply(modelTransform);\n }\n if (placementWithOffset) {\n _modelAndPlacementTransform.multiply(placementWithOffset);\n }\n }\n\n return _modelAndPlacementTransform;\n };\n\n /**\n * Returns the inverse of the model transform combined with placementWithOffset.\n * @returns {THREE.Matrix4|null}\n */\n this.getInverseModelToViewerTransform = function () {\n if (_invModelAndPlacementTransform) {// Return cached value if available\n return _invModelAndPlacementTransform;\n }\n\n var tr = this.getModelToViewerTransform();\n if (tr) {\n _invModelAndPlacementTransform = new THREE.Matrix4();\n _invModelAndPlacementTransform.getInverse(tr);\n\n }\n\n return _invModelAndPlacementTransform;\n };\n\n // Overrides inner state of RenderModel.\n this.setInnerAttributes = function (attributes) {\n this.id = attributes._id;\n _visibleBounds = attributes._visibleBounds;\n _visibleBoundsWithHidden = attributes._visibleBoundsWithHidden;\n _tmpBox = attributes._tmpBox;\n this.enforceBvh = attributes._enforceBvh;\n _numHighlighted = attributes._numHighlighted;\n _geoms = attributes._geoms;\n _frags = attributes._frags;\n _linearIterator = attributes._linearIterator;\n _bvhIterator = attributes._bvhIterator;\n _iterator = attributes._iterator;\n _consolidationIterator = attributes._consolidationIterator;\n _consolidationMap = attributes._consolidationMap;\n _renderCounter = attributes._renderCounter;\n _frustum = attributes._frustum;\n _drawMode = attributes._drawMode;\n _bvhOn = attributes._bvhOn;\n };\n\n // Get inner state of RenderModel.\n this.getInnerAttributes = function () {\n return {\n _id: this.id,\n _visibleBounds: _visibleBounds,\n _visibleBoundsWithHidden: _visibleBoundsWithHidden,\n _tmpBox: _tmpBox,\n _enforceBvh: this.enforceBvh,\n _numHighlighted: _numHighlighted,\n _geoms: _geoms,\n _frags: _frags,\n _linearIterator: _linearIterator,\n _bvhIterator: _bvhIterator,\n _iterator: _iterator,\n _consolidationIterator: _consolidationIterator,\n _consolidationMap: _consolidationMap,\n _renderCounter: _renderCounter,\n _frustum: _frustum,\n _drawMode: _drawMode,\n _bvhOn: _bvhOn };\n\n };\n\n /**\n * Changes whether cutplanes should affect the visibility of the model.\n * Works only for 2D models (in OTG the materials are shared).\n * @param {MaterialManager} materialsManager\n * @param {boolean} doNotCut\n */\n this.setDoNotCut = function (materialsManager, doNotCut) {\n if (_doNotCut === doNotCut) {\n return;\n }\n\n _doNotCut = doNotCut;\n if (_frags) {\n _frags.doNotCut = doNotCut;\n }\n\n var modelMaterials = materialsManager.getModelMaterials(this);\n var cb = function cb(mat) {var _mat$cutplanes;\n mat.doNotCut = doNotCut;\n var updateNeeded = ((_mat$cutplanes = mat.cutplanes) === null || _mat$cutplanes === void 0 ? void 0 : _mat$cutplanes.length) > 0 === doNotCut;\n if (updateNeeded) {\n materialsManager._applyCutPlanes(mat);\n mat.needsUpdate = true;\n }\n };\n Object.values(modelMaterials.mats).forEach(cb);\n Object.values(modelMaterials.matsNonHDR).forEach(cb);\n Object.values(modelMaterials.selectionMats).forEach(cb);\n };\n\n this.getDoNotCut = function () {\n return _doNotCut;\n };\n}","import * as globals from '../globals';\nimport { FrustumIntersector } from './FrustumIntersector';\nimport * as THREE from \"three\";\nimport { RenderFlags } from \"./RenderFlags\";\nimport { ResetFlags } from \"./ResetFlags\";\nimport { ModelExploder } from \"./ModelExploder\";\n\n/**\n * RenderScene\n * Represents the full graphical scene.\n * Used for iterating through the scene for progressive rendering,\n * hit testing, etc.\n * @constructor\n * */\nexport function RenderScene() {\n\n var _needsRender = false; // if true, scene needs a re-render due to a paging-failure in last render traversal\n\n var _done = false; // true indicates that progressive rendering has finished\n // since last reset call, i.e. all batches have been traversed.\n\n var _models = []; // {RenderModel[]} - All RenderModels to be rendered.\n var _candidateScenes = []; // {RenderBatch[]} - _candidateScenes[i] points to the next batch to be rendered from _models[i]. Same length as _models.\n var _previousScenes = []; // {RenderBatch[]} - _previousScenes[i] points to the previous batch rendered from _models[i]. Same length as _models.\n var _tmpBox = new THREE.Box3(); // Reused for return values of getVisibleBounds() \n\n var _hiddenModels = []; // {RenderModel[]} - All models that are currently loaded, but excluded from rendering/selection etc.\n\n var _frustum = new FrustumIntersector(); // updated for current camera in this.reset().\n var _raycaster = new THREE.Raycaster();\n\n //var _frameStamp = 0; // increased with each render traversal restart; set, not used. For debug?\n var _perf = performance; // shortcut to browser-provided performance object\n\n // During motion, we usually restart rendering at any frame, i.e. a frame is never resumed. When setting this\n // option, we exploit this to render transparent shapes earlier. (and skip less important opaque ones)\n this.enableNonResumableFrames = false;\n\n // Determines how much of the render budget is reserved for transparent shapes.\n // E.g., a value of 0.1 means that 10% of the render budget is spent for transparent shapes.\n this.budgetForTransparent = 0.1;\n\n // If true, we assume the current frame not to be resumed and\n // render some transparent shapes before the opaque ones are done.\n var _frameWillNotBeResumed = false;\n\n // If _frameWillNotBeResumed is true, this array collects transparent scenes and renders them\n // back-to-front at the end of a frame.\n var _transparentScenes = []; // {THREE.Scene|RenderBatch}[]\n\n // needed for back-to-front sorting of transparent objects (see renderTransparentScenes)\n var _camera = null;\n\n\n this.frustum = function () {\n return _frustum;\n };\n\n function findById(models, modelId) {\n for (var i = 0; i < models.length; i++) {\n var model = models[i];\n if (model && model.id === modelId) {\n return model;\n }\n }\n return null;\n }\n\n this.findModel = function (modelId) {return findById(_models, modelId);};\n this.findHiddenModel = function (modelId) {return findById(_hiddenModels, modelId);};\n\n this.addModel = function (renderModel) {\n _models.push(renderModel);\n _candidateScenes.length = _models.length;\n _previousScenes.length = _models.length;\n this.recomputeLinePrecision();\n };\n\n this.removeModel = function (renderModel) {\n var idx = _models.indexOf(renderModel);\n if (idx >= 0) {\n _models.splice(idx, 1);\n }\n _candidateScenes.length = _models.length;\n _previousScenes.length = _models.length;\n this.recomputeLinePrecision();\n return idx >= 0;\n };\n\n this.addHiddenModel = function (renderModel) {\n var idx = _hiddenModels.indexOf(renderModel);\n if (idx < 0) {\n _hiddenModels.push(renderModel);\n }\n return idx < 0;\n };\n\n this.removeHiddenModel = function (renderModel) {\n var idx = _hiddenModels.indexOf(renderModel);\n if (idx >= 0) {\n _hiddenModels.splice(idx, 1);\n }\n return idx >= 0;\n };\n\n this.isEmpty = function () {\n return _models.length === 0;\n };\n\n this.needsRender = function () {\n return _needsRender;\n };\n this.resetNeedsRender = function () {\n _needsRender = false;\n };\n\n this.recomputeLinePrecision = function () {\n var value = 1;\n for (var i = 0, len = _models.length; i < len; ++i) {\n var modelBox = _models[i].getData().bbox;\n\n // Note that modelBox.getBoundingSphere() may not exist if the box is an LmvBox3. \n var modelValue = THREE.Box3.prototype.getBoundingSphere.call(modelBox).radius * 0.001;\n value = Math.min(value, modelValue);\n }\n _raycaster.linePrecision = value;\n };\n\n /**\n * For each sub-scene, keep a running average of how long it took to render over the\n * last few frames.\n * @param {THREE.Scene|RenderBatch} scene\n * @param {number} frameTime - last measured rendering time in ms\n */\n function updateAvgFrameTime(scene, frameTime) {\n if (scene.avgFrameTime === undefined)\n scene.avgFrameTime = frameTime;else\n {\n scene.avgFrameTime = 0.8 * scene.avgFrameTime + 0.2 * frameTime;\n }\n }\n\n /**\n * Renders transparent scenes in back-to-front order.\n *\n * @param {RenderCB} renderObjectsCB - Called for each element of the scenes array\n * @param {UnifiedCamera} camera\n * @param {RenderBatch[]} scenes - Array of RenderBatches (or THREE.Scene with .boundingBox property)\n */\n function renderTransparentScenes(scenes, camera, renderObjectCB) {\n\n // compute camera distance for each scene\n var i, scene;\n for (i = 0; i < scenes.length; i++) {\n scene = scenes[i];\n var bbox = scene.boundingBox || scene.getBoundingBox();\n scene.cameraDistance = bbox.distanceToPoint(camera.position);\n }\n\n // sort by decreasing camera distance\n var sortOrder = function sortOrder(a, b) {\n return b.cameraDistance - a.cameraDistance;\n };\n scenes.sort(sortOrder);\n\n // render each scene and update average frame time\n var t0 = performance.now();\n for (i = 0; i < scenes.length; i++) {\n\n // render scene\n scene = scenes[i];\n renderObjectCB(scene);\n\n // measure elapsed time\n var t1 = performance.now();\n var delta = t1 - t0;\n t0 = t1;\n\n // track average frame time\n updateAvgFrameTime(scene, delta);\n }\n }\n\n /**\n * Indicates if the current traversal is done with the assumption that this frame will not be resumed.\n * @returns {boolean}\n */\n this.frameResumePossible = function () {\n return !_frameWillNotBeResumed;\n };\n\n /**\n * Incrementally render some meshes until we run out of time.\n * @param {RenderCB} cb - Called that does the actual rendering. Called for each RenderBatch to be rendered.\n * @param {number} timeRemaining - Time in milliseconds that can be spend in this function call.\n * @returns {number} Remaining time left after the call. Usually <=0.0 if the frame could not be fully finished yet.\n * \n * @callback RenderScene~RenderCB\n * @param {RenderBatch} scene\n */\n this.renderSome = function (renderObjectCB, timeRemaining) {\n\n var t0 = _perf.now(),t1;\n\n // reserve some time for transparent shapes.\n var timeForTransparent = this.budgetForTransparent * timeRemaining;\n\n // repeat until time budget is consumed...\n var model;\n while (1) {\n\n //Find the best candidate render batch to render now -- in case\n //there are multiple models.\n //TODO: In case a huge number of models is loaded, we may have to\n //rethink the linear loop below and use some priority heap or somesuch.\n var candidateIdx = 0;\n var scene = null;\n for (var iq = 0; iq < _candidateScenes.length; iq++) {\n\n // candidate is the next RenderBatch to be processed from _models[q] \n var candidate = _candidateScenes[iq];\n model = _models[iq];\n if (!candidate)\n _candidateScenes[iq] = candidate = model.nextBatch();\n\n // If the camera is in motion and the time for opaque scenes is over, continue with transparent shapes.\n var skipOpaque = _frameWillNotBeResumed && timeRemaining < timeForTransparent;\n if (skipOpaque) {\n\n // check if the next candidate is still an opaque one. Note that the .sortObjects\n // flag indicates whether a RenderBatch contains transparent objects.\n var isOpaque = candidate && !candidate.sortObjects;\n\n if (isOpaque) {\n // skip current candidate and use the first available transparent scene instead\n model.skipOpaqueShapes();\n candidate = model.nextBatch();\n }\n }\n\n if (candidate === null) {\n // No more batches to render from this model\n continue;\n }\n\n // If all previous candidates were null, _candidateScenes[q] is obviously the best one so far.\n if (!scene) {\n candidateIdx = iq;\n scene = candidate;\n }\n\n // Choose current candidate only if its renderImportance is higher.\n // The renderImportance of RenderBatches is set by model iterators.\n if (candidate.renderImportance > scene.renderImportance) {\n candidateIdx = iq;\n scene = candidate;\n }\n }\n\n // Render the batch we chose above and determine whether to continue the loop\n if (scene) {\n //Fetch a new render batch from the model that we took the\n //current batch from.\n _candidateScenes[candidateIdx] = _models[candidateIdx].nextBatch();\n\n // If we are in a non-resumable frame, we try to get the most important ones of opaque and\n // transparent scenes. Therefore, the traversal of transparent scenes will also be ordered\n // by decreasing priority just like for opaque ones. For correct rendering, however,\n // we cannot render them directly here. Instead, we must collect them first and render them\n // back-to-front at the end of the function.\n if (scene.sortObjects && _frameWillNotBeResumed) {\n\n // defer to the end of the frame\n _transparentScenes.push(scene);\n\n // reserve frame time based on past rendering times. Just for the very first use,\n // we use an initial guess value as fallback.\n timeRemaining -= scene.avgFrameTime === undefined ? 0.05 : scene.avgFrameTime;\n\n } else {\n\n // do the actual rendering\n renderObjectCB(scene);\n if (scene.hasOwnProperty(\"drawEnd\"))\n scene.drawEnd = scene.lastItem;\n\n // get time that we spent for rendering of the last batch\n t1 = _perf.now();\n var delta = t1 - t0; // in milliseconds\n t0 = t1;\n\n //For each sub-scene, keep a running average\n //of how long it took to render over the\n //last few frames.\n updateAvgFrameTime(scene, delta);\n\n // update remaining time\n // Note that we don't do accurate timing here, but compute with average values instead.\n // In this way, the number of rendered batches is more consistent across different frames\n timeRemaining -= scene.avgFrameTime;\n }\n\n // get time that we spent for rendering of the last batch\n t1 = _perf.now();\n var delta = t1 - t0; // in milliseconds\n t0 = t1;\n\n //For each sub-scene, keep a running average\n //of how long it took to render over the\n //last few frames.\n updateAvgFrameTime(scene, delta);\n\n // update remaining time\n // Note that we don't do accurate timing here, but compute with average values instead.\n // In this way, the number of rendered batches is more consistent across different frames\n timeRemaining -= scene.avgFrameTime;\n\n // Check if we should exit the loop...\n if (timeRemaining <= 0) {\n break;\n }\n\n } else {\n // No more batches => Frame rendering finished, if all models are loaded\n _done = true;\n break;\n }\n }\n\n // Render some deferred transparent shapes (_transparentShapes). Note that this array will\n // usually be empty if _frameWillNotBeResumed is false\n if (_transparentScenes.length > 0) {\n\n renderTransparentScenes(_transparentScenes, _camera, renderObjectCB);\n\n // all scenes processed. Clear array.\n _transparentScenes.length = 0;\n }\n\n return timeRemaining;\n };\n\n //TODO: This method needs to be revisited as on demand loading is removed from the code base \n /** Resets the scene traversal \n * @param {UnifiedCamera} camera\n * @param {number} drawMode - E.g., RENDER_NORMAL. See RenderFlags.js\n * @param: {number} [resetType] - Must be one of RESET_NORMAL, RESET_REDRAW or RESET_RELOAD.\n * Only used when on demand loading is enabled. RESET_RELOAD will reload and redraw\n * geometry. RESET_REDRAW will redraw geometry. RESET_NORMAL will only redraw geometry\n * that hasn't already been drawn. If undefined RESET_NORMAL is used.\n */\n this.reset = function (camera, drawMode, resetType, cutPlanes) {\n //_frameStamp++;\n _done = false;\n\n this.resetNeedsRender();\n\n //Calculate the viewing frustum\n //TODO: same math is done in the renderer also. We could unify\n _frustum.reset(camera, cutPlanes);\n _frustum.areaCullThreshold = globals.PIXEL_CULLING_THRESHOLD;\n\n if (!_models.length)\n return;\n\n // If the camera is in-motion, we assume the frame not to be resumed. This allows us to render transparent shapes\n // earlier. This special treatment is only used/needed for the main scene pass.\n _frameWillNotBeResumed = this.enableNonResumableFrames && resetType == ResetFlags.RESET_RELOAD && drawMode === RenderFlags.RENDER_NORMAL;\n\n _camera = camera;\n\n //Begin the frustum based scene iteration process per model.\n //A \"Model\" is all the objects to display. There's typically one model in a scene, so length is 1. \n for (var i = 0; i < _models.length; i++) {\n // decide what iterator to use, usually the BVH iterator\n _models[i].resetIterator(camera, _frustum, drawMode, resetType);\n // get the first RenderBatch (some set of fragments) to render.\n _candidateScenes[i] = _models[i].nextBatch();\n _previousScenes[i] = null;\n }\n };\n\n\n this.isDone = function () {\n return _done || this.isEmpty();\n };\n\n // Visibility and highlighting methods: see RenderModel.js for details.\n\n this.setAllVisibility = function (value) {\n for (var i = 0; i < _models.length; i++) {\n _models[i].setAllVisibility(value);}\n };\n\n this.hideLines = function (hide) {\n for (var i = 0; i < _models.length; i++) {\n _models[i].hideLines(hide);}\n };\n\n this.hidePoints = function (hide) {\n for (var i = 0; i < _models.length; i++) {\n _models[i].hidePoints(hide);}\n };\n\n this.hasHighlighted = function () {\n for (var i = 0; i < _models.length; i++) {\n if (_models[i].hasHighlighted())\n return true;}\n\n return false;\n };\n\n this.areAllVisible = function () {\n for (var i = 0; i < _models.length; i++) {\n if (!_models[i].areAllVisible())\n return false;}\n\n return true;\n };\n\n this.areAll2D = function () {\n for (var i = 0; i < _models.length; i++) {\n if (!_models[i].is2d())\n return false;}\n\n return true;\n };\n\n this.areAll3D = function () {\n for (var i = 0; i < _models.length; i++) {\n if (!_models[i].is3d())\n return false;}\n\n return true;\n };\n\n /** Trigger bbox recomputation. See RenderModel.js for details. */\n this.invalidateVisibleBounds = function () {\n for (var i = 0; i < _models.length; i++) {\n _models[i].visibleBoundsDirty = true;}\n };\n\n /**\n * @param {bool} includeGhosted\n * @param {function(model)} [modeFilter]\n * @param {bool} excludeShadow - Remove shadow geometry (if exists) from model bounds.\n * @returns {THREE.Box3} \n *\n * NOTE: The returned box object is always the same, i.e. later calls\n * affect previously returned values. E.g., for\n * var box1 = getVisibleBounds(true);\n * var box2 = getVisibleBounds(false);\n * the second call would also change box1.\n */\n this.getVisibleBounds = function (includeGhosted, bboxFilter, excludeShadow) {\n _tmpBox.makeEmpty();\n for (var i = 0; i < _models.length; i++) {\n var model = _models[i];\n var modelBox = model.getVisibleBounds(includeGhosted, excludeShadow);\n\n // Consider bboxFilter\n var skipModel = bboxFilter && !bboxFilter(modelBox);\n if (skipModel) {\n continue;\n }\n\n _tmpBox.union(modelBox);\n }\n return _tmpBox;\n };\n\n /**\n * @param {THREE.Vector3} position - Ray origin.\n * @param {THREE.Vector3} direction - Ray direction.\n * @param {bool} [ignoreTransparent] - Shoot trough transparent objects.\n * @param {number[]|number[][]} [dbIds] - Optional filter of dbIds to be considered for testing. see RenderModel.rayIntersect().\n * If modelIds is set, dbIds[i] must provide a separate dbId array for modelIds[i].\n * @param {number[]} [modelIds] - Optional list of modelIds to be considered for rayIntersection. (default is to consider all)\n * @param {Array} [intersections] - Optional return array with all found intersections.\n * @param {function} [getDbIdAtPointFor2D] - Optional callback. For 2D models, to return the dbId and modelId in an array.\n *\n * @returns {Object|null} Intersection result obect (see RenderModel.rayIntersect)\n */\n // Add \"meshes\" parameter, after we get meshes of the object using id buffer,\n // then we just need to ray intersect this object instead of all objects of the model.\n this.rayIntersect = function (position, direction, ignoreTransparent,\n dbIds, modelIds,\n intersections, getDbIdAtPointFor2D) {\n\n // Init raycaster\n _raycaster.set(position, direction);\n\n // For multiple RenderModels, perform raytest on each of them and find the closest one.\n if (_models.length > 1) {\n // Collect raytest result objects from each 3D model\n var modelHits = [];\n\n if (modelIds) {\n for (var i = 0; i < modelIds.length; i++) {\n var model = this.findModel(modelIds[i]);\n if (model) {\n var modelDbIds = dbIds && dbIds[i];\n var res = model.rayIntersect(_raycaster, ignoreTransparent, modelDbIds, intersections, getDbIdAtPointFor2D);\n if (res) {\n modelHits.push(res);\n }\n }\n }\n } else {\n for (var _i = 0; _i < _models.length; _i++) {\n // Perform raytest on model i\n var _res = _models[_i].rayIntersect(_raycaster, ignoreTransparent, dbIds, intersections, getDbIdAtPointFor2D);\n\n if (_res) {\n modelHits.push(_res);\n }\n }\n }\n\n if (!modelHits.length)\n return null;\n\n // Return closest hit\n modelHits.sort(function (a, b) {return a.distance - b.distance;});\n return modelHits[0];\n } else {\n // If we don't have any RenderModel, just return null.\n if (!_models.length)\n return null;\n\n // Apply modelIds filter\n var _model = _models[0];\n if (modelIds && modelIds.indexOf(_model.id) === -1) {\n return null;\n }\n\n // If we only have a single RenderModel, just call rayIntersect() on it.\n return _model.rayIntersect(_raycaster, ignoreTransparent, dbIds, intersections, getDbIdAtPointFor2D);\n }\n };\n\n /**\n * Progress of current frame rendering. \n * @returns {number} Value in [0,1], where 1 means finished.\n */\n this.getRenderProgress = function () {\n return _models[0].getRenderProgress();\n };\n\n /** @returns {RenderModel[]} */\n this.getModels = function () {\n return _models;\n };\n\n /** @returns {RenderModel[]} */\n this.getHiddenModels = function () {\n return _hiddenModels;\n };\n\n // ----------------------------\n // Warning: The methods in the section below assume that there is exactly one RenderModel.\n // They will ignore any additional models and cause an exception if the model list is empty.\n // \n\n // Direct access to FragmentList, GeometryList, and total number of RenderBatches.\n //\n // Note: \n // - The methods do only care for model 0 and ignore any additional ones.\n // - Will cause an error when called if the RenderModel array is empty.\n this.getFragmentList = function () {\n return _models[0].getFragmentList();\n };\n this.getGeometryList = function () {\n return _models[0].getGeometryList();\n };\n this.getSceneCount = function () {\n return _models[0].getSceneCount();\n };\n\n //Used by ground shadow update, ground reflection update, and screenshots\n this.getGeomScenes = function () {\n //TODO: temporarily rolled back because it breaks selection highlighting due to some ground shadow reason\n return _models[0].getGeomScenes();\n /*\n var scenes = [];\n for (var i=0; i<_models.length; i++) {\n // Collect all scenes from next model\n var modelScenes = _models[i].getGeomScenes();\n for (var j=0; j