@google/model-viewer
Version:
Easily display interactive 3D models on the web and in AR!
110 lines • 1.45 MB
JavaScript
/**
* Copyright (c) 2014-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/!function(a){"use strict";function b(a,b,c,e){// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return g._invoke=i(a,c,h),g}// Try/catch helper to minimize deoptimizations. Returns a completion
// record like context.tryEntries[i].completion. This interface could
// have been (and was previously) designed to take a closure to be
// invoked without arguments, but in all the cases we care about we
// already have an existing method we want to call, so there's no need
// to create a new function object. We can even get away with assuming
// the method takes exactly one argument, since that happens to be true
// in every case, so we don't have to touch the arguments object. The
// only additional allocation required is the completion record, which
// has a stable shape and so hopefully should be cheap to allocate.
function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}// Dummy constructor functions that we use as the .constructor and
// .constructor.prototype properties for functions that return Generator
// objects. For full spec compliance, you may wish to configure your
// minifier not to mangle the names of these two functions.
function d(){}function e(){}function f(){}// This is a polyfill for %IteratorPrototype% for environments that
// don't natively support it.
// Helper for defining the .next, .throw, and .return methods of the
// Iterator interface in terms of a single ._invoke method.
function g(a){["next","throw","return"].forEach(function(b){a[b]=function(a){return this._invoke(b,a)}})}function h(a){function b(d,e,f,g){var h=c(a[d],a,e);if("throw"===h.type)g(h.arg);else{var i=h.arg,j=i.value;return j&&"object"===typeof j&&q.call(j,"__await")?Promise.resolve(j.__await).then(function(a){b("next",a,f,g)},function(a){b("throw",a,f,g)}):Promise.resolve(j).then(function(a){// When a yielded Promise is resolved, its final value becomes
// the .value of the Promise<{value,done}> result for the
// current iteration. If the Promise is rejected, however, the
// result for this iteration will be rejected with the same
// reason. Note that rejections of yielded Promises are not
// thrown back into the generator function, as is the case
// when an awaited Promise is rejected. This difference in
// behavior between yield and await is important, because it
// allows the consumer to decide what to do with the yielded
// rejection (swallow it and continue, manually .throw it back
// into the generator, abandon iteration, whatever). With
// await, by contrast, there is no opportunity to examine the
// rejection reason outside the generator function, so the
// only option is to throw it from the await expression, and
// let the generator function handle the exception.
i.value=a,f(i)},g)}}function d(a,c){function d(){return new Promise(function(d,e){b(a,c,d,e)})}return e=// If enqueue has been called before, then we want to wait until
// all previous Promises have been resolved before calling invoke,
// so that results are always delivered in the correct order. If
// enqueue has not been called before, then it is important to
// call invoke immediately, without waiting on a callback to fire,
// so that the async generator function has the opportunity to do
// any necessary setup in a predictable way. This predictability
// is why the Promise constructor synchronously invokes its
// executor callback, and why async functions synchronously
// execute code before the first await. Since we implement simple
// async functions in terms of async generators, it is especially
// important to get this right, even though it requires care.
e?e.then(d,// Avoid propagating failures to Promises returned by later
// invocations of the iterator.
d):d()}// Define the unified helper method that is used to implement .next,
// .throw, and .return (see defineIteratorMethods).
var e;this._invoke=d}function i(a,b,d){var e="suspendedStart";return function(f,g){if(e==="executing")throw new Error("Generator is already running");if("completed"===e){if("throw"===f)throw g;// Be forgiving, per 25.3.3.3.3 of the spec:
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)// Setting context._sent for legacy support of Babel's
// function.sent implementation.
d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"===e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(// Dispatch the exception by looping back around to the
// context.dispatchException(context.arg) call above.
e="completed",d.method="throw",d.arg=k.arg)}}}// Call delegate.iterator[context.method](context.arg) and handle the
// result, either by returning a { value, done } result from the
// delegate iterator, or by modifying context.method and context.arg,
// setting context.delegate to null, and returning the ContinueSentinel.
function j(a,b){var d=a.iterator[b.method];if(void 0===d){if(b.delegate=null,"throw"===b.method){if(a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method))// If maybeInvokeDelegate(context) changed context.method from
// "return" to "throw", let that override the TypeError below.
return x;b.method="throw",b.arg=new TypeError("The iterator does not provide a 'throw' method")}return x}var e=c(d,a.iterator,b.arg);if("throw"===e.type)return b.method="throw",b.arg=e.arg,b.delegate=null,x;var f=e.arg;if(!f)return b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x;if(f.done)b[a.resultName]=f.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0);else// Re-yield the result returned by the delegate method.
return f;// The delegate iterator is finished, so forget it and continue with
// the outer generator.
return b.delegate=null,x}// Define Generator.prototype.{next,throw,return} in terms of the
// unified ._invoke helper method.
function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){// The root entry object (effectively a try statement without a catch
// or a finally block) gives us a place to store values thrown from
// locations where there is no enclosing try statement.
this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[s];if(b)return b.call(a);if("function"===typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(q.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}// Return an iterator with no values.
return{next:o}}function o(){return{value:void 0,done:!0}}var p=Object.prototype,q=p.hasOwnProperty,r="function"===typeof Symbol?Symbol:{},s=r.iterator||"@@iterator",t=r.asyncIterator||"@@asyncIterator",u=r.toStringTag||"@@toStringTag",v="object"===typeof module,w=a.regeneratorRuntime;if(w)// Don't bother evaluating the rest of this file if the runtime was
// already defined globally.
return void(v&&(module.exports=w));// Define the runtime globally (as expected by generated code) as either
// module.exports (if we're in a module) or a new, empty object.
w=a.regeneratorRuntime=v?module.exports:{},w.wrap=b;var x={},y={};y[s]=function(){return this};var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==p&&q.call(A,s)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);// Within the body of any async function, `await x` is transformed to
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
// `hasOwn.call(value, "__await")` to determine if the yielded value is
// meant to be awaited.
// Note that simple async functions are implemented on top of
// AsyncIterator objects; they just return a Promise for the value of
// the final result produced by the iterator.
// A Generator should always return itself as the iterator object when the
// @@iterator function is called on it. Some browsers' implementations of the
// iterator prototype chain incorrectly implement this, causing the Generator
// object to not be returned from this call. This ensures that doesn't happen.
// See https://github.com/facebook/regenerator/issues/274 for more details.
e.prototype=B.constructor=f,f.constructor=e,f[u]=e.displayName="GeneratorFunction",w.isGeneratorFunction=function(a){var b="function"===typeof a&&a.constructor;return!!b&&(b===e||// For the native GeneratorFunction constructor, the best we can
// do is to check its .name property.
"GeneratorFunction"===(b.displayName||b.name))},w.mark=function(a){return Object.setPrototypeOf?Object.setPrototypeOf(a,f):(a.__proto__=f,!(u in a)&&(a[u]="GeneratorFunction")),a.prototype=Object.create(B),a},w.awrap=function(a){return{__await:a}},g(h.prototype),h.prototype[t]=function(){return this},w.AsyncIterator=h,w.async=function(a,c,d,e){var f=new h(b(a,c,d,e));return w.isGeneratorFunction(c)?f// If outerFn is a generator, return the full iterator.
:f.next().then(function(a){return a.done?a.value:f.next()})},g(B),B[u]="Generator",B[s]=function(){return this},B.toString=function(){return"[object Generator]"},w.keys=function(a){var b=[];for(var c in a)b.push(c);// Rather than returning an object with a next method, we keep
// things simple and return the next function itself.
return b.reverse(),function c(){for(;b.length;){var d=b.pop();if(d in a)return c.value=d,c.done=!1,c}// To avoid creating an additional object, we just hang the .value
// and .done properties off the next function object itself. This
// also ensures that the minifier will not anonymize the function.
return c.done=!0,c}},w.values=n,m.prototype={constructor:m,reset:function(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)// Not sure about the optimal order of these conditions:
"t"===b.charAt(0)&&q.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function(){this.done=!0;var a=this.tryEntries[0],b=a.completion;if("throw"===b.type)throw b.arg;return this.rval},dispatchException:function(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)// Exception thrown outside of any try block that could handle
// it, so set the completion value of the entire function to
// throw the exception.
return b("end");if(e.tryLoc<=this.prev){var g=q.call(e,"catchLoc"),h=q.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(g){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);}else if(!h)throw new Error("try statement without catch or finally");else if(this.prev<e.finallyLoc)return b(e.finallyLoc)}}},abrupt:function(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&q.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}// The context.catch method must only be called with a location
// argument that corresponds to a known catch block.
throw new Error("illegal catch attempt")},delegateYield:function(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}}}(// In sloppy mode, unbound `this` refers to the global object, fallback to
// Function constructor if we're in global strict mode. That is sadly a form
// of indirect eval which violates Content Security Policy.
function(){return this}()||Function("return this")());function _get(target,property,receiver){if(typeof Reflect!=="undefined"&&Reflect.get){_get=Reflect.get;}else{_get=function _get(target,property,receiver){var base=_superPropBase(target,property);if(!base)return;var desc=Object.getOwnPropertyDescriptor(base,property);if(desc.get){return desc.get.call(receiver);}return desc.value;};}return _get(target,property,receiver||target);}function _superPropBase(object,property){while(!Object.prototype.hasOwnProperty.call(object,property)){object=_getPrototypeOf(object);if(object===null)break;}return object;}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _wrapNativeSuper(Class){var _cache=typeof Map==="function"?new Map():undefined;_wrapNativeSuper=function _wrapNativeSuper(Class){if(Class===null||!_isNativeFunction(Class))return Class;if(typeof Class!=="function"){throw new TypeError("Super expression must either be null or a function");}if(typeof _cache!=="undefined"){if(_cache.has(Class))return _cache.get(Class);_cache.set(Class,Wrapper);}function Wrapper(){return _construct(Class,arguments,_getPrototypeOf(this).constructor);}Wrapper.prototype=Object.create(Class.prototype,{constructor:{value:Wrapper,enumerable:false,writable:true,configurable:true}});return _setPrototypeOf(Wrapper,Class);};return _wrapNativeSuper(Class);}function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Date.prototype.toString.call(Reflect.construct(Date,[],function(){}));return true;}catch(e){return false;}}function _construct(Parent,args,Class){if(isNativeReflectConstruct()){_construct=Reflect.construct;}else{_construct=function _construct(Parent,args,Class){var a=[null];a.push.apply(a,args);var Constructor=Function.bind.apply(Parent,a);var instance=new Constructor();if(Class)_setPrototypeOf(instance,Class.prototype);return instance;};}return _construct.apply(null,arguments);}function _isNativeFunction(fn){return Function.toString.call(fn).indexOf("[native code]")!==-1;}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){if(!(Symbol.iterator in Object(arr)||Object.prototype.toString.call(arr)==="[object Arguments]")){return;}var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _instanceof(left,right){if(right!=null&&typeof Symbol!=="undefined"&&right[Symbol.hasInstance]){return!!right[Symbol.hasInstance](left);}else{return left instanceof right;}}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}function _toConsumableArray(arr){return _arrayWithoutHoles(arr)||_iterableToArray(arr)||_nonIterableSpread();}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance");}function _iterableToArray(iter){if(Symbol.iterator in Object(iter)||Object.prototype.toString.call(iter)==="[object Arguments]")return Array.from(iter);}function _arrayWithoutHoles(arr){if(Array.isArray(arr)){for(var i=0,arr2=new Array(arr.length);i<arr.length;i++){arr2[i]=arr[i];}return arr2;}}function _classCallCheck(instance,Constructor){if(!_instanceof(instance,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;}function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}(function(global,factory){(typeof exports==="undefined"?"undefined":_typeof(exports))==='object'&&typeof module!=='undefined'?factory():typeof define==='function'&&define.amd?define(factory):factory();})(this,function(){'use strict';var _encodings;var HAS_WEBXR_DEVICE_API=navigator.xr!=null&&self.XRSession!=null&&navigator.xr.supportsSession!=null;var HAS_WEBXR_HIT_TEST_API=HAS_WEBXR_DEVICE_API&&self.XRSession.prototype.requestHitTest;var HAS_RESIZE_OBSERVER=self.ResizeObserver!=null;var HAS_INTERSECTION_OBSERVER=self.IntersectionObserver!=null;var IS_WEBXR_AR_CANDIDATE=HAS_WEBXR_HIT_TEST_API;var IS_MOBILE=function(){var userAgent=navigator.userAgent||navigator.vendor||self.opera;var check=false;if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(userAgent)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(userAgent.substr(0,4))){check=true;}return check;}();var HAS_OFFSCREEN_CANVAS=Boolean(self.OffscreenCanvas);var OFFSCREEN_CANVAS_SUPPORT_BITMAP=Boolean(self.OffscreenCanvas)&&Boolean(self.OffscreenCanvas.prototype.transferToImageBitmap);var IS_ANDROID=/android/i.test(navigator.userAgent);var IS_IOS=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!self.MSStream||navigator.platform==='MacIntel'&&navigator.maxTouchPoints>1;var IS_AR_QUICKLOOK_CANDIDATE=function(){var tempAnchor=document.createElement('a');return Boolean(tempAnchor.relList&&tempAnchor.relList.supports&&tempAnchor.relList.supports('ar'));}();var IS_IOS_CHROME=IS_IOS&&/CriOS\//.test(navigator.userAgent);var IS_IOS_SAFARI=IS_IOS&&/Safari\//.test(navigator.userAgent);var IS_IE11=!window.ActiveXObject&&'ActiveXObject'in window;var deserializeUrl=function deserializeUrl(url){return url!=null&&url!=='null'?toFullUrl(url):null;};var assertIsArCandidate=function assertIsArCandidate(){if(IS_WEBXR_AR_CANDIDATE){return;}var missingApis=[];if(!HAS_WEBXR_DEVICE_API){missingApis.push('WebXR Device API');}if(!HAS_WEBXR_HIT_TEST_API){missingApis.push('WebXR Hit Test API');}throw new Error("The following APIs are required for AR, but are missing in this browser: ".concat(missingApis.join(', ')));};var toFullUrl=function toFullUrl(partialUrl){var url=new URL(partialUrl,window.location.toString());return url.toString();};var throttle=function throttle(fn,ms){var timer=null;var throttled=function throttled(){if(timer!=null){return;}fn.apply(void 0,arguments);timer=self.setTimeout(function(){return timer=null;},ms);};throttled.flush=function(){if(timer!=null){self.clearTimeout(timer);timer=null;}};return throttled;};var debounce=function debounce(fn,ms){var timer=null;return function(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}if(timer!=null){self.clearTimeout(timer);}timer=self.setTimeout(function(){timer=null;fn.apply(void 0,args);},ms);};};var step=function step(edge,value){return value<edge?0:1;};var clamp=function clamp(value,lowerLimit,upperLimit){return Math.max(lowerLimit===-Infinity?value:lowerLimit,Math.min(upperLimit===Infinity?value:upperLimit,value));};var CAPPED_DEVICE_PIXEL_RATIO=1;var resolveDpr=function(){var HAS_META_VIEWPORT_TAG=function(){var metas=document.head!=null?Array.from(document.head.querySelectorAll('meta')):[];var _iteratorNormalCompletion=true;var _didIteratorError=false;var _iteratorError=undefined;try{for(var _iterator=metas[Symbol.iterator](),_step;!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=true){var meta=_step.value;if(meta.name==='viewport'){return true;}}}catch(err){_didIteratorError=true;_iteratorError=err;}finally{try{if(!_iteratorNormalCompletion&&_iterator.return!=null){_iterator.return();}}finally{if(_didIteratorError){throw _iteratorError;}}}return false;}();if(!HAS_META_VIEWPORT_TAG){console.warn('No <meta name="viewport"> detected; <model-viewer> will cap pixel density at 1.');}return function(){return HAS_META_VIEWPORT_TAG?window.devicePixelRatio:CAPPED_DEVICE_PIXEL_RATIO;};}();var getFirstMapKey=function getFirstMapKey(map){if(map.keys!=null){return map.keys().next().value||null;}var firstKey=null;try{map.forEach(function(_value,key,_map){firstKey=key;throw new Error();});}catch(_error){}return firstKey;};var expect=chai.expect;suite('utils',function(){suite('deserializeUrl',function(){test('returns a string given a string',function(){expect(deserializeUrl('foo')).to.be.a('string');});test('returns null given a null-ish value',function(){expect(deserializeUrl(null)).to.be.equal(null);});test('yields a url on the same origin for relative paths',function(){var origin=window.location.origin;expect(deserializeUrl('foo').indexOf(origin)).to.be.equal(0);});});suite('resolveDpr',function(){suite('when <meta name="viewport"> is present',function(){test('resolves the device pixel ratio',function(){var resolvedDpr=resolveDpr();var actualDpr=self.devicePixelRatio;expect(resolvedDpr).to.be.equal(actualDpr);});});suite('when <meta name="viewport"> is not present',function(){test.skip('caps the device pixel ratio to 1',function(){});});});suite('step',function(){test('returns 0 for values below edge',function(){expect(step(0.5,0.1)).to.be.equal(0);});test('returns 1 for values above edge',function(){expect(step(0.5,0.9)).to.be.equal(1);});});suite('clamp',function(){test('numbers below lower limit adjusted to lower limit',function(){expect(clamp(1.0,2.0,3.0)).to.be.equal(2.0);});test('numbers above upper limit adjusted to upper limit',function(){expect(clamp(4.0,2.0,3.0)).to.be.equal(3.0);});test('numbers within lower and upper limits unchanged',function(){expect(clamp(2.5,2.0,3.0)).to.be.equal(2.5);});});});var numberNode=function numberNode(value,unit){return{type:'number',number:value,unit:unit};};var parseExpressions=function(){var cache={};var MAX_PARSE_ITERATIONS=1000;return function(inputString){var cacheKey=inputString;if(cacheKey in cache){return cache[cacheKey];}var expressions=[];var parseIterations=0;while(inputString){if(++parseIterations>MAX_PARSE_ITERATIONS){inputString='';break;}var expressionParseResult=parseExpression(inputString);var expression=expressionParseResult.nodes[0];if(expression==null||expression.terms.length===0){break;}expressions.push(expression);inputString=expressionParseResult.remainingInput;}return cache[cacheKey]=expressions;};}();var parseExpression=function(){var IS_IDENT_RE=/^(\-\-|[a-z\u0240-\uffff])/i;var IS_OPERATOR_RE=/^([\*\+\/]|[\-]\s)/i;var IS_EXPRESSION_END_RE=/^[\),]/;var FUNCTION_ARGUMENTS_FIRST_TOKEN='(';var HEX_FIRST_TOKEN='#';return function(inputString){var terms=[];while(inputString.length){inputString=inputString.trim();if(IS_EXPRESSION_END_RE.test(inputString)){break;}else if(inputString[0]===FUNCTION_ARGUMENTS_FIRST_TOKEN){var _parseFunctionArgumen=parseFunctionArguments(inputString),nodes=_parseFunctionArgumen.nodes,remainingInput=_parseFunctionArgumen.remainingInput;inputString=remainingInput;terms.push({type:'function',name:{type:'ident',value:'calc'},arguments:nodes});}else if(IS_IDENT_RE.test(inputString)){var identParseResult=parseIdent(inputString);var _identNode=identParseResult.nodes[0];inputString=identParseResult.remainingInput;if(inputString[0]===FUNCTION_ARGUMENTS_FIRST_TOKEN){var _parseFunctionArgumen2=parseFunctionArguments(inputString),_nodes=_parseFunctionArgumen2.nodes,_remainingInput=_parseFunctionArgumen2.remainingInput;terms.push({type:'function',name:_identNode,arguments:_nodes});inputString=_remainingInput;}else{terms.push(_identNode);}}else if(IS_OPERATOR_RE.test(inputString)){terms.push({type:'operator',value:inputString[0]});inputString=inputString.slice(1);}else{var _ref=inputString[0]===HEX_FIRST_TOKEN?parseHex(inputString):parseNumber(inputString),_nodes2=_ref.nodes,_remainingInput2=_ref.remainingInput;if(_nodes2.length===0){break;}terms.push(_nodes2[0]);inputString=_remainingInput2;}}return{nodes:[{type:'expression',terms:terms}],remainingInput:inputString};};}();var parseIdent=function(){var NOT_IDENT_RE=/[^a-z^0-9^_^\-^\u0240-\uffff]/i;return function(inputString){var match=inputString.match(NOT_IDENT_RE);var ident=match==null?inputString:inputString.substr(0,match.index);var remainingInput=match==null?'':inputString.substr(match.index);return{nodes:[{type:'ident',value:ident}],remainingInput:remainingInput};};}();var parseNumber=function(){var NOT_VALUE_RE=/[^0-9\.\-]|$/;var UNIT_RE=/^[a-z%]+/i;var ALLOWED_UNITS=/^(m|mm|cm|rad|deg|[%])$/;return function(inputString){var notValueMatch=inputString.match(NOT_VALUE_RE);var value=notValueMatch==null?inputString:inputString.substr(0,notValueMatch.index);inputString=notValueMatch==null?inputString:inputString.slice(notValueMatch.index);var unitMatch=inputString.match(UNIT_RE);var unit=unitMatch!=null&&unitMatch[0]!==''?unitMatch[0]:null;var remainingInput=unitMatch==null?inputString:inputString.slice(unit.length);if(unit!=null&&!ALLOWED_UNITS.test(unit)){unit=null;}return{nodes:[{type:'number',number:parseFloat(value)||0,unit:unit}],remainingInput:remainingInput};};}();var parseHex=function(){var HEX_RE=/^[a-f0-9]*/i;return function(inputString){inputString=inputString.slice(1).trim();var hexMatch=inputString.match(HEX_RE);var nodes=hexMatch==null?[]:[{type:'hex',value:hexMatch[0]}];return{nodes:nodes,remainingInput:hexMatch==null?inputString:inputString.slice(hexMatch[0].length)};};}();var parseFunctionArguments=function parseFunctionArguments(inputString){var expressionNodes=[];inputString=inputString.slice(1).trim();while(inputString.length){var expressionParseResult=parseExpression(inputString);expressionNodes.push(expressionParseResult.nodes[0]);inputString=expressionParseResult.remainingInput.trim();if(inputString[0]===','){inputString=inputString.slice(1).trim();}else if(inputString[0]===')'){inputString=inputString.slice(1);break;}}return{nodes:expressionNodes,remainingInput:inputString};};var $visitedTypes=Symbol('visitedTypes');var ASTWalker=/*#__PURE__*/function(){function ASTWalker(visitedTypes){_classCallCheck(this,ASTWalker);this[$visitedTypes]=visitedTypes;}_createClass(ASTWalker,[{key:"walk",value:function walk(ast,callback){var remaining=ast.slice();while(remaining.length){var next=remaining.shift();if(this[$visitedTypes].indexOf(next.type)>-1){callback(next);}switch(next.type){case'expression':remaining.unshift.apply(remaining,_toConsumableArray(next.terms));break;case'function':remaining.unshift.apply(remaining,[next.name].concat(_toConsumableArray(next.arguments)));break;}}}}]);return ASTWalker;}();var ZERO=Object.freeze({type:'number',number:0,unit:null});var elementFromLocalPoint=function elementFromLocalPoint(document,x,y){var host=document===window.document?window.document.body:document.host;var actualDocument=window.ShadyCSS?window.document:document;var boundingRect=host.getBoundingClientRect();return actualDocument.elementFromPoint(boundingRect.left+x,boundingRect.top+y);};var pickShadowDescendant=function pickShadowDescendant(element){var x=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var y=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0;return element.shadowRoot!=null?elementFromLocalPoint(element.shadowRoot,x,y):null;};var timePasses=function timePasses(){var ms=arguments.length>0&&arguments[0]!==undefined?arguments[0]:0;return new Promise(function(resolve){return setTimeout(resolve,ms);});};var until=/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee(predicate){return regeneratorRuntime.wrap(function _callee$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:if(predicate()){_context2.next=5;break;}_context2.next=3;return timePasses();case 3:_context2.next=0;break;case 5:case"end":return _context2.stop();}}},_callee);}));return function until(_x2){return _ref2.apply(this,arguments);};}();var rafPasses=function rafPasses(){return new Promise(function(resolve){return requestAnimationFrame(function(){return resolve();});});};var textureMatchesMeta=function textureMatchesMeta(texture,meta){return!!(texture&&texture.userData&&Object.keys(meta).reduce(function(matches,key){return matches&&meta[key]===texture.userData[key];},true));};var waitForEvent=function waitForEvent(target,eventName){var predicate=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;return new Promise(function(resolve){function handler(event){if(!predicate||predicate(event)){resolve(event);target.removeEventListener(eventName,handler);}}target.addEventListener(eventName,handler);});};var dispatchSyntheticEvent=function dispatchSyntheticEvent(target,type){var properties=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{clientX:0,clientY:0,deltaY:1.0};var event=new CustomEvent(type,{cancelable:true,bubbles:true});Object.assign(event,properties);target.dispatchEvent(event);return event;};var ASSETS_DIRECTORY='../examples/assets/';var assetPath=function assetPath(name){return deserializeUrl("".concat(ASSETS_DIRECTORY).concat(name));};var isInDocumentTree=function isInDocumentTree(node){var root=node.getRootNode();while(root!==node&&root!=null){if(root.nodeType===Node.DOCUMENT_NODE){return root===document;}root=root.host&&root.host.getRootNode();}return false;};var spy=function spy(object,property,descriptor){var sourcePrototype=object;while(sourcePrototype!=null&&!sourcePrototype.hasOwnProperty(property)){sourcePrototype=sourcePrototype.__proto__;}if(sourcePrototype==null){throw new Error("Cannnot spy property \"".concat(property,"\" on ").concat(object));}var originalDescriptor=Object.getOwnPropertyDescriptor(sourcePrototype,property);if(originalDescriptor==null){throw new Error("Cannot read descriptor of \"".concat(property,"\" on ").concat(object));}Object.defineProperty(sourcePrototype,property,descriptor);return function(){Object.defineProperty(sourcePrototype,property,originalDescriptor);};};var expressionNode=function expressionNode(terms){return{type:'expression',terms:terms};};var hexNode=function hexNode(value){return{type:'hex',value:value};};var identNode=function identNode(value){return{type:'ident',value:value};};var operatorNode=function operatorNode(value){return{type:'operator',value:value};};var functionNode=function functionNode(name,args){return{type:'function',name:identNode(name),arguments:args};};var expect$1=chai.expect;suite('parsers',function(){suite('parseExpressions',function(){test('parses single numbers',function(){expect$1(parseExpressions('123rad')).to.be.eql([expressionNode([numberNode(123,'rad')])]);});test('parses number tuples',function(){expect$1(parseExpressions('123rad 3.14deg -1m 2cm')).to.be.eql([expressionNode([numberNode(123,'rad'),numberNode(3.14,'deg'),numberNode(-1,'m'),numberNode(2,'cm')])]);});test('parses hex colors',function(){expect$1(parseExpressions('#fff')).to.be.eql([expressionNode([hexNode('fff')])]);expect$1(parseExpressions('#abc123')).to.be.eql([expressionNode([hexNode('abc123')])]);expect$1(parseExpressions('#daf012ee')).to.be.eql([expressionNode([hexNode('daf012ee')])]);});test('parses functions',function(){expect$1(parseExpressions('rgba(255, 123, 0, 0.25)')).to.be.eql([expressionNode([functionNode('rgba',[expressionNode([numberNode(255,null)]),expressionNode([numberNode(123,null)]),expressionNode([numberNode(0,null)]),expressionNode([numberNode(0.25,null)])])])]);});test('parses nested functions',function(){expect$1(parseExpressions('rgba(255, calc(100 + var(--blue)), 0, 0.25)')).to.be.eql([expressionNode([functionNode('rgba',[expressionNode([numberNode(255,null)]),expressionNode([functionNode('calc',[expressionNode([numberNode(100,null),operatorNode('+'),functionNode('var',[expressionNode([identNode('--blue')])])])])]),expressionNode([numberNode(0,null)]),expressionNode([numberNode(0.25,null)])])])]);});test('parses calc algebra',function(){expect$1(parseExpressions('1m - -2rad / 3 + 4deg * -10.5')).to.be.eql([expressionNode([numberNode(1,'m'),operatorNode('-'),numberNode(-2,'rad'),operatorNode('/'),numberNode(3,null),operatorNode('+'),numberNode(4,'deg'),operatorNode('*'),numberNode(-10.5,null)])]);});suite('failure cases',function(){suite('mismatched parens',function(){test('trailing paren is gracefully dropped',function(){expect$1(parseExpressions('calc(calc(123)))')).to.be.eql([expressionNode([functionNode('calc',[expressionNode([functionNode('calc',[expressionNode([numberNode(123,null)])])])])])]);});});});});suite('ASTWalker',function(){test('only walks configured node types',function(){var astWalker=new ASTWalker(['number','ident']);var ast=parseExpressions('calc(123 + var(--size))');var visitedNodes=0;astWalker.walk(ast,function(node){expect$1(node.type==='number'||node.type==='ident').to.be.true;visitedNodes++;});expect$1(visitedNodes).to.be.equal(4);});});});var degreesToRadians=function degreesToRadians(numberNode$$1){var fallbackRadianValue=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var number=numberNode$$1.number,unit=numberNode$$1.unit;if(!isFinite(number)){number=fallbackRadianValue;unit='rad';}else if(numberNode$$1.unit==='rad'||numberNode$$1.unit==null){return numberNode$$1;}var valueIsDegrees=unit==='deg'&&number!=null;var value=valueIsDegrees?number:0;var radians=value*Math.PI/180;return{type:'number',number:radians,unit:'rad'};};var radiansToDegrees=function radiansToDegrees(numberNode$$1){var fallbackDegreeValue=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var number=numberNode$$1.number,unit=numberNode$$1.unit;if(!isFinite(number)){number=fallbackDegreeValue;unit='deg';}else if(numberNode$$1.unit==='deg'){return numberNode$$1;}var valueIsRadians=(unit===null||unit==='rad')&&number!=null;var value=valueIsRadians?number:0;var degrees=value*180/Math.PI;return{type:'number',number:degrees,unit:'deg'};};var lengthToBaseMeters=function lengthToBaseMeters(numberNode$$1){var fallbackMeterValue=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var number=numberNode$$1.number,unit=numberNode$$1.unit;if(!isFinite(number)){number=fallbackMeterValue;unit='m';}else if(numberNode$$1.unit==='m'){return numberNode$$1;}var scale;switch(unit){default:scale=1;break;case'cm':scale=1/100;break;case'mm':scale=1/1000;break;}var value=scale*number;return{type:'number',number:value,unit:'m'};};var normalizeUnit=function(){var identity=function identity(node){return node;};var unitNormalizers={'rad':identity,'deg':degreesToRadians,'m':identity,'mm':lengthToBaseMeters,'cm':lengthToBaseMeters};return function(node){var fallback=arguments.length>1&&arguments[1]!==undefined?arguments[1]:ZERO;var number=node.number,unit=node.unit;if(!isFinite(number)){number=fallback.number;unit=fallback.unit;}if(unit==null){return node;}var normalize=unitNormalizers[unit];if(normalize==null){return fallback;}return normalize(node);};}();var expect$2=chai.expect;suite('conversions',function(){suite('degreesToRadians',function(){test('converts a number expressed in degrees to radians',function(){expect$2(degreesToRadians(numberNode(180,'deg'))).to.be.eql(numberNode(Math.PI,'rad'));});test('passes through numbers expressed in radians',function(){expect$2(degreesToRadians(numberNode(1,'rad'))).to.be.eql(numberNode(1,'rad'));});test('passes through numbers without a unit',function(){expect$2(degreesToRadians(numberNode(1,null))).to.be.eql(numberNode(1,null));});});suite('radiansToDegrees',function(){test('converts a number expressed in radians to degrees',function(){expect$2(radiansToDegrees(numberNode(Math.PI,'rad'))).to.be.eql(numberNode(180,'deg'));});test('passes through numbers expressed in degrees',function(){expect$2(radiansToDegrees(numberNode(1,'deg'))).to.be.eql(numberNode(1,'deg'));});test('treats numbers without a unit as radians',function(){expect$2(radiansToDegrees(numberNode(Math.PI,null))).to.be.eql(numberNode(180,'deg'));});});suite('lengthToBaseMeters',function(){test('passes through numbers expressed in base meters',function(){expect$2(lengthToBaseMeters(numberNode(1,'m'))).to.be.eql(numberNode(1,'m'));});test('converts numbers expressed in centimeters to base meters',function(){expect$2(lengthToBaseMeters(numberNode(123,'cm'))).to.be.eql(numberNode(1.23,'m'));});test('converts numbers expressed in millimeters to base meters',function(){expect$2(lengthToBaseMeters(numberNode(1234,'mm'))).to.be.eql(numberNode(1.234,'m'));});});suite('normalizeUnit',function(){test('normalizes angles to radians',function(){expect$2(normalizeUnit(numberNode(180,'deg'))).to.be.eql(numberNode(Math.PI,'rad'));expect$2(normalizeUnit(numberNode(180,'rad'))).to.be.eql(numberNode(180,'rad'));});test('normalizes lengths to base meters',function(){expect$2(normalizeUnit(numberNode(1,'m'))).to.be.eql(numberNode(1,'m'));expect$2(normalizeUnit(numberNode(1000,'mm'))).to.be.eql(numberNode(1,'m'));});});});var enumerationDeserializer=function enumerationDeserializer(allowedNames){return function(valueString){try{var expressions=parseExpressions(valueString);var names=(expressions.length?expressions[0].terms:[]).filter(function(valueNode){return valueNode&&valueNode.type==='ident';}).map(function(valueNode){return valueNode.value;}).filter(function(name){return allowedNames.indexOf(name)>-1;});var result=new Set();var _iteratorNormalCompletion2=true;var _didIteratorError2=false;var _iteratorError2=undefined;try{for(var _iterator2=names[Symbol.iterator](),_step2;!(_iteratorNormalCompletion2=(_step2=_iterator2.next()).done);_iteratorNormalCompletion2=true){var name=_step2.value;result.add(name);}}catch(err){_didIteratorError2=true;_iteratorError2=err;}finally{try{if(!_iteratorNormalCompletion2&&_iterator2.return!=null){_iterator2.return();}}finally{if(_didIteratorError2){throw _iteratorError2;}}}return result;}catch(_error){}return new Set();};};var expect$3=chai.expect;suite('deserializers',function(){suite('enumerationDeserializer',function(){var animals;var deserializeAnimals;setup(function(){animals=['elephant','octopus','chinchilla'];deserializeAnimals=enumerationDeserializer(animals);});test('yields the members of the enumeration in the input string',function(){var deserialized=deserializeAnimals('elephant chinchilla');expect$3(deserialized.size).to.be.equal(2);expect$3(deserialized.has('elephant')).to.be.true;expect$3(deserialized.has('chinchilla')).to.be.true;});test('filters out non-members of the enumeration',function(){var deserialized=deserializeAnimals('octopus paris');expect$3(deserialized.size).to.be.equal(1);expect$3(deserialized.has('octopus')).to.be.true;});test('yields an empty set from null input',function(){var deserialized=deserializeAnimals(null);expect$3(deserialized.size).to.be.equal(0);});});});var _a,_b,_c;var $evaluate=Symbol('evaluate');var $lastValue=Symbol('lastValue');var Evaluator=/*#__PURE__*/function(){function Evaluator(){_classCallCheck(this,Evaluator);this[_a]=null;}_createClass(Evaluator,[{key:"evaluate",value:function evaluate(){if(!this.isConstant||this[$lastValue]==null){this[$lastValue]=this[$evaluate]();}return this[$lastValue];}},{key:"isConstant",get:function get(){return false;}}],[{key:"evaluatableFor",value:function evaluatableFor(node){var basis=arguments.length>1&&arguments[1]!==undefined?arguments[1]:ZERO;if(_instanceof(node,Evaluator)){return node;}if(node.type==='number'){if(node.unit==='%'){return new PercentageEvaluator(node,basis);}return node;}switch(node.name.value){case'calc':return new CalcEvaluator(node,basis);case'env':return new EnvEvaluator(node);}return ZERO;}},{key:"evaluate",value:function evaluate(evaluatable){if(_instanceof(evaluatable,Evaluator)){return evaluatable.evaluate();}return evaluatable;}},{key:"isConstant",value:function isConstant(evaluatable){if(_instanceof(evaluatable,Evaluator)){return evaluatable.isConstant;}return true;}},{key:"applyIntrinsics",value:function applyIntrinsics(evaluated,intrinsics){var basis=intrinsics.basis,keywords=intrinsics.keywords;var auto=keywords.auto;return basis.map(function(basisNode,index){var autoSubstituteNode=auto[index]==null?basisNode:auto[index];var evaluatedNode=evaluated[index]?evaluated[index]:autoSubstituteNode;if(evaluatedNode.type==='ident'){var keyword=evaluatedNode.value;if(keyword in keywords){evaluatedNode=keywords[keyword][index];}}if(evaluatedNode==null||evaluatedNode.type==='ident'){evaluatedNode=autoSubstituteNode;}if(evaluatedNode.unit==='%'){return numberNode(evaluatedNode.number/100*basisNode.number,basisNode.unit);}evaluatedNode=normalizeUnit(evaluatedNode,basisNode);if(evaluatedNode.unit!==basisNode.unit){return basisNode;}return evaluatedNode;});}}]);return Evaluator;}();_a=$lastValue;var $percentage=Symbol('percentage');var $basis=Symbol('basis');var PercentageEvaluator=/*#__PURE__*/function(_Evaluator){_inherits(PercentageEvaluator,_Evaluator);function PercentageEvaluator(percentage,basis){var _this2;_classCallCheck(this,PercentageEvaluator);_this2=_possibleConstructorReturn(this,_getPrototypeOf(PercentageEvaluator).call(this));_this2[$percentage]=percentage;_this2[$basis]=basis;return _this2;}_createClass(PercentageEvaluator,[{key:$evaluate,value:function value(){return numberNode(this[$percentage].number/100*this[$basis].number,this[$basis].unit);}},{key:"isConstant",get:function get(){return true;}}]);return PercentageEvaluator;}(Evaluator);var $identNode=Symbol('identNode');var EnvEvaluator=/*#__PURE__*/function(_Evaluator2){_inherits(EnvEvaluator,_Evaluator2);function EnvEvaluator(envFunction){var _this3;_classCallCheck(this,EnvEvaluator);_this3=_possibleConstructorReturn(this,_getPrototypeOf(EnvEvaluator).call(this));_this3[_b]=null;var identNode=envFunction.arguments.length?envFunction.arguments[0].terms[0]:null;if(identNode!=null&&identNode.type==='ident'){_this3[$identNode]=identNode;}return _this3;}_createClass(EnvEvaluator,[{key:(_b=$identNode,$evaluate),value:function value(){if(this[$identNode]!=null){switch(this[$identNode].value){case'window-scroll-y':var verticalScrollPosition=window.pageYOffset;var verticalScrollMax=Math.max(document.body.scrollHeight,document.body.offsetHeight,document.documentElement.clientHeight,document.documentElement.scrollHeight,document.documentElement.offsetHeight);var scrollY=verticalScrollPosition/(verticalScrollMax-window.innerHeight)||0;return{type:'number',number:scrollY,unit:null};}}return ZERO;}},{key:"isConstant",get:function get(){return false;}}]);return EnvEvaluator;}(Evaluator);var IS_MULTIPLICATION_RE=/[\*\/]/;var $evaluator=Symbol('evalutor');var CalcEvaluator=/*#__PURE__*/function(_Evaluator3){_inherits(CalcEvaluator,_Evaluator3);function CalcEvaluator(calcFunction){var _this4;var basis=arguments.length>1&&arguments[1]!==undefined?arguments[1]:ZERO;_classCallCheck(this,CalcEvaluator);_this4=_possibleConstructorReturn(this,_getPrototypeOf(CalcEvaluator).call(this));_this4[_c]=null;if(calcFunction.arguments.length!==1){return _possibleConstructorReturn(_this4);}var terms=calcFunction.arguments[0].terms.slice();var secondOrderTerms=[];while(terms.length){var term=terms.shift();if(secondOrderTerms.length>0){var previousTerm=secondOrderTerms[secondOrderTerms.length-1];if(previousTerm.type==='operator'&&IS_MULTIPLICATION_RE.test(previousTerm.value)){var operator=secondOrderTerms.pop();var leftValue=secondOrderTerms.pop();if(leftValue==null){return _possibleConstructorReturn(_this4);}secondOrderTerms.push(new OperatorEvaluator(operator,Evaluator.evaluatableFor(leftValue,basis),Evaluator.evaluatableFor(term,basis)));continue;}}secondOrderTerms.push(term.type==='operator'?term:Evaluator.evaluatableFor(term,basis));}while(secondOrderTerms.length>2){var _secondOrderTerms$spl=secondOrderTerms.splice(0,3),_secondOrderTerms$spl2=_slicedToArray(_secondOrderTerms$spl,3),left=_secondOrderTerms$spl2[0],_operator=_secondOrderTerms$spl2[1],right=_secondOrderTerms$spl2[2];if(_operator.type!=='operator'){return _possibleConstructorReturn(_this4);}secondOrderTerms.unshift(new OperatorEvaluator(_operator,Evaluator.evaluatableFor(left,basis),Evaluator.evaluatableFor(right,basis)));}if(secondOrderTerms.length===1){_this4[$evaluator]=secondOrderTerms[0];}return _this4;}_createClass(CalcEvaluator,[{key:(_c=$evaluator,$evaluate),value:function value(){return this[$evaluator]!=null?Evaluator.evaluate(this[$evaluator]):ZERO;}},{key:"isConstant",get:function get(){return this[$evaluator]==null||Evaluator.isConstant(this[$evaluator]);}}]);return CalcEvaluator;}(Evaluator);var $operator=Symbol('operator');var $left=Symbol('left');var $right=Symbol('right');var OperatorEvaluator=/*#__PURE__*/function(_Evaluator4){_inherits(OperatorEvaluator,_Evaluator4);function OperatorEvaluator(operator,left,right){var _this5;_classCallCheck(this,OperatorEvaluator);_this5=_possibleConstructorReturn(this,_getPrototypeOf(OperatorEvaluator).call(this));_this5[$operator]=operator;_this5[$left]=left;_this5[$right]=right;return _this5;}_createClass(OperatorEvaluator,[{key:$evaluate,value:function value(){var leftNode=normalizeUnit(Evaluator.evaluate(this[$left]));var rightNode=normalizeUnit(Evaluator.evaluate(this[$right]));var leftValue=leftNode.number,leftUnit=leftNode.unit;var rightValue=rightNode.number,rightUnit=rightNode.unit;if(rightUnit!=null&&leftUnit!=n