UNPKG

159 kBJavaScriptView Raw
1/*
2Copyright (c) 2017-present NAVER Corp.
3name: @egjs/view360
4license: MIT
5author: NAVER Corp.
6repository: https://github.com/naver/egjs-view360
7version: 3.6.1
8*/
9!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).eg=t.eg||{},t.eg.view360=e())}(this,function(){"use strict";var i="3.6.1",r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function a(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var u=function(){return(u=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function n(t,s,a,h){return new(a=a||Promise)(function(n,e){function i(t){try{o(h.next(t))}catch(t){e(t)}}function r(t){try{o(h.throw(t))}catch(t){e(t)}}function o(t){var e;t.done?n(t.value):((e=t.value)instanceof a?e:new a(function(t){t(e)})).then(i,r)}o((h=h.apply(t,s||[])).next())})}function o(n,i){var r,o,s,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},t={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,o&&(s=2&e[0]?o.return:e[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,e[1])).done)return s;switch(o=0,s&&(e=[2&e[0],s.value]),e[0]){case 0:case 1:s=e;break;case 4:return a.label++,{value:e[1],done:!1};case 5:a.label++,o=e[1],e=[0];continue;case 7:e=a.ops.pop(),a.trys.pop();continue;default:if(!(s=0<(s=a.trys).length&&s[s.length-1])&&(6===e[0]||2===e[0])){a=0;continue}if(3===e[0]&&(!s||e[1]>s[0]&&e[1]<s[3])){a.label=e[1];break}if(6===e[0]&&a.label<s[1]){a.label=s[1],s=e;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(e);break}s[2]&&a.ops.pop(),a.trys.pop();continue}e=i.call(n,a)}catch(t){e=[6,t],o=0}finally{r=s=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}function f(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],i=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function d(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,r,o=n.call(t),s=[];try{for(;(void 0===e||0<e--)&&!(i=o.next()).done;)s.push(i.value)}catch(t){r={error:t}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return s}(arguments[e]));return t}function c(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],i=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,r,o=n.call(t),s=[];try{for(;(void 0===e||0<e--)&&!(i=o.next()).done;)s.push(i.value)}catch(t){r={error:t}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return s}(arguments[e]));return t}function l(t){return void 0===t}var h=function(){function t(t,e){var n,i;if(this.eventType=t,this._canceled=!1,e)try{for(var r=c(Object.keys(e)),o=r.next();!o.done;o=r.next()){var s=o.value;this[s]=e[s]}}catch(t){n={error:t}}finally{try{o&&!o.done&&(i=r.return)&&i.call(r)}finally{if(n)throw n.error}}}var e=t.prototype;return e.stop=function(){this._canceled=!0},e.isCanceled=function(){return this._canceled},t}(),e=function(){function t(){this._eventHandler={}}var e=t.prototype;return e.trigger=function(e){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];var i=e instanceof h?e.eventType:e,i=s(this._eventHandler[i]||[]);return i.length<=0||(e instanceof h?(e.currentTarget=this,i.forEach(function(t){t(e)})):i.forEach(function(t){t.apply(void 0,s(n))})),this},e.once=function(n,i){var r,o=this;if("object"==typeof n&&l(i)){var t,e=n;for(t in e)this.once(t,e[t]);return this}return"string"==typeof n&&"function"==typeof i&&(r=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];i.apply(void 0,s(t)),o.off(n,r)},this.on(n,r)),this},e.hasOn=function(t){return!!this._eventHandler[t]},e.on=function(t,e){if("object"==typeof t&&l(e)){var n,i=t;for(n in i)this.on(n,i[n]);return this}var r;return"string"==typeof t&&"function"==typeof e&&(r=this._eventHandler[t],l(r)&&(this._eventHandler[t]=[],r=this._eventHandler[t]),r.push(e)),this},e.off=function(t,e){var n,i;if(l(t))return this._eventHandler={},this;if(l(e)){if("string"==typeof t)return delete this._eventHandler[t],this;var r,o=t;for(r in o)this.off(r,o[r]);return this}var s=this._eventHandler[t];if(s){var a=0;try{for(var h=c(s),u=h.next();!u.done;u=h.next()){if(u.value===e){s.splice(a,1),s.length<=0&&delete this._eventHandler[t];break}a++}}catch(t){n={error:t}}finally{try{u&&!u.done&&(i=h.return)&&i.call(h)}finally{if(n)throw n.error}}}return this},t.VERSION="3.0.1",t}(),p=h;var m=setTimeout;function v(t){return Boolean(t&&void 0!==t.length)}function g(){}function _(t){if(!(this instanceof _))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],R(t,this)}function y(n,i){for(;3===n._state;)n=n._value;0!==n._state?(n._handled=!0,_._immediateFn(function(){var t,e=1===n._state?i.onFulfilled:i.onRejected;if(null!==e){try{t=e(n._value)}catch(t){return void w(i.promise,t)}x(i.promise,t)}else(1===n._state?x:w)(i.promise,n._value)})):n._deferreds.push(i)}function x(e,t){try{if(t===e)throw new TypeError("A promise cannot be resolved with itself.");if(t&&("object"==typeof t||"function"==typeof t)){var n=t.then;if(t instanceof _)return e._state=3,e._value=t,void E(e);if("function"==typeof n)return void R((i=n,r=t,function(){i.apply(r,arguments)}),e)}e._state=1,e._value=t,E(e)}catch(t){w(e,t)}var i,r}function w(t,e){t._state=2,t._value=e,E(t)}function E(t){2===t._state&&0===t._deferreds.length&&_._immediateFn(function(){t._handled||_._unhandledRejectionFn(t._value)});for(var e=0,n=t._deferreds.length;e<n;e++)y(t,t._deferreds[e]);t._deferreds=null}function T(t,e,n){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=n}function R(t,e){var n=!1;try{t(function(t){n||(n=!0,x(e,t))},function(t){n||(n=!0,w(e,t))})}catch(t){if(n)return;n=!0,w(e,t)}}function b(t,e){for(var n=t.length,i=0;i<n;++i)if(e(t[i],i))return!0;return!1}function C(t,e){for(var n=t.length,i=0;i<n;++i)if(e(t[i],i))return t[i];return null}function P(t,e){try{return new RegExp(t,"g").exec(e)}catch(t){return null}}function I(t){return t.replace(/_/g,".")}function A(t,n){var i=null,r="-1";return b(t,function(t){var e=P("("+t.test+")((?:\\/|\\s|:)([0-9|\\.|_]+))?",n);return e&&!t.brand&&(i=t,r=e[3]||"-1",t.versionAlias?r=t.versionAlias:t.versionTest&&(t=t.versionTest.toLowerCase(),r=((t=P("("+t+")((?:\\/|\\s|:)([0-9|\\.|_]+))?",t=n))?t[3]:"")||r),r=I(r),1)}),{preset:i,version:r}}function S(t,e){return C(t,function(t){t=t.brand;return P(""+e.test,t.toLowerCase())})}_.prototype.catch=function(t){return this.then(null,t)},_.prototype.then=function(t,e){var n=new this.constructor(g);return y(this,new T(t,e,n)),n},_.prototype.finally=function(e){var n=this.constructor;return this.then(function(t){return n.resolve(e()).then(function(){return t})},function(t){return n.resolve(e()).then(function(){return n.reject(t)})})},_.all=function(e){return new _(function(r,o){if(!v(e))return o(new TypeError("Promise.all accepts an array"));var s=Array.prototype.slice.call(e);if(0===s.length)return r([]);var a=s.length;for(var t=0;t<s.length;t++)!function e(n,t){try{if(t&&("object"==typeof t||"function"==typeof t)){var i=t.then;if("function"==typeof i)return void i.call(t,function(t){e(n,t)},o)}s[n]=t,0==--a&&r(s)}catch(t){o(t)}}(t,s[t])})},_.allSettled=function(n){return new this(function(r,t){if(!n||void 0===n.length)return t(new TypeError(typeof n+" "+n+" is not iterable(cannot read property Symbol(Symbol.iterator))"));var o=Array.prototype.slice.call(n);if(0===o.length)return r([]);var s=o.length;for(var e=0;e<o.length;e++)!function e(n,t){if(t&&("object"==typeof t||"function"==typeof t)){var i=t.then;if("function"==typeof i)return void i.call(t,function(t){e(n,t)},function(t){o[n]={status:"rejected",reason:t},0==--s&&r(o)})}o[n]={status:"fulfilled",value:t},0==--s&&r(o)}(e,o[e])})},_.resolve=function(e){return e&&"object"==typeof e&&e.constructor===_?e:new _(function(t){t(e)})},_.reject=function(n){return new _(function(t,e){e(n)})},_.race=function(r){return new _(function(t,e){if(!v(r))return e(new TypeError("Promise.race accepts an array"));for(var n=0,i=r.length;n<i;n++)_.resolve(r[n]).then(t,e)})},_._immediateFn="function"==typeof setImmediate?function(t){setImmediate(t)}:function(t){m(t,0)},_._unhandledRejectionFn=function(t){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",t)};var O=[{test:"phantomjs",id:"phantomjs"},{test:"whale",id:"whale"},{test:"edgios|edge|edg",id:"edge"},{test:"msie|trident|windows phone",id:"ie",versionTest:"iemobile|msie|rv"},{test:"miuibrowser",id:"miui browser"},{test:"samsungbrowser",id:"samsung internet"},{test:"samsung",id:"samsung internet",versionTest:"version"},{test:"chrome|crios",id:"chrome"},{test:"firefox|fxios",id:"firefox"},{test:"android",id:"android browser",versionTest:"version"},{test:"safari|iphone|ipad|ipod",id:"safari",versionTest:"version"}],M=[{test:"(?=.*applewebkit/(53[0-7]|5[0-2]|[0-4]))(?=.*\\schrome)",id:"chrome"},{test:"chromium",id:"chrome"},{test:"whale",id:"chrome",brand:!0}],D=[{test:"applewebkit",id:"webkit"}],F=[{test:"(?=(iphone|ipad))(?!(.*version))",id:"webview"},{test:"(?=(android|iphone|ipad))(?=.*(naver|daum|; wv))",id:"webview"},{test:"webview",id:"webview"}],V=[{test:"windows phone",id:"windows phone"},{test:"windows 2000",id:"window",versionAlias:"5.0"},{test:"windows nt",id:"window"},{test:"iphone|ipad|ipod",id:"ios",versionTest:"iphone os|cpu os"},{test:"mac os x",id:"mac"},{test:"android",id:"android"},{test:"tizen",id:"tizen"},{test:"webos|web0s",id:"webos"}];function L(t){var e=function(t){if(void 0===t){if("undefined"==typeof navigator||!navigator)return"";t=navigator.userAgent||""}return t.toLowerCase()}(t),n=!!/mobi/g.exec(e),i={name:"unknown",version:"-1",majorVersion:-1,webview:!!A(F,e).preset,chromium:!!A(M,e).preset,webkit:!1},r={name:"unknown",version:"-1",majorVersion:-1},o=A(O,e),s=o.preset,a=o.version,t=A(V,e),o=t.preset,t=t.version;return i.webkit=!i.chromium&&!!A(D,e).preset,o&&(r.name=o.id,r.version=t,r.majorVersion=parseInt(t,10)),s&&(i.name=s.id,i.version=a,i.webview&&"ios"===r.name&&"safari"!==i.name&&(i.webview=!1)),i.majorVersion=parseInt(i.version,10),{browser:i,os:r,isMobile:n,isHints:!1}}function N(t){return void 0===t&&function(){if("undefined"!=typeof navigator&&navigator&&navigator.userAgentData){var t=navigator.userAgentData,t=t.brands||t.uaList;return t&&t.length}}()?(i=((a=navigator.userAgentData).uaList||a.brands).slice(),r=a.mobile||!1,o=i[0],s={name:o.brand,version:o.version,majorVersion:-1,webkit:!1,webview:b(F,function(t){return S(i,t)}),chromium:b(M,function(t){return S(i,t)})},a={name:"unknown",version:"-1",majorVersion:-1},s.webkit=!s.chromium&&b(D,function(t){return S(i,t)}),n&&(e=n.platform.toLowerCase(),o=C(V,function(t){return new RegExp(""+t.test,"g").exec(e)}),a.name=o?o.id:e,a.version=n.platformVersion),b(O,function(t){var e=S(i,t);return e&&(s.name=t.id,s.version=n?n.uaFullVersion:e.version,1)}),"Linux armv8l"===navigator.platform?a.name="android":s.webkit&&(a.name=r?"ios":"mac"),"ios"===a.name&&s.webview&&(s.version="-1"),a.version=I(a.version),s.version=I(s.version),a.majorVersion=parseInt(a.version,10),s.majorVersion=parseInt(s.version,10),{browser:s,os:a,isMobile:r,isHints:!0}):L(t);var n,e,i,r,o,s,a}var U="undefined"!=typeof window&&window.Math===Math?window:"undefined"!=typeof self&&self.Math===Math?self:Function("return this")(),k=U.document,z=U.navigator,t=N(),Q=t.os.name,W=t.browser.name,X="ios"===Q,Y="mac"===Q&&"safari"===W;U.Float32Array=void 0!==U.Float32Array?U.Float32Array:U.Array;U.Float32Array,U.getComputedStyle;var j=U.navigator&&U.navigator.userAgent,B="ontouchstart"in U,H="ondevicemotion"in U,G=U.DeviceMotionEvent,q=U.devicePixelRatio,K=function(){for(var t,e=null!==(t=null==k?void 0:k.documentElement.style)&&void 0!==t?t:{},n=["transform","webkitTransform","msTransform","mozTransform"],i=0,r=n.length;i<r;i++)if(n[i]in e)return n[i];return""}(),Z=U.CSS&&U.CSS.supports&&U.CSS.supports("will-change","transform"),J=!1,$=function(){var t=window.navigator;t.xr&&(t.xr.isSessionSupported?t.xr.isSessionSupported("immersive-vr").then(function(t){J=t}).catch(function(){}):t.xr.supportsSession&&t.xr.supportsSession("immersive-vr").then(function(t){J=t}).catch(function(){}))};function tt(){return(tt=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n,i=arguments[e];for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t}).apply(this,arguments)}function et(t,e){t.prototype=Object.create(e.prototype),(t.prototype.constructor=t).__proto__=e}function nt(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var it,rt="function"!=typeof Object.assign?function(t){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n<arguments.length;n++){var i=arguments[n];if(null!=i)for(var r in i)i.hasOwnProperty(r)&&(e[r]=i[r])}return e}:Object.assign,ot=["","webkit","Moz","MS","ms","o"],st="undefined"==typeof document?{style:{}}:document.createElement("div"),at="function",ht=Math.round,ut=Math.abs,ct=Date.now;function lt(t,e){for(var n,i=e[0].toUpperCase()+e.slice(1),r=0;r<ot.length;){if((n=(n=ot[r])?n+i:e)in t)return n;r++}}it="undefined"==typeof window?{}:window;var ft=lt(st.style,"touchAction"),dt=void 0!==ft;var pt="compute",mt="manipulation",vt="none",gt="pan-x",_t="pan-y",yt=function(){if(!dt)return!1;var e={},n=it.CSS&&it.CSS.supports;return["auto","manipulation","pan-y","pan-x","pan-x pan-y","none"].forEach(function(t){return e[t]=!n||it.CSS.supports("touch-action",t)}),e}(),xt="ontouchstart"in it,wt=void 0!==lt(it,"PointerEvent"),Et=xt&&/mobile|tablet|ip(ad|hone|od)|android/i.test(navigator.userAgent),Tt="touch",Rt="mouse",bt=25,Ct=1,Pt=4,It=8,At=1,St=2,Ot=4,Mt=8,Dt=16,Ft=St|Ot,Vt=Mt|Dt,Lt=Ft|Vt,Nt=["x","y"],Ut=["clientX","clientY"];function kt(t,e,n){if(t)if(t.forEach)t.forEach(e,n);else if(void 0!==t.length)for(i=0;i<t.length;)e.call(n,t[i],i,t),i++;else for(var i in t)t.hasOwnProperty(i)&&e.call(n,t[i],i,t)}function zt(t,e){return typeof t===at?t.apply(e&&e[0]||void 0,e):t}function Qt(t,e){return-1<t.indexOf(e)}var Wt=function(){function t(t,e){this.manager=t,this.set(e)}var e=t.prototype;return e.set=function(t){t===pt&&(t=this.compute()),dt&&this.manager.element.style&&yt[t]&&(this.manager.element.style[ft]=t),this.actions=t.toLowerCase().trim()},e.update=function(){this.set(this.manager.options.touchAction)},e.compute=function(){var e=[];return kt(this.manager.recognizers,function(t){zt(t.options.enable,[t])&&(e=e.concat(t.getTouchAction()))}),function(t){if(Qt(t,vt))return vt;var e=Qt(t,gt),n=Qt(t,_t);return e&&n?vt:e||n?e?gt:_t:Qt(t,mt)?mt:"auto"}(e.join(" "))},e.preventDefaults=function(t){var e=t.srcEvent,n=t.offsetDirection;if(this.manager.session.prevented)e.preventDefault();else{var i=this.actions,r=Qt(i,vt)&&!yt[vt],o=Qt(i,_t)&&!yt[_t],s=Qt(i,gt)&&!yt[gt];if(r){var a=1===t.pointers.length,i=t.distance<2,t=t.deltaTime<250;if(a&&i&&t)return}if(!s||!o)return r||o&&n&Ft||s&&n&Vt?this.preventSrc(e):void 0}},e.preventSrc=function(t){this.manager.session.prevented=!0,t.preventDefault()},t}();function Xt(t,e){for(;t;){if(t===e)return!0;t=t.parentNode}return!1}function Yt(t){var e=t.length;if(1===e)return{x:ht(t[0].clientX),y:ht(t[0].clientY)};for(var n=0,i=0,r=0;r<e;)n+=t[r].clientX,i+=t[r].clientY,r++;return{x:ht(n/e),y:ht(i/e)}}function jt(t){for(var e=[],n=0;n<t.pointers.length;)e[n]={clientX:ht(t.pointers[n].clientX),clientY:ht(t.pointers[n].clientY)},n++;return{timeStamp:ct(),pointers:e,center:Yt(e),deltaX:t.deltaX,deltaY:t.deltaY}}function Bt(t,e,n){var i=e[(n=n||Nt)[0]]-t[n[0]],n=e[n[1]]-t[n[1]];return Math.sqrt(i*i+n*n)}function Ht(t,e,n){var i=e[(n=n||Nt)[0]]-t[n[0]],n=e[n[1]]-t[n[1]];return 180*Math.atan2(n,i)/Math.PI}function Gt(t,e){return t===e?At:ut(t)>=ut(e)?t<0?St:Ot:e<0?Mt:Dt}function qt(t,e,n){return{x:e/t||0,y:n/t||0}}function Kt(t,e){var n=t.session,i=e.pointers,r=i.length;n.firstInput||(n.firstInput=jt(e)),1<r&&!n.firstMultiple?n.firstMultiple=jt(e):1===r&&(n.firstMultiple=!1);var o,s,a=n.firstInput,h=n.firstMultiple,u=(h||a).center,c=e.center=Yt(i);e.timeStamp=ct(),e.deltaTime=e.timeStamp-a.timeStamp,e.angle=Ht(u,c),e.distance=Bt(u,c),o=n,r=(s=e).center,a=o.offsetDelta||{},u=o.prevDelta||{},c=o.prevInput||{},s.eventType!==Ct&&c.eventType!==Pt||(u=o.prevDelta={x:c.deltaX||0,y:c.deltaY||0},a=o.offsetDelta={x:r.x,y:r.y}),s.deltaX=u.x+(r.x-a.x),s.deltaY=u.y+(r.y-a.y),e.offsetDirection=Gt(e.deltaX,e.deltaY);var l,f,d,p,m,r=qt(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=r.x,e.overallVelocityY=r.y,e.overallVelocity=ut(r.x)>ut(r.y)?r.x:r.y,e.scale=h?(a=h.pointers,Bt((r=i)[0],r[1],Ut)/Bt(a[0],a[1],Ut)):1,e.rotation=h?(m=h.pointers,Ht((l=i)[1],l[0],Ut)+Ht(m[1],m[0],Ut)):0,e.maxPointers=!n.prevInput||e.pointers.length>n.prevInput.maxPointers?e.pointers.length:n.prevInput.maxPointers,i=e,m=(l=n).lastInterval||i,n=i.timeStamp-m.timeStamp,i.eventType!==It&&(bt<n||void 0===m.velocity)?(f=(p=qt(n,n=i.deltaX-m.deltaX,v=i.deltaY-m.deltaY)).x,d=p.y,p=ut(p.x)>ut(p.y)?p.x:p.y,v=Gt(n,v),l.lastInterval=i):(p=m.velocity,f=m.velocityX,d=m.velocityY,v=m.direction),i.velocity=p,i.velocityX=f,i.velocityY=d,i.direction=v;var v=t.element,t=e.srcEvent,t=t.composedPath?t.composedPath()[0]:t.path?t.path[0]:t.target;Xt(t,v)&&(v=t),e.target=v}function Zt(t,e,n){var i=n.pointers.length,r=n.changedPointers.length,o=e&Ct&&i-r==0,r=e&(Pt|It)&&i-r==0;n.isFirst=!!o,n.isFinal=!!r,o&&(t.session={}),n.eventType=e,Kt(t,n),t.emit("hammer.input",n),t.recognize(n),t.session.prevInput=n}function Jt(t){return t.trim().split(/\s+/g)}function $t(e,t,n){kt(Jt(t),function(t){e.addEventListener(t,n,!1)})}function te(e,t,n){kt(Jt(t),function(t){e.removeEventListener(t,n,!1)})}function ee(t){t=t.ownerDocument||t;return t.defaultView||t.parentWindow||window}var ne=function(){function t(e,t){var n=this;this.manager=e,this.callback=t,this.element=e.element,this.target=e.options.inputTarget,this.domHandler=function(t){zt(e.options.enable,[e])&&n.handler(t)},this.init()}var e=t.prototype;return e.handler=function(){},e.init=function(){this.evEl&&$t(this.element,this.evEl,this.domHandler),this.evTarget&&$t(this.target,this.evTarget,this.domHandler),this.evWin&&$t(ee(this.element),this.evWin,this.domHandler)},e.destroy=function(){this.evEl&&te(this.element,this.evEl,this.domHandler),this.evTarget&&te(this.target,this.evTarget,this.domHandler),this.evWin&&te(ee(this.element),this.evWin,this.domHandler)},t}();function ie(t,e,n){if(t.indexOf&&!n)return t.indexOf(e);for(var i=0;i<t.length;){if(n&&t[i][n]==e||!n&&t[i]===e)return i;i++}return-1}var re={pointerdown:Ct,pointermove:2,pointerup:Pt,pointercancel:It,pointerout:It},oe={2:Tt,3:"pen",4:Rt,5:"kinect"},se="pointerdown",ae="pointermove pointerup pointercancel";it.MSPointerEvent&&!it.PointerEvent&&(se="MSPointerDown",ae="MSPointerMove MSPointerUp MSPointerCancel");var he=function(e){function n(){var t=n.prototype;return t.evEl=se,t.evWin=ae,(t=e.apply(this,arguments)||this).store=t.manager.session.pointerEvents=[],t}return et(n,e),n.prototype.handler=function(t){var e=this.store,n=!1,i=t.type.toLowerCase().replace("ms",""),r=re[i],o=oe[t.pointerType]||t.pointerType,s=o===Tt,i=ie(e,t.pointerId,"pointerId");r&Ct&&(0===t.button||s)?i<0&&(e.push(t),i=e.length-1):r&(Pt|It)&&(n=!0),i<0||(e[i]=t,this.callback(this.manager,r,{pointers:e,changedPointers:[t],pointerType:o,srcEvent:t}),n&&e.splice(i,1))},n}(ne);function ue(t){return Array.prototype.slice.call(t,0)}var ce={touchstart:Ct,touchmove:2,touchend:Pt,touchcancel:It},le="touchstart touchmove touchend touchcancel",fe=function(e){function n(){var t;return n.prototype.evTarget=le,(t=e.apply(this,arguments)||this).targetIds={},t}return et(n,e),n.prototype.handler=function(t){var e=ce[t.type],n=function(t,e){var n,i,r=ue(t.touches),o=this.targetIds;if(e&(2|Ct)&&1===r.length)return o[r[0].identifier]=!0,[r,r];var s=ue(t.changedTouches),a=[],h=this.target;if(i=r.filter(function(t){return Xt(t.target,h)}),e===Ct)for(n=0;n<i.length;)o[i[n].identifier]=!0,n++;n=0;for(;n<s.length;)o[s[n].identifier]&&a.push(s[n]),e&(Pt|It)&&delete o[s[n].identifier],n++;return a.length?[function(t,n,e){for(var i=[],r=[],o=0;o<t.length;){var s=n?t[o][n]:t[o];ie(r,s)<0&&i.push(t[o]),r[o]=s,o++}return e&&(i=n?i.sort(function(t,e){return t[n]>e[n]}):i.sort()),i}(i.concat(a),"identifier",!0),a]:void 0}.call(this,t,e);n&&this.callback(this.manager,e,{pointers:n[0],changedPointers:n[1],pointerType:Tt,srcEvent:t})},n}(ne);var de={mousedown:Ct,mousemove:2,mouseup:Pt},pe="mousedown",me="mousemove mouseup",ve=function(e){function n(){var t=n.prototype;return t.evEl=pe,t.evWin=me,(t=e.apply(this,arguments)||this).pressed=!1,t}return et(n,e),n.prototype.handler=function(t){var e=de[t.type];e&Ct&&0===t.button&&(this.pressed=!0),2&e&&1!==t.which&&(e=Pt),this.pressed&&(e&Pt&&(this.pressed=!1),this.callback(this.manager,e,{pointers:[t],changedPointers:[t],pointerType:Rt,srcEvent:t}))},n}(ne),ge=2500,_e=25;function ye(t){var e,n,t=t.changedPointers[0];t.identifier===this.primaryTouch&&(e={x:t.clientX,y:t.clientY},n=this.lastTouches,this.lastTouches.push(e),setTimeout(function(){var t=n.indexOf(e);-1<t&&n.splice(t,1)},ge))}var xe=function(){return function(n){function t(t,e){var o=n.call(this,t,e)||this;return o.handler=function(t,e,n){var i=n.pointerType===Tt,r=n.pointerType===Rt;if(!(r&&n.sourceCapabilities&&n.sourceCapabilities.firesTouchEvents)){if(i)(function(t,e){t&Ct?(this.primaryTouch=e.changedPointers[0].identifier,ye.call(this,e)):t&(Pt|It)&&ye.call(this,e)}).call(nt(nt(o)),e,n);else if(r&&function(t){for(var e=t.srcEvent.clientX,n=t.srcEvent.clientY,i=0;i<this.lastTouches.length;i++){var r=this.lastTouches[i],o=Math.abs(e-r.x),r=Math.abs(n-r.y);if(o<=_e&&r<=_e)return!0}return!1}.call(nt(nt(o)),n))return;o.callback(t,e,n)}},o.touch=new fe(o.manager,o.handler),o.mouse=new ve(o.manager,o.handler),o.primaryTouch=null,o.lastTouches=[],o}return et(t,n),t.prototype.destroy=function(){this.touch.destroy(),this.mouse.destroy()},t}(ne)}();function we(t,e,n){return Array.isArray(t)&&(kt(t,n[e],n),1)}var Ee=1;function Te(t,e){e=e.manager;return e?e.get(t):t}function Re(t){return 16&t?"cancel":8&t?"end":4&t?"move":2&t?"start":""}var be=function(){function t(t){void 0===t&&(t={}),this.options=tt({enable:!0},t),this.id=Ee++,this.manager=null,this.state=1,this.simultaneous={},this.requireFail=[]}var e=t.prototype;return e.set=function(t){return rt(this.options,t),this.manager&&this.manager.touchAction.update(),this},e.recognizeWith=function(t){if(we(t,"recognizeWith",this))return this;var e=this.simultaneous;return e[(t=Te(t,this)).id]||(e[t.id]=t).recognizeWith(this),this},e.dropRecognizeWith=function(t){return we(t,"dropRecognizeWith",this)||(t=Te(t,this),delete this.simultaneous[t.id]),this},e.requireFailure=function(t){if(we(t,"requireFailure",this))return this;var e=this.requireFail;return-1===ie(e,t=Te(t,this))&&(e.push(t),t.requireFailure(this)),this},e.dropRequireFailure=function(t){if(we(t,"dropRequireFailure",this))return this;t=Te(t,this);t=ie(this.requireFail,t);return-1<t&&this.requireFail.splice(t,1),this},e.hasRequireFailures=function(){return 0<this.requireFail.length},e.canRecognizeWith=function(t){return!!this.simultaneous[t.id]},e.emit=function(e){var n=this,t=this.state;function i(t){n.manager.emit(t,e)}t<8&&i(n.options.event+Re(t)),i(n.options.event),e.additionalEvent&&i(e.additionalEvent),8<=t&&i(n.options.event+Re(t))},e.tryEmit=function(t){if(this.canEmit())return this.emit(t);this.state=32},e.canEmit=function(){for(var t=0;t<this.requireFail.length;){if(!(33&this.requireFail[t].state))return!1;t++}return!0},e.recognize=function(t){t=rt({},t);if(!zt(this.options.enable,[this,t]))return this.reset(),void(this.state=32);56&this.state&&(this.state=1),this.state=this.process(t),30&this.state&&this.tryEmit(t)},e.process=function(){},e.getTouchAction=function(){},e.reset=function(){},t}(),Ce=function(e){function t(t){return void 0===t&&(t={}),e.call(this,tt({pointers:1},t))||this}et(t,e);var n=t.prototype;return n.attrTest=function(t){var e=this.options.pointers;return 0===e||t.pointers.length===e},n.process=function(t){var e=this.state,n=t.eventType,i=6&e,t=this.attrTest(t);return i&&(n&It||!t)?16|e:i||t?n&Pt?8|e:2&e?4|e:2:32},t}(be);var Pe=function(n){function t(t){return void 0===t&&(t={}),(t=n.call(this,tt({event:"pan",threshold:10,pointers:1,direction:Lt},t))||this).pX=null,t.pY=null,t}et(t,n);var e=t.prototype;return e.getTouchAction=function(){var t=this.options.direction,e=[];return t&Ft&&e.push(_t),t&Vt&&e.push(gt),e},e.directionTest=function(t){var e=this.options,n=!0,i=t.distance,r=t.direction,o=t.deltaX,s=t.deltaY;return r&e.direction||(i=e.direction&Ft?(r=0===o?At:o<0?St:Ot,n=o!==this.pX,Math.abs(t.deltaX)):(r=0===s?At:s<0?Mt:Dt,n=s!==this.pY,Math.abs(t.deltaY))),t.direction=r,n&&i>e.threshold&&r&e.direction},e.attrTest=function(t){return Ce.prototype.attrTest.call(this,t)&&(2&this.state||!(2&this.state)&&this.directionTest(t))},e.emit=function(t){this.pX=t.deltaX,this.pY=t.deltaY;var e,e=(e=t.direction)===Dt?"down":e===Mt?"up":e===St?"left":e===Ot?"right":"";e&&(t.additionalEvent=this.options.event+e),n.prototype.emit.call(this,t)},t}(Ce),Ie=function(n){function t(t){return void 0===t&&(t={}),n.call(this,tt({event:"pinch",threshold:0,pointers:2},t))||this}et(t,n);var e=t.prototype;return e.getTouchAction=function(){return[vt]},e.attrTest=function(t){return n.prototype.attrTest.call(this,t)&&(Math.abs(t.scale-1)>this.options.threshold||2&this.state)},e.emit=function(t){var e;1!==t.scale&&(e=t.scale<1?"in":"out",t.additionalEvent=this.options.event+e),n.prototype.emit.call(this,t)},t}(Ce),Ae={domEvents:!1,touchAction:pt,enable:!0,inputTarget:null,inputClass:null,cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};function Se(n,i){var r,o=n.element;o.style&&(kt(n.options.cssProps,function(t,e){r=lt(o.style,e),i?(n.oldCssProps[r]=o.style[r],o.style[r]=t):o.style[r]=n.oldCssProps[r]||""}),i||(n.oldCssProps={}))}var Oe=function(){function t(t,e){var n=this;this.options=rt({},Ae,e||{}),this.options.inputTarget=this.options.inputTarget||t,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=t,this.input=new((t=this).options.inputClass||(wt?he:Et?fe:xt?xe:ve))(t,Zt),this.touchAction=new Wt(this,this.options.touchAction),Se(this,!0),kt(this.options.recognizers,function(t){var e=n.add(new t[0](t[1]));t[2]&&e.recognizeWith(t[2]),t[3]&&e.requireFailure(t[3])},this)}var e=t.prototype;return e.set=function(t){return rt(this.options,t),t.touchAction&&this.touchAction.update(),t.inputTarget&&(this.input.destroy(),this.input.target=t.inputTarget,this.input.init()),this},e.stop=function(t){this.session.stopped=t?2:1},e.recognize=function(t){var e,n=this.session;if(!n.stopped){this.touchAction.preventDefaults(t);var i=this.recognizers,r=n.curRecognizer;(!r||r&&8&r.state)&&(r=n.curRecognizer=null);for(var o=0;o<i.length;)e=i[o],2===n.stopped||r&&e!==r&&!e.canRecognizeWith(r)?e.reset():e.recognize(t),!r&&14&e.state&&(r=n.curRecognizer=e),o++}},e.get=function(t){if(t instanceof be)return t;for(var e=this.recognizers,n=0;n<e.length;n++)if(e[n].options.event===t)return e[n];return null},e.add=function(t){if(we(t,"add",this))return this;var e=this.get(t.options.event);return e&&this.remove(e),this.recognizers.push(t),(t.manager=this).touchAction.update(),t},e.remove=function(t){if(we(t,"remove",this))return this;var e=this.get(t);return!t||-1!==(e=ie(t=this.recognizers,e))&&(t.splice(e,1),this.touchAction.update()),this},e.on=function(t,e){if(void 0===t||void 0===e)return this;var n=this.handlers;return kt(Jt(t),function(t){n[t]=n[t]||[],n[t].push(e)}),this},e.off=function(t,e){if(void 0===t)return this;var n=this.handlers;return kt(Jt(t),function(t){e?n[t]&&n[t].splice(ie(n[t],e),1):delete n[t]}),this},e.emit=function(t,e){var n,i,r;this.options.domEvents&&(n=t,i=e,(r=document.createEvent("Event")).initEvent(n,!0,!0),(r.gesture=i).target.dispatchEvent(r));var o=this.handlers[t]&&this.handlers[t].slice();if(o&&o.length){e.type=t,e.preventDefault=function(){e.srcEvent.preventDefault()};for(var s=0;s<o.length;)o[s](e),s++}},e.destroy=function(){this.element&&Se(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null},t}();function Me(t){return void 0===t}var t=function(){function t(){this.options={},this._eventHandler={}}var e=t.prototype;return e.trigger=function(t){for(var e=this,n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];if(!(0<(s=this._eventHandler[t]||[]).length))return!0;var r=n[0]||{},o=n.slice(1),s=s.concat(),a=!1;r.eventType=t,r.stop=function(){a=!0},r.currentTarget=this;var h=[r];return 1<=o.length&&(h=h.concat(o)),s.forEach(function(t){t.apply(e,h)}),!a},e.once=function(n,i){var r,o=this;if("object"==typeof n&&Me(i)){var t,e=n;for(t in e)this.once(t,e[t]);return this}return"string"==typeof n&&"function"==typeof i&&(r=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];i.apply(o,t),o.off(n,r)},this.on(n,r)),this},e.hasOn=function(t){return!!this._eventHandler[t]},e.on=function(t,e){if("object"==typeof t&&Me(e)){var n,i=t;for(n in i)this.on(n,i[n]);return this}var r;return"string"==typeof t&&"function"==typeof e&&(Me(r=this._eventHandler[t])&&(this._eventHandler[t]=[],r=this._eventHandler[t]),r.push(e)),this},e.off=function(t,e){var n,i;if(Me(t))return this._eventHandler={},this;if(Me(e)){if("string"==typeof t)return delete this._eventHandler[t],this;var r,o=t;for(r in o)this.off(r,o[r]);return this}var s=this._eventHandler[t];if(s){var a=0;try{for(var h=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],i=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(s),u=h.next();!u.done;u=h.next()){if(u.value===e){s.splice(a,1);break}a++}}catch(t){n={error:t}}finally{try{u&&!u.done&&(i=h.return)&&i.call(h)}finally{if(n)throw n.error}}}return this},t.VERSION="2.2.2",t}(),De=function(t,e){return(De=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var Fe,Ve=function(){return(Ve=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function Le(t,e,n,i){e=[!n[0]&&i?e[0]-i[0]:e[0],!n[1]&&i?e[1]+i[1]:e[1]],t=Math.max(e[0],t);return t=Math.min(e[1],t)}function Ne(t,e){return t<e[0]||t>e[1]}function Ue(t,e,n){return n[1]&&t>e[1]||n[0]&&t<e[0]}function ke(t,e,n){var i=t,r=e[0],o=e[1],e=o-r;return n[1]&&o<t&&(i=(i-o)%e+r),n[0]&&t<r&&(i=(i-r)%e+o),i}function ze(t){for(var e=[],n=0,i=t.length;n<i;n++)e.push(t[n]);return e}function Qe(t,e){var n;return void 0===e&&(e=!1),"string"==typeof t?(n=t.match(/^<([a-z]+)\s*([^>]*)>/)?((n=document.createElement("div")).innerHTML=t,ze(n.childNodes)):ze(document.querySelectorAll(t)),e||(n=1<=n.length?n[0]:void 0)):t!==Fe&&(!t.nodeName||1!==t.nodeType&&9!==t.nodeType)?"jQuery"in Fe&&t instanceof jQuery||t.constructor.prototype.jquery?n=e?t.toArray():t.get(0):Array.isArray(t)&&(n=t.map(function(t){return Qe(t)}),e||(n=1<=n.length?n[0]:void 0)):n=t,n}var We,Xe,Ye=(Fe="undefined"==typeof window?{navigator:{userAgent:""}}:window).requestAnimationFrame||Fe.webkitRequestAnimationFrame,je=Fe.cancelAnimationFrame||Fe.webkitCancelAnimationFrame;function Be(t,e){var n,i={};for(n in t)n&&(i[n]=e(t[n],n));return i}function He(t,e){var n,i={};for(n in t)n&&e(t[n],n)&&(i[n]=t[n]);return i}function Ge(t,e){for(var n in t)if(n&&!e(t[n],n))return!1;return!0}function qe(t,n){return Ge(t,function(t,e){return t===n[e]})}Ye&&!je?(We={},Xe=Ye,Ye=function(e){var n=Xe(function(t){We[n]&&e(t)});return We[n]=!0,n},je=function(t){delete We[t]}):Ye&&je||(Ye=function(t){return Fe.setTimeout(function(){t(Fe.performance&&Fe.performance.now&&Fe.performance.now()||(new Date).getTime())},16)},je=Fe.clearTimeout);var Ke={};function Ze(t,e){var n,i;return Ke[e]||(Ke[e]=(i=(n=e)<1?Math.pow(10,$e(n)):1,function(t){return 0===n?0:Math.round(Math.round(t/n)*n*i)/i})),Ke[e](t)}function Je(t,n){if(!t||!n)return t;var i="number"==typeof n;return Be(t,function(t,e){return Ze(t,i?n:n[e])})}function $e(t){if(!isFinite(t))return 0;var e=t+"";if(0<=e.indexOf("e")){for(var n=0,i=1;Math.round(t*i)/i!==t;)i*=10,n++;return n}return 0<=e.indexOf(".")?e.length-e.indexOf(".")-1:0}function tn(t,e,n){return Math.max(Math.min(t,n),e)}var en=function(){function t(t){var e=t.options,n=t.itm,i=t.em,t=t.axm;this.options=e,this.itm=n,this.em=i,this.axm=t,this.animationEnd=this.animationEnd.bind(this)}var e=t.prototype;return e.getDuration=function(n,t,e){var i,r=this;return tn(void 0!==e?e:(i=Be(t,function(t,e){return t=Math.abs(t-n[e]),e=r.options.deceleration,(e=Math.sqrt(t/e*2))<100?0:e}),Object.keys(i).reduce(function(t,e){return Math.max(t,i[e])},-1/0)),this.options.minimumDuration,this.options.maximumDuration)},e.createAnimationParam=function(t,e,n){var i=this.axm.get(),r=t,t=n&&n.event||null;return{depaPos:i,destPos:r,duration:tn(e,this.options.minimumDuration,this.options.maximumDuration),delta:this.axm.getDelta(i,r),inputEvent:t,input:n&&n.input||null,isTrusted:!!t,done:this.animationEnd}},e.grab=function(t,e){var n;this._animateParam&&t.length&&(n=this.axm.get(t),Ge(t=this.axm.map(n,function(t,e){return ke(t,e.range,e.circular)}),function(t,e){return n[e]===t})||this.em.triggerChange(t,!1,n,e,!!e),this._animateParam=null,this._raf&&(t=this._raf,je(t)),this._raf=null,this.em.triggerAnimationEnd(!(!e||!e.event)))},e.getEventInfo=function(){return this._animateParam&&this._animateParam.input&&this._animateParam.inputEvent?{input:this._animateParam.input,event:this._animateParam.inputEvent}:null},e.restore=function(t){var e=this.axm.get(),n=this.axm.map(e,function(t,e){return Math.min(e.range[1],Math.max(e.range[0],t))});this.animateTo(n,this.getDuration(e,n),t)},e.animationEnd=function(){var t=this.getEventInfo();this._animateParam=null;var e=this.axm.filter(this.axm.get(),function(t,e){return Ue(t,e.range,e.circular)});0<Object.keys(e).length&&this.setTo(this.axm.map(e,function(t,e){return ke(t,e.range,e.circular)})),this.itm.setInterrupt(!1),this.em.triggerAnimationEnd(!!t),this.axm.isOutside()?this.restore(t):this.finish(!!t)},e.finish=function(t){this._animateParam=null,this.itm.setInterrupt(!1),this.em.triggerFinish(t)},e.animateLoop=function(s,a){var h,u,c,l,f,d,p,m;s.duration?(this._animateParam=Ve({},s),h=this._animateParam,u=this,c=h.destPos,l=h.depaPos,f=0,d=Be(l,function(t,e){return t<=c[e]?1:-1}),p=Be(c,function(t){return t}),m=(new Date).getTime(),h.startTime=m,function t(){u._raf=null;var e=(new Date).getTime(),r=(e-h.startTime)/s.duration,o=u.easing(r),n=u.axm.map(l,function(t,e,n){var i=1<=r?c[n]:t+h.delta[n]*(o-f),t=ke(i,e.range,e.circular);return i!==t&&(e=d[n]*(e.range[1]-e.range[0]),c[n]-=e,l[n]-=e),t}),i=!u.em.triggerChange(n,!1,l);l=n,m=e,1<=(f=o)?(qe(c=u.getFinalPos(c,p),u.axm.get(Object.keys(c)))||u.em.triggerChange(c,!0,l),a()):i?u.finish(!1):u._raf=Ye(t)}()):(this.em.triggerChange(s.destPos,!0),a())},e.getFinalPos=function(t,n){var i=this;return Be(t,function(t,e){return t>=n[e]-1e-6&&t<=n[e]+1e-6?n[e]:Ze(t,i.getRoundUnit(t,e))})},e.getRoundUnit=function(t,e){var n=this.options.round,i=null;return n||(e=this.axm.getAxisOptions(e),t=Math.max($e(e.range[0]),$e(e.range[1]),$e(t)),i=1/Math.pow(10,t)),i||n},e.getUserControll=function(t){t=t.setTo();return t.destPos=this.axm.get(t.destPos),t.duration=tn(t.duration,this.options.minimumDuration,this.options.maximumDuration),t},e.animateTo=function(t,e,n){var i=this,r=this.createAnimationParam(t,e,n),t=Ve({},r.depaPos),e=this.em.triggerAnimationStart(r),r=this.getUserControll(r);!e&&this.axm.every(r.destPos,function(t,e){return Ue(t,e.range,e.circular)})&&console.warn("You can't stop the 'animation' event when 'circular' is true."),e&&!qe(r.destPos,t)&&(e=n&&n.event||null,this.animateLoop({depaPos:t,destPos:r.destPos,duration:r.duration,delta:this.axm.getDelta(t,r.destPos),isTrusted:!!e,inputEvent:e,input:n&&n.input||null},function(){return i.animationEnd()}))},e.easing=function(t){return 1<t?1:this.options.easing(t)},e.setTo=function(t,e){void 0===e&&(e=0);var n=Object.keys(t);this.grab(n);var i=this.axm.get(n);if(qe(t,i))return this;this.itm.setInterrupt(!0);t=He(t,function(t,e){return i[e]!==t});return Object.keys(t).length&&(qe(t=this.axm.map(t,function(t,e){var n=e.range,e=e.circular;return e&&(e[0]||e[1])?t:Le(t,n,e)}),i)||(0<e?this.animateTo(t,e):(this.em.triggerChange(t),this.finish(!1)))),this},e.setBy=function(n,t){return void 0===t&&(t=0),this.setTo(Be(this.axm.get(Object.keys(n)),function(t,e){return t+n[e]}),t)},t}(),nn=function(){function t(t){this.axes=t}var e=t.prototype;return e.triggerHold=function(t,e){t=this.getRoundPos(t).roundPos;this.axes.trigger("hold",{pos:t,input:e.input||null,inputEvent:e.event||null,isTrusted:!0})},e.triggerRelease=function(t){var e=this.getRoundPos(t.destPos,t.depaPos),n=e.roundPos,e=e.roundDepa;t.destPos=n,t.depaPos=e,t.setTo=this.createUserControll(t.destPos,t.duration),this.axes.trigger("release",t)},e.triggerChange=function(t,e,n,i,r){void 0===r&&(r=!1);var o=this.am,s=o.axm,o=o.getEventInfo(),t=this.getRoundPos(t,n),n=t.roundPos,t=t.roundDepa,n=s.moveTo(n,t),t=i&&i.event||o&&o.event||null,o={pos:n.pos,delta:n.delta,holding:r,inputEvent:t,isTrusted:!!t,input:i&&i.input||o&&o.input||null,set:t?this.createUserControll(n.pos):function(){}},n=this.axes.trigger("change",o);return t&&s.set(o.set().destPos),n},e.triggerAnimationStart=function(t){var e=this.getRoundPos(t.destPos,t.depaPos),n=e.roundPos,e=e.roundDepa;return t.destPos=n,t.depaPos=e,t.setTo=this.createUserControll(t.destPos,t.duration),this.axes.trigger("animationStart",t)},e.triggerAnimationEnd=function(t){void 0===t&&(t=!1),this.axes.trigger("animationEnd",{isTrusted:t})},e.triggerFinish=function(t){void 0===t&&(t=!1),this.axes.trigger("finish",{isTrusted:t})},e.createUserControll=function(t,e){void 0===e&&(e=0);var n={destPos:Ve({},t),duration:e};return function(t,e){return t&&(n.destPos=Ve({},t)),void 0!==e&&(n.duration=e),n}},e.setAnimationManager=function(t){this.am=t},e.destroy=function(){this.axes.off()},e.getRoundPos=function(t,e){var n=this.axes.options.round;return{roundPos:Je(t,n),roundDepa:Je(e,n)}},t}(),rn=function(){function t(t){this.options=t,this._prevented=!1}var e=t.prototype;return e.isInterrupting=function(){return this.options.interruptable||this._prevented},e.isInterrupted=function(){return!this.options.interruptable&&this._prevented},e.setInterrupt=function(t){this.options.interruptable||(this._prevented=t)},t}(),on=function(){function t(t,e){var n=this;this.axis=t,this.options=e,this._complementOptions(),this._pos=Object.keys(this.axis).reduce(function(t,e){return t[e]=n.axis[e].range[0],t},{})}var e=t.prototype;return e._complementOptions=function(){var r=this;Object.keys(this.axis).forEach(function(i){r.axis[i]=Ve({range:[0,100],bounce:[0,0],circular:[!1,!1]},r.axis[i]),["bounce","circular"].forEach(function(t){var e=r.axis,n=e[i][t];/string|number|boolean/.test(typeof n)&&(e[i][t]=[n,n])})})},e.getDelta=function(t,e){var n=this.get(t);return Be(this.get(e),function(t,e){return t-n[e]})},e.get=function(t){var n=this;return t&&Array.isArray(t)?t.reduce(function(t,e){return e&&e in n._pos&&(t[e]=n._pos[e]),t},{}):Ve(Ve({},this._pos),t||{})},e.moveTo=function(n,i){void 0===i&&(i=this._pos);var t=Be(this._pos,function(t,e){return e in n&&e in i?n[e]-i[e]:0});return this.set(this.map(n,function(t,e){return e?ke(t,e.range,e.circular):0})),{pos:Ve({},this._pos),delta:t}},e.set=function(t){for(var e in t)e&&e in this._pos&&(this._pos[e]=t[e])},e.every=function(t,n){var i=this.axis;return Ge(t,function(t,e){return n(t,i[e],e)})},e.filter=function(t,n){var i=this.axis;return He(t,function(t,e){return n(t,i[e],e)})},e.map=function(t,n){var i=this.axis;return Be(t,function(t,e){return n(t,i[e],e)})},e.isOutside=function(t){return!this.every(t?this.get(t):this._pos,function(t,e){return!Ne(t,e.range)})},e.getAxisOptions=function(t){return this.axis[t]},t}(),sn=function(){function t(t){var e=t.options,n=t.itm,i=t.em,r=t.axm,t=t.am;this.isOutside=!1,this.moveDistance=null,this.isStopped=!1,this.options=e,this.itm=n,this.em=i,this.axm=r,this.am=t}var e=t.prototype;return e.atOutside=function(t){var o=this;if(this.isOutside)return this.axm.map(t,function(t,e){var n=e.range[0]-e.bounce[0],e=e.range[1]+e.bounce[1];return e<t?e:t<n?n:t});var s=this.am.easing(1e-5)/1e-5;return this.axm.map(t,function(t,e){var n=e.range[0],i=e.range[1],r=e.bounce,e=e.circular;return e&&(e[0]||e[1])?t:t<n?n-o.am.easing((n-t)/(r[0]*s))*r[0]:i<t?i+o.am.easing((t-i)/(r[1]*s))*r[1]:t})},e.get=function(t){return this.axm.get(t.axes)},e.hold=function(t,e){!this.itm.isInterrupted()&&t.axes.length&&(e={input:t,event:e},this.isStopped=!1,this.itm.setInterrupt(!0),this.am.grab(t.axes,e),this.moveDistance||this.em.triggerHold(this.axm.get(),e),this.isOutside=this.axm.isOutside(t.axes),this.moveDistance=this.axm.get(t.axes))},e.change=function(t,e,n){var i,r;this.isStopped||!this.itm.isInterrupting()||this.axm.every(n,function(t){return 0===t})||(r=Be(i=this.moveDistance||this.axm.get(t.axes),function(t,e){return t+(n[e]||0)}),this.moveDistance&&(this.moveDistance=r),this.isOutside&&this.axm.every(i,function(t,e){return!Ne(t,e.range)})&&(this.isOutside=!1),i=this.atOutside(i),r=this.atOutside(r),this.em.triggerChange(r,!1,i,{input:t,event:e},!0)||(this.isStopped=!0,this.moveDistance=null,this.am.finish(!1)))},e.release=function(t,e,n,i){var r,o;!this.isStopped&&this.itm.isInterrupting()&&this.moveDistance&&(r=this.axm.get(t.axes),o=this.axm.get(),n=this.axm.get(this.axm.map(n,function(t,e,n){return e.circular&&(e.circular[0]||e.circular[1])?r[n]+t:Le(r[n]+t,e.range,e.circular,e.bounce)})),0===(i=this.am.getDuration(n,r,i))&&(n=Ve({},o)),n={depaPos:o,destPos:n,duration:i,delta:this.axm.getDelta(o,n),inputEvent:e,input:t,isTrusted:!0},this.em.triggerRelease(n),this.moveDistance=null,t={input:t,event:e},(n=qe((e=this.am.getUserControll(n)).destPos,o))||0===e.duration?(n||this.em.triggerChange(e.destPos,!1,o,t,!0),this.itm.setInterrupt(!1),this.axm.isOutside()?this.am.restore(t):this.em.triggerFinish(!0)):this.am.animateTo(e.destPos,e.duration,t))},t}(),an="ontouchstart"in Fe&&"safari"===N().browser.name,hn=function(){if("undefined"==typeof document)return"";for(var t=(document.head||document.getElementsByTagName("head")[0]).style,e=["transform","webkitTransform","msTransform","mozTransform"],n=0,i=e.length;n<i;n++)if(e[n]in t)return e[n];return""}(),un=function(r){function t(){this.constructor=e}var e;function n(t,e,n){void 0===t&&(t={}),void 0===e&&(e={});var i=r.call(this)||this;return i.axis=t,i._inputs=[],i.options=Ve({easing:function(t){return 1-Math.pow(1-t,3)},interruptable:!0,maximumDuration:1/0,minimumDuration:0,deceleration:6e-4,round:null},e),i.itm=new rn(i.options),i.axm=new on(i.axis,i.options),i.em=new nn(i),i.am=new en(i),i.io=new sn(i),i.em.setAnimationManager(i.am),n&&i.em.triggerChange(n),i}De(e=n,i=r),e.prototype=null===i?Object.create(i):(t.prototype=i.prototype,new t);var i=n.prototype;return i.connect=function(t,e){var n="string"==typeof t?t.split(" "):t.concat();return~this._inputs.indexOf(e)&&this.disconnect(e),"hammer"in e&&((t=this._inputs.filter(function(t){return t.hammer&&t.element===e.element})).length&&(e.hammer=t[0].hammer)),e.mapAxes(n),e.connect(this.io),this._inputs.push(e),this},i.disconnect=function(t){return t?0<=(t=this._inputs.indexOf(t))&&(this._inputs[t].disconnect(),this._inputs.splice(t,1)):(this._inputs.forEach(function(t){return t.disconnect()}),this._inputs=[]),this},i.get=function(t){return this.axm.get(t)},i.setTo=function(t,e){return void 0===e&&(e=0),this.am.setTo(t,e),this},i.setBy=function(t,e){return void 0===e&&(e=0),this.am.setBy(t,e),this},i.isBounceArea=function(t){return this.axm.isOutside(t)},i.destroy=function(){this.disconnect(),this.em.destroy()},n.VERSION="2.7.2",n.TRANSFORM=hn,n.DIRECTION_NONE=At,n.DIRECTION_LEFT=St,n.DIRECTION_RIGHT=Ot,n.DIRECTION_UP=Mt,n.DIRECTION_DOWN=Dt,n.DIRECTION_HORIZONTAL=Ft,n.DIRECTION_VERTICAL=Vt,n.DIRECTION_ALL=Lt,n}(t),cn="PointerEvent"in Fe||"MSPointerEvent"in Fe,ln="ontouchstart"in Fe,fn="_EGJS_AXES_INPUTTYPE_";function dn(i,t){return t.reduce(function(t,e,n){return i[n]&&(t[i[n]]=e),t},{})}function pn(t,e){try{return new Oe(t,Ve({},e))}catch(t){return null}}function mn(t){void 0===t&&(t=[]);var e=!1,n=!1,i=!1;return t.forEach(function(t){switch(t){case"mouse":n=!0;break;case"touch":e=ln;break;case"pointer":i=cn}}),i?he:e&&n?xe:e?fe:n?ve:null}function vn(t,e,n){return n?!!(e===Lt||e&t&&n&t):!!(e&t)}var gn=function(){function t(t,e){if(this.axes=[],this.hammer=null,this.element=null,this.panRecognizer=null,this.isRightEdge=!1,this.rightEdgeTimer=0,this.panFlag=!1,void 0===Oe)throw new Error("The Hammerjs must be loaded before eg.Axes.PanInput.\nhttp://hammerjs.github.io/");this.element=Qe(t),this.options=Ve({inputType:["touch","mouse","pointer"],scale:[1,1],thresholdAngle:45,threshold:0,iOSEdgeSwipeThreshold:30,hammerManagerOptions:{cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",userDrag:"none"}}},e),this.onHammerInput=this.onHammerInput.bind(this),this.onPanmove=this.onPanmove.bind(this),this.onPanend=this.onPanend.bind(this)}var e=t.prototype;return e.mapAxes=function(t){var e=!!t[0],n=!!t[1];this._direction=e&&n?Lt:e?Ft:n?Vt:At,this.axes=t},e.connect=function(t){var e={direction:this._direction,threshold:this.options.threshold};if(this.hammer)this.removeRecognizer(),this.dettachEvent();else{var n=(n=this.element[fn])||String(Math.round(Math.random()*(new Date).getTime())),i=mn(this.options.inputType);if(!i)throw new Error("Wrong inputType parameter!");this.hammer=pn(this.element,Ve({inputClass:i},this.options.hammerManagerOptions)),this.element[fn]=n}return this.panRecognizer=new Pe(e),this.hammer.add(this.panRecognizer),this.attachEvent(t),this},e.disconnect=function(){return this.removeRecognizer(),this.hammer&&this.dettachEvent(),this._direction=At,this},e.destroy=function(){this.disconnect(),this.hammer&&0===this.hammer.recognizers.length&&this.hammer.destroy(),delete this.element[fn],this.element=null,this.hammer=null},e.enable=function(){return this.hammer&&(this.hammer.get("pan").options.enable=!0),this},e.disable=function(){return this.hammer&&(this.hammer.get("pan").options.enable=!1),this},e.isEnable=function(){return!(!this.hammer||!this.hammer.get("pan").options.enable)},e.removeRecognizer=function(){this.hammer&&this.panRecognizer&&(this.hammer.remove(this.panRecognizer),this.panRecognizer=null)},e.onHammerInput=function(t){var e;this.isEnable()&&(t.isFirst?(this.panFlag=!1)!==t.srcEvent.cancelable&&(e=this.options.iOSEdgeSwipeThreshold,this.observer.hold(this,t),this.isRightEdge=an&&t.center.x>window.innerWidth-e,this.panFlag=!0):t.isFinal&&this.onPanend(t))},e.onPanmove=function(t){var e=this;if(this.panFlag){var n=(n=t.angle,(r=this.options.thresholdAngle)<0||90<r?At:(n=Math.abs(n),r<n&&n<180-r?Vt:Ft)),i=this.hammer.session.prevInput;if(i&&an){if(t.center.x<0)return void this.onPanend(Ve(Ve({},i),{velocityX:0,velocityY:0,offsetX:0,offsetY:0}));this.isRightEdge&&(clearTimeout(this.rightEdgeTimer),o=this.options.iOSEdgeSwipeThreshold,t.deltaX<-o?this.isRightEdge=!1:this.rightEdgeTimer=window.setTimeout(function(){e.onPanend(Ve(Ve({},i),{velocityX:0,velocityY:0,offsetX:0,offsetY:0}))},100))}i?(t.offsetX=t.deltaX-i.deltaX,t.offsetY=t.deltaY-i.deltaY):(t.offsetX=0,t.offsetY=0);var n,r=this.getOffset([t.offsetX,t.offsetY],[vn(Ft,this._direction,n),vn(Vt,this._direction,n)]),o=r.some(function(t){return 0!==t});o&&(!1!==(n=t.srcEvent).cancelable&&n.preventDefault(),n.stopPropagation()),(t.preventSystemEvent=o)&&this.observer.change(this,t,dn(this.axes,r))}},e.onPanend=function(t){var e,n,i,r;this.panFlag&&(clearTimeout(this.rightEdgeTimer),this.panFlag=!1,e=this.getOffset([Math.abs(t.velocityX)*(t.deltaX<0?-1:1),Math.abs(t.velocityY)*(t.deltaY<0?-1:1)],[vn(Ft,this._direction),vn(Vt,this._direction)]),n=e,i=this.observer.options.deceleration,r=Math.sqrt(n[0]*n[0]+n[1]*n[1]),i=Math.abs(r/-i),e=[n[0]/2*i,n[1]/2*i],this.observer.release(this,t,dn(this.axes,e)))},e.attachEvent=function(t){this.observer=t,this.hammer.on("hammer.input",this.onHammerInput).on("panstart panmove",this.onPanmove)},e.dettachEvent=function(){this.hammer.off("hammer.input",this.onHammerInput).off("panstart panmove",this.onPanmove),this.observer=null},e.getOffset=function(t,e){var n=[0,0],i=this.options.scale;return e[0]&&(n[0]=t[0]*i[0]),e[1]&&(n[1]=t[1]*i[1]),n},t}(),_n=function(){function t(t,e){if(this.axes=[],this.hammer=null,this.element=null,this._base=null,this._prev=null,this.pinchRecognizer=null,void 0===Oe)throw new Error("The Hammerjs must be loaded before eg.Axes.PinchInput.\nhttp://hammerjs.github.io/");this.element=Qe(t),this.options=Ve({scale:1,threshold:0,inputType:["touch","pointer"],hammerManagerOptions:{cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",userDrag:"none"}}},e),this.onPinchStart=this.onPinchStart.bind(this),this.onPinchMove=this.onPinchMove.bind(this),this.onPinchEnd=this.onPinchEnd.bind(this)}var e=t.prototype;return e.mapAxes=function(t){this.axes=t},e.connect=function(t){var e={threshold:this.options.threshold};if(this.hammer)this.removeRecognizer(),this.dettachEvent();else{var n=(n=this.element[fn])||String(Math.round(Math.random()*(new Date).getTime())),i=mn(this.options.inputType);if(!i)throw new Error("Wrong inputType parameter!");this.hammer=pn(this.element,Ve({inputClass:i},this.options.hammerManagerOptions)),this.element[fn]=n}return this.pinchRecognizer=new Ie(e),this.hammer.add(this.pinchRecognizer),this.attachEvent(t),this},e.disconnect=function(){return this.removeRecognizer(),this.hammer&&(this.hammer.remove(this.pinchRecognizer),this.pinchRecognizer=null,this.dettachEvent()),this},e.destroy=function(){this.disconnect(),this.hammer&&0===this.hammer.recognizers.length&&this.hammer.destroy(),delete this.element[fn],this.element=null,this.hammer=null},e.removeRecognizer=function(){this.hammer&&this.pinchRecognizer&&(this.hammer.remove(this.pinchRecognizer),this.pinchRecognizer=null)},e.onPinchStart=function(t){this._base=this.observer.get(this)[this.axes[0]];var e=this.getOffset(t.scale);this.observer.hold(this,t),this.observer.change(this,t,dn(this.axes,[e])),this._prev=t.scale},e.onPinchMove=function(t){var e=this.getOffset(t.scale,this._prev);this.observer.change(this,t,dn(this.axes,[e])),this._prev=t.scale},e.onPinchEnd=function(t){var e=this.getOffset(t.scale,this._prev);this.observer.change(this,t,dn(this.axes,[e])),this.observer.release(this,t,dn(this.axes,[0]),0),this._base=null,this._prev=null},e.getOffset=function(t,e){return void 0===e&&(e=1),this._base*(t-e)*this.options.scale},e.attachEvent=function(t){this.observer=t,this.hammer.on("pinchstart",this.onPinchStart).on("pinchmove",this.onPinchMove).on("pinchend",this.onPinchEnd)},e.dettachEvent=function(){this.hammer.off("pinchstart",this.onPinchStart).off("pinchmove",this.onPinchMove).off("pinchend",this.onPinchEnd),this.observer=null,this._prev=null},e.enable=function(){return this.hammer&&(this.hammer.get("pinch").options.enable=!0),this},e.disable=function(){return this.hammer&&(this.hammer.get("pinch").options.enable=!1),this},e.isEnable=function(){return!(!this.hammer||!this.hammer.get("pinch").options.enable)},t}(),yn=function(){function t(t,e){this.axes=[],this.element=null,this._isEnabled=!1,this._isHolded=!1,this._timer=null,this.element=Qe(t),this.options=Ve({scale:1,useNormalized:!0},e),this.onWheel=this.onWheel.bind(this)}var e=t.prototype;return e.mapAxes=function(t){this.axes=t},e.connect=function(t){return this.dettachEvent(),this.attachEvent(t),this},e.disconnect=function(){return this.dettachEvent(),this},e.destroy=function(){this.disconnect(),this.element=null},e.onWheel=function(t){var e,n=this;this._isEnabled&&(t.preventDefault(),0!==t.deltaY&&(this._isHolded||(this.observer.hold(this,t),this._isHolded=!0),e=(0<t.deltaY?-1:1)*this.options.scale*(this.options.useNormalized?1:Math.abs(t.deltaY)),this.observer.change(this,t,dn(this.axes,[e])),clearTimeout(this._timer),this._timer=setTimeout(function(){n._isHolded&&(n._isHolded=!1,n.observer.release(n,t,dn(n.axes,[0])))},50)))},e.attachEvent=function(t){this.observer=t,this.element.addEventListener("wheel",this.onWheel),this._isEnabled=!0},e.dettachEvent=function(){this.element.removeEventListener("wheel",this.onWheel),this._isEnabled=!1,this.observer=null,this._timer&&(clearTimeout(this._timer),this._timer=null)},e.enable=function(){return this._isEnabled=!0,this},e.disable=function(){return this._isEnabled=!1,this},e.isEnable=function(){return this._isEnabled},t}(),xn=function(){function t(t,e){this.axes=[],this.element=null,this._isEnabled=!1,this._isHolded=!1,this._timer=null,this.element=Qe(t),this.options=Ve({scale:[1,1]},e),this.onKeydown=this.onKeydown.bind(this),this.onKeyup=this.onKeyup.bind(this)}var e=t.prototype;return e.mapAxes=function(t){this.axes=t},e.connect=function(t){return this.dettachEvent(),"0"!==this.element.getAttribute("tabindex")&&this.element.setAttribute("tabindex","0"),this.attachEvent(t),this},e.disconnect=function(){return this.dettachEvent(),this},e.destroy=function(){this.disconnect(),this.element=null},e.onKeydown=function(t){if(this._isEnabled){var e=!0,n=1,i=-1;switch(t.keyCode){case 37:case 65:n=-1;break;case 39:case 68:break;case 40:case 83:n=-1,i=1;break;case 38:case 87:i=1;break;default:e=!1}(-1===i&&!this.axes[0]||1===i&&!this.axes[1])&&(e=!1),e&&(t=-1===i?[+this.options.scale[0]*n,0]:[0,+this.options.scale[1]*n],this._isHolded||(this.observer.hold(this,event),this._isHolded=!0),clearTimeout(this._timer),this.observer.change(this,event,dn(this.axes,t)))}},e.onKeyup=function(t){var e=this;this._isHolded&&(clearTimeout(this._timer),this._timer=setTimeout(function(){e.observer.release(e,t,dn(e.axes,[0,0])),e._isHolded=!1},80))},e.attachEvent=function(t){this.observer=t,this.element.addEventListener("keydown",this.onKeydown,!1),this.element.addEventListener("keypress",this.onKeydown,!1),this.element.addEventListener("keyup",this.onKeyup,!1),this._isEnabled=!0},e.dettachEvent=function(){this.element.removeEventListener("keydown",this.onKeydown,!1),this.element.removeEventListener("keypress",this.onKeydown,!1),this.element.removeEventListener("keyup",this.onKeyup,!1),this._isEnabled=!1,this.observer=null},e.enable=function(){return this._isEnabled=!0,this},e.disable=function(){return this._isEnabled=!1,this},e.isEnable=function(){return this._isEnabled},t}(),wn=1e-6,En="undefined"!=typeof Float32Array?Float32Array:Array,Tn=Math.PI/180;function Rn(t){return t*Tn}function bn(){var t=new En(9);return En!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function Cn(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}function Pn(t,e){var n=e[0],i=e[1],r=e[2],o=e[3],s=e[4],a=e[5],h=e[6],u=e[7],c=e[8],l=c*s-a*u,f=-c*o+a*h,d=u*o-s*h,e=n*l+i*f+r*d;return e?(e=1/e,t[0]=l*e,t[1]=(-c*i+r*u)*e,t[2]=(a*i-r*s)*e,t[3]=f*e,t[4]=(c*n-r*h)*e,t[5]=(-a*n+r*o)*e,t[6]=d*e,t[7]=(-u*n+i*h)*e,t[8]=(s*n-i*o)*e,t):null}function In(){var t=new En(16);return En!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function An(t,e,n){var i=Math.sin(n),r=Math.cos(n),o=e[4],s=e[5],a=e[6],h=e[7],u=e[8],c=e[9],l=e[10],n=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*r+u*i,t[5]=s*r+c*i,t[6]=a*r+l*i,t[7]=h*r+n*i,t[8]=u*r-o*i,t[9]=c*r-s*i,t[10]=l*r-a*i,t[11]=n*r-h*i,t}function Sn(t,e,n){var i=Math.sin(n),r=Math.cos(n),o=e[0],s=e[1],a=e[2],h=e[3],u=e[8],c=e[9],l=e[10],n=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*r-u*i,t[1]=s*r-c*i,t[2]=a*r-l*i,t[3]=h*r-n*i,t[8]=o*i+u*r,t[9]=s*i+c*r,t[10]=a*i+l*r,t[11]=h*i+n*r,t}function On(t,e,n,i,r){e=1/Math.tan(e/2);return t[0]=e/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=r&&r!==1/0?(e=1/(i-r),t[10]=(r+i)*e,t[14]=2*r*i*e):(t[10]=-1,t[14]=-2*i),t}function Mn(){var t=new En(3);return En!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Dn(t){var e=t[0],n=t[1],t=t[2];return Math.hypot(e,n,t)}function Fn(t,e,n){var i=new En(3);return i[0]=t,i[1]=e,i[2]=n,i}function Vn(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function Ln(t,e){var n=e[0],i=e[1],r=e[2],r=n*n+i*i+r*r;return 0<r&&(r=1/Math.sqrt(r)),t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function Nn(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Un(t,e,n){var i=e[0],r=e[1],o=e[2],s=n[0],e=n[1],n=n[2];return t[0]=r*n-o*e,t[1]=o*s-i*n,t[2]=i*e-r*s,t}function kn(t,e,n){var i=e[0],r=e[1],e=e[2];return t[0]=i*n[0]+r*n[3]+e*n[6],t[1]=i*n[1]+r*n[4]+e*n[7],t[2]=i*n[2]+r*n[5]+e*n[8],t}function zn(t,e,n){var i=n[0],r=n[1],o=n[2],s=n[3],a=e[0],h=e[1],u=e[2],c=r*u-o*h,l=o*a-i*u,n=i*h-r*a,e=r*n-o*l,o=o*c-i*n,r=i*l-r*c,s=2*s;return c*=s,l*=s,n*=s,e*=2,o*=2,r*=2,t[0]=a+c+e,t[1]=h+l+o,t[2]=u+n+r,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var Qn,Wn=Dn;Qn=Mn();var Xn,Yn;Xn=new En(4),En!=Float32Array&&(Xn[0]=0,Xn[1]=0,Xn[2]=0,Xn[3]=0),Yn=Xn;function jn(){var t=new En(4);return En!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Bn(t,e,n){n*=.5;var i=Math.sin(n);return t[0]=i*e[0],t[1]=i*e[1],t[2]=i*e[2],t[3]=Math.cos(n),t}function Hn(t,e,n,i){var r,o=e[0],s=e[1],a=e[2],h=e[3],u=n[0],c=n[1],l=n[2],f=n[3],e=o*u+s*c+a*l+h*f;return e<0&&(e=-e,u=-u,c=-c,l=-l,f=-f),i=wn<1-e?(n=Math.acos(e),e=Math.sin(n),r=Math.sin((1-i)*n)/e,Math.sin(i*n)/e):(r=1-i,i),t[0]=r*o+i*u,t[1]=r*s+i*c,t[2]=r*a+i*l,t[3]=r*h+i*f,t}var Gn,qn,Kn,Zn,Jn,$n,ti=function(t){var e=new En(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},ei=function(t,e,n,i){var r=new En(4);return r[0]=t,r[1]=e,r[2]=n,r[3]=i,r},ni=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},ii=function(t,e){var n=e[0],i=e[1],r=e[2],o=e[3];return 0<(e=n*n+i*i+r*r+o*o)&&(e=1/Math.sqrt(e)),t[0]=n*e,t[1]=i*e,t[2]=r*e,t[3]=o*e,t},ri=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},oi=function(t,e){var n=t[0],i=t[1],r=t[2],o=t[3],s=e[0],a=e[1],t=e[2],e=e[3];return Math.abs(n-s)<=wn*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(i-a)<=wn*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(r-t)<=wn*Math.max(1,Math.abs(r),Math.abs(t))&&Math.abs(o-e)<=wn*Math.max(1,Math.abs(o),Math.abs(e))};Gn=Mn(),qn=Fn(1,0,0),Kn=Fn(0,1,0),Zn=jn(),Jn=jn(),$n=bn();function si(t,e){var n=new En(2);return n[0]=t,n[1]=e,n}function ai(t,e){return t[0]=e[0],t[1]=e[1],t}function hi(t,e){var n=e[0],i=e[1],i=n*n+i*i;return 0<i&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i,t}function ui(t){return 180*t/Math.PI}ci=new En(2),En!=Float32Array&&(ci[0]=0,ci[1]=0),li=ci;var ci,li,fi={isPowerOfTwo:function(t){return t&&0==(t&t-1)}};fi.extractPitchFromQuat=function(t){var e,t=(e=t,zn(t=Fn(0,0,1),t,e),t);return-1*Math.atan2(t[1],Math.sqrt(Math.pow(t[0],2)+Math.pow(t[2],2)))},fi.hypot=Math.hypot||function(t,e){return Math.sqrt(t*t+e*e)};var di={PITCH_DELTA:1,YAW_DELTA_BY_ROLL:2,YAW_DELTA_BY_YAW:3};di[di.PITCH_DELTA]={targetAxis:[0,1,0],meshPoint:[0,0,1]},di[di.YAW_DELTA_BY_ROLL]={targetAxis:[0,1,0],meshPoint:[1,0,0]},di[di.YAW_DELTA_BY_YAW]={targetAxis:[1,0,0],meshPoint:[0,0,1]};function pi(t,e){var n=t[0]*e[1]-e[0]*t[1];return-Math.atan2(n,(e=e,(t=t)[0]*e[0]+t[1]*e[1]))}fi.yawOffsetBetween=function(t,e){t=si(t[0],t[2]),e=si(e[0],e[2]);return hi(t,t),hi(e,e),-pi(t,e)},fi.sign=function(t){return Math.sign?Math.sign(t):Number(0<t)-Number(t<0)||+t},fi.toDegree=ui,fi.getRotationDelta=function(t,e,n){var i=Fn(di[n].targetAxis[0],di[n].targetAxis[1],di[n].targetAxis[2]),r=di[n].meshPoint,o=ti(t),s=ti(e);ii(o,o),ii(s,s);var a=Fn(0,0,1),h=Fn(0,0,1);zn(a,a,o),zn(h,h,s),zn(i,i,s);var u=0<Nn(i,Un(Mn(),a,h))?1:-1,c=Fn(r[0],r[1],r[2]),t=n!==di.YAW_DELTA_BY_YAW?Fn(0,u,0):Fn(u,0,0);zn(c,c,s),zn(t,t,s);e=c,i=t,c=Mn();Un(c,e,i),Ln(c,c);t=c[0],e=c[1],i=c[2];zn(h=Fn(r[0],r[1],r[2]),h,s),zn(a=Fn(r[0],r[1],r[2]),a,o);s=Math.abs(a[0]*t+a[1]*e+a[2]*i),r=Mn();Vn(r,a,(o=Mn(),a=c,c=s,o[0]=a[0]*c,o[1]=a[1]*c,o[2]=a[2]*c,o));o=(r[0]*h[0]+r[1]*h[1]+r[2]*h[2])/(Dn(r)*Dn(h));1<o&&(o=1);var o=Math.acos(o),r=Un(Mn(),h,r),s=t*r[0]+e*r[1]+i*r[2],s=n!==di.YAW_DELTA_BY_YAW?0<s?1:-1:s<0?1:-1;return ui(o*s*u)},fi.angleBetweenVec2=pi;Q=-1,W=null,st=null,t=/Chrome\/([0-9]+)\.(?:[0-9]*)\.([0-9]*)\.([0-9]*)/i.exec(j);t&&(Q=parseInt(t[1],10),W=t[2],st=t[3]);var mi,vi,gi=Q,_i=65===Q&&"3325"===W&&parseInt(st,10)<148,yi=/Android/i.test(j),xi=[.2,.2],wi={NONE:"none",YAWPITCH:"yawPitch",VR:"VR"},Ei=U.MathUtil||{};Ei.degToRad=Math.PI/180,Ei.radToDeg=180/Math.PI,Ei.Vector2=function(t,e){this.x=t||0,this.y=e||0},Ei.Vector2.prototype={constructor:Ei.Vector2,set:function(t,e){return this.x=t,this.y=e,this},copy:function(t){return this.x=t.x,this.y=t.y,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}},Ei.Vector3=function(t,e,n){this.x=t||0,this.y=e||0,this.z=n||0},Ei.Vector3.prototype={constructor:Ei.Vector3,set:function(t,e,n){return this.x=t,this.y=e,this.z=n,this},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},normalize:function(){var t=this.length();return 0!==t?(t=1/t,this.multiplyScalar(t)):(this.x=0,this.y=0,this.z=0),this},multiplyScalar:function(t){this.x*=t,this.y*=t,this.z*=t},applyQuaternion:function(t){var e=this.x,n=this.y,i=this.z,r=t.x,o=t.y,s=t.z,a=t.w,h=a*e+o*i-s*n,u=a*n+s*e-r*i,t=a*i+r*n-o*e,i=-r*e-o*n-s*i;return this.x=h*a+i*-r+u*-s-t*-o,this.y=u*a+i*-o+t*-r-h*-s,this.z=t*a+i*-s+h*-o-u*-r,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},crossVectors:function(t,e){var n=t.x,i=t.y,r=t.z,o=e.x,t=e.y,e=e.z;return this.x=i*e-r*t,this.y=r*o-n*e,this.z=n*t-i*o,this}},Ei.Quaternion=function(t,e,n,i){this.x=t||0,this.y=e||0,this.z=n||0,this.w=void 0!==i?i:1},Ei.Quaternion.prototype={constructor:Ei.Quaternion,set:function(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},setFromEulerXYZ:function(t,e,n){var i=Math.cos(t/2),r=Math.cos(e/2),o=Math.cos(n/2),t=Math.sin(t/2),e=Math.sin(e/2),n=Math.sin(n/2);return this.x=t*r*o+i*e*n,this.y=i*e*o-t*r*n,this.z=i*r*n+t*e*o,this.w=i*r*o-t*e*n,this},setFromEulerYXZ:function(t,e,n){var i=Math.cos(t/2),r=Math.cos(e/2),o=Math.cos(n/2),t=Math.sin(t/2),e=Math.sin(e/2),n=Math.sin(n/2);return this.x=t*r*o+i*e*n,this.y=i*e*o-t*r*n,this.z=i*r*n-t*e*o,this.w=i*r*o+t*e*n,this},setFromAxisAngle:function(t,e){var n=e/2,e=Math.sin(n);return this.x=t.x*e,this.y=t.y*e,this.z=t.z*e,this.w=Math.cos(n),this},multiply:function(t){return this.multiplyQuaternions(this,t)},multiplyQuaternions:function(t,e){var n=t.x,i=t.y,r=t.z,o=t.w,s=e.x,a=e.y,t=e.z,e=e.w;return this.x=n*e+o*s+i*t-r*a,this.y=i*e+o*a+r*s-n*t,this.z=r*e+o*t+n*a-i*s,this.w=o*e-n*s-i*a-r*t,this},inverse:function(){return this.x*=-1,this.y*=-1,this.z*=-1,this.normalize(),this},normalize:function(){var t=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);return 0===t?(this.x=0,this.y=0,this.z=0,this.w=1):(t=1/t,this.x=this.x*t,this.y=this.y*t,this.z=this.z*t,this.w=this.w*t),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var n=this.x,i=this.y,r=this.z,o=this.w,s=o*t.w+n*t.x+i*t.y+r*t.z;if(s<0?(this.w=-t.w,this.x=-t.x,this.y=-t.y,this.z=-t.z,s=-s):this.copy(t),1<=s)return this.w=o,this.x=n,this.y=i,this.z=r,this;var a=Math.acos(s),t=Math.sqrt(1-s*s);if(Math.abs(t)<.001)return this.w=.5*(o+this.w),this.x=.5*(n+this.x),this.y=.5*(i+this.y),this.z=.5*(r+this.z),this;s=Math.sin((1-e)*a)/t,t=Math.sin(e*a)/t;return this.w=o*s+this.w*t,this.x=n*s+this.x*t,this.y=i*s+this.y*t,this.z=r*s+this.z*t,this},setFromUnitVectors:function(t,e){return void 0===mi&&(mi=new Ei.Vector3),(vi=t.dot(e)+1)<1e-6?(vi=0,Math.abs(t.x)>Math.abs(t.z)?mi.set(-t.y,t.x,0):mi.set(0,-t.z,t.y)):mi.crossVectors(t,e),this.x=mi.x,this.y=mi.y,this.z=mi.z,this.w=vi,this.normalize(),this}};var Ti,Ri,bi,Ci,Pi,Ii,Ai,Si,Oi,Mi=null!==(W=null==z?void 0:z.userAgent)&&void 0!==W?W:"",Di=U.Util||{};function Fi(t,e,n,i,r){c=t,s=i?i.fieldOfView:null,o=r.depthNear,u=r.depthFar,l=Math.tan(s?s.upDegrees*Ii:Ai),h=Math.tan(s?s.downDegrees*Ii:Ai),d=Math.tan(s?s.leftDegrees*Ii:Ai),f=Math.tan(s?s.rightDegrees*Ii:Ai),a=2/(d+f),s=2/(l+h),c[0]=a,c[1]=0,c[2]=0,c[3]=0,c[4]=0,c[5]=s,c[6]=0,c[7]=0,c[8]=-(d-f)*a*.5,c[9]=(l-h)*s*.5,c[10]=u/(o-u),c[11]=-1,c[12]=0,c[13]=0,c[14]=u*o/(o-u),c[15]=0;var o,s,a,h,u,c,l,f,d,p,m,v,g,_,y,x,w,E,T,R,b,C,P,I,A,S,t=n.orientation||Si,r=n.position||Oi;d=e,f=r,l=(a=t)[0],h=a[1],s=a[2],o=a[3],c=l*(u=l+l),r=l*(n=h+h),a=l*(t=s+s),l=h*n,h*=t,s*=t,u*=o,n*=o,t*=o,d[0]=1-(l+s),d[1]=r+t,d[2]=a-n,d[3]=0,d[4]=r-t,d[5]=1-(c+s),d[6]=h+u,d[7]=0,d[8]=a+n,d[9]=h-u,d[10]=1-(c+l),d[11]=0,d[12]=f[0],d[13]=f[1],d[14]=f[2],d[15]=1,i&&(b=A=e,R=i.offset,I=R[0],P=R[1],C=R[2],b===A?(A[12]=b[0]*I+b[4]*P+b[8]*C+b[12],A[13]=b[1]*I+b[5]*P+b[9]*C+b[13],A[14]=b[2]*I+b[6]*P+b[10]*C+b[14],A[15]=b[3]*I+b[7]*P+b[11]*C+b[15]):(p=b[0],g=b[1],x=b[2],E=b[3],m=b[4],_=b[5],S=b[6],T=b[7],v=b[8],y=b[9],w=b[10],R=b[11],A[0]=p,A[1]=g,A[2]=x,A[3]=E,A[4]=m,A[5]=_,A[6]=S,A[7]=T,A[8]=v,A[9]=y,A[10]=w,A[11]=R,A[12]=p*I+m*P+v*C+b[12],A[13]=g*I+_*P+y*C+b[13],A[14]=x*I+S*P+w*C+b[14],A[15]=E*I+T*P+R*C+b[15])),s=(t=r=e)[0],a=t[1],n=t[2],h=t[3],u=t[4],c=t[5],l=t[6],f=t[7],d=t[8],i=t[9],p=t[10],m=t[11],v=t[12],g=t[13],_=t[14],y=t[15],(t=(x=s*c-a*u)*(S=p*y-m*_)-(w=s*l-n*u)*(A=i*y-m*g)+(E=s*f-h*u)*(I=i*_-p*g)+(T=a*l-n*c)*(P=d*y-m*v)-(R=a*f-h*c)*(C=d*_-p*v)+(b=n*f-h*l)*(e=d*g-i*v))&&(t=1/t,r[0]=(c*S-l*A+f*I)*t,r[1]=(n*A-a*S-h*I)*t,r[2]=(g*b-_*R+y*T)*t,r[3]=(p*R-i*b-m*T)*t,r[4]=(l*P-u*S-f*C)*t,r[5]=(s*S-n*P+h*C)*t,r[6]=(_*E-v*b-y*w)*t,r[7]=(d*b-p*E+m*w)*t,r[8]=(u*A-c*P+f*e)*t,r[9]=(a*P-s*A-h*e)*t,r[10]=(v*R-g*E+y*x)*t,r[11]=(i*E-d*R-m*x)*t,r[12]=(c*C-u*I-l*e)*t,r[13]=(s*I-a*C+n*e)*t,r[14]=(g*w-v*T-_*x)*t,r[15]=(d*T-i*w+p*x)*t)}Di.MIN_TIMESTEP=.001,Di.MAX_TIMESTEP=1,Di.base64=function(t,e){return"data:"+t+";base64,"+e},Di.clamp=function(t,e,n){return Math.min(Math.max(e,t),n)},Di.lerp=function(t,e,n){return t+(e-t)*n},Di.isIOS=(Ti=/iPad|iPhone|iPod/.test(null==z?void 0:z.platform),function(){return Ti}),Di.isWebViewAndroid=(Ri=-1!==Mi.indexOf("Version")&&-1!==Mi.indexOf("Android")&&-1!==Mi.indexOf("Chrome"),function(){return Ri}),Di.isSafari=(bi=/^((?!chrome|android).)*safari/i.test(Mi),function(){return bi}),Di.isFirefoxAndroid=(Ci=-1!==Mi.indexOf("Firefox")&&-1!==Mi.indexOf("Android"),function(){return Ci}),Di.isR7=(Pi=-1!==Mi.indexOf("R7 Build"),function(){return Pi}),Di.isLandscapeMode=function(){var t=90===U.orientation||-90===U.orientation;return Di.isR7()?!t:t},Di.isTimestampDeltaValid=function(t){return!isNaN(t)&&(!(t<=Di.MIN_TIMESTEP)&&!(t>Di.MAX_TIMESTEP))},Di.getScreenWidth=function(){return Math.max(U.screen.width,U.screen.height)*U.devicePixelRatio},Di.getScreenHeight=function(){return Math.min(U.screen.width,U.screen.height)*U.devicePixelRatio},Di.requestFullscreen=function(t){if(Di.isWebViewAndroid())return!1;if(t.requestFullscreen)t.requestFullscreen();else if(t.webkitRequestFullscreen)t.webkitRequestFullscreen();else if(t.mozRequestFullScreen)t.mozRequestFullScreen();else{if(!t.msRequestFullscreen)return!1;t.msRequestFullscreen()}return!0},Di.exitFullscreen=function(){if(k.exitFullscreen)k.exitFullscreen();else if(k.webkitExitFullscreen)k.webkitExitFullscreen();else if(k.mozCancelFullScreen)k.mozCancelFullScreen();else{if(!k.msExitFullscreen)return!1;k.msExitFullscreen()}return!0},Di.getFullscreenElement=function(){return k.fullscreenElement||k.webkitFullscreenElement||k.mozFullScreenElement||k.msFullscreenElement},Di.linkProgram=function(t,e,n,i){var r=t.createShader(t.VERTEX_SHADER);t.shaderSource(r,e),t.compileShader(r);e=t.createShader(t.FRAGMENT_SHADER);t.shaderSource(e,n),t.compileShader(e);var o,s=t.createProgram();for(o in t.attachShader(s,r),t.attachShader(s,e),i)t.bindAttribLocation(s,i[o],o);return t.linkProgram(s),t.deleteShader(r),t.deleteShader(e),s},Di.getProgramUniforms=function(t,e){for(var n={},i=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),r="",o=0;o<i;o++)n[r=t.getActiveUniform(e,o).name.replace("[0]","")]=t.getUniformLocation(e,r);return n},Di.orthoMatrix=function(t,e,n,i,r,o,s){var a=1/(e-n),h=1/(i-r),u=1/(o-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*h,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*u,t[11]=0,t[12]=(e+n)*a,t[13]=(r+i)*h,t[14]=(s+o)*u,t[15]=1,t},Di.copyArray=function(t,e){for(var n=0,i=t.length;n<i;n++)e[n]=t[n]},Di.isMobile=function(){var t,e=!1;return t=Mi||(null==z?void 0:z.vendor)||U.opera,(/(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(t)||/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(t.substr(0,4)))&&(e=!0),e},Di.extend=function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t},Di.safariCssSizeWorkaround=function(t){var e,n;Di.isIOS()&&(e=t.style.width,n=t.style.height,t.style.width=parseInt(e)+1+"px",t.style.height=parseInt(n)+"px",setTimeout(function(){t.style.width=e,t.style.height=n},100)),U.Util=Di,U.canvas=t},Di.isDebug=function(){return Di.getQueryParameter("debug")},Di.getQueryParameter=function(t){t=t.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");t=new RegExp("[\\?&]"+t+"=([^&#]*)").exec(location.search);return null===t?"":decodeURIComponent(t[1].replace(/\+/g," "))},Di.frameDataFromPose=(Ii=Math.PI/180,Ai=.25*Math.PI,Si=new Float32Array([0,0,0,1]),Oi=new Float32Array([0,0,0]),function(t,e,n){return!(!t||!e)&&(t.pose=e,t.timestamp=e.timestamp,Fi(t.leftProjectionMatrix,t.leftViewMatrix,e,n.getEyeParameters("left"),n),Fi(t.rightProjectionMatrix,t.rightViewMatrix,e,n.getEyeParameters("right"),n),!0)}),Di.isInsideCrossDomainIFrame=function(){var t=U.self!==U.top,e=Di.getDomainFromUrl(k.referrer),n=Di.getDomainFromUrl(U.location.href);return t&&e!==n},Di.getDomainFromUrl=function(t){t=-1<t.indexOf("://")?t.split("/")[2]:t.split("/")[0];return t=t.split(":")[0]};var Vi=function(){function t(t){this.predictionTimeS=t,this.previousQ=new Ei.Quaternion,this.previousTimestampS=null,this.deltaQ=new Ei.Quaternion,this.outQ=new Ei.Quaternion}return t.prototype.getPrediction=function(t,e,n){if(!this.previousTimestampS)return this.previousQ.copy(t),this.previousTimestampS=n,t;var i=new Ei.Vector3;i.copy(e),i.normalize();e=e.length();if(e<20*Ei.degToRad)return Di.isDebug()&&console.log("Moving slowly, at %s deg/s: no prediction",(Ei.radToDeg*e).toFixed(1)),this.outQ.copy(t),this.previousQ.copy(t),this.outQ;this.previousTimestampS;e*=this.predictionTimeS;return this.deltaQ.setFromAxisAngle(i,e),this.outQ.copy(this.previousQ),this.outQ.multiply(this.deltaQ),this.previousQ.copy(t),this.previousTimestampS=n,this.outQ},t}(),Li=function(e){function t(){var t=e.call(this)||this;return t._onDeviceMotion=t._onDeviceMotion.bind(t),t._onDeviceOrientation=t._onDeviceOrientation.bind(t),t._onChromeWithoutDeviceMotion=t._onChromeWithoutDeviceMotion.bind(t),t.isWithoutDeviceMotion=_i,t.isAndroid=yi,t.stillGyroVec=Mn(),t.rawGyroVec=Mn(),t.adjustedGyroVec=Mn(),t._timer=-1,t.lastDevicemotionTimestamp=0,t._isEnabled=!1,t.enable(),t}a(t,e);var n=t.prototype;return n.enable=function(){this.isAndroid&&U.addEventListener("deviceorientation",this._onDeviceOrientation),this.isWithoutDeviceMotion?U.addEventListener("deviceorientation",this._onChromeWithoutDeviceMotion):U.addEventListener("devicemotion",this._onDeviceMotion),this._isEnabled=!0},n.disable=function(){U.removeEventListener("deviceorientation",this._onDeviceOrientation),U.removeEventListener("deviceorientation",this._onChromeWithoutDeviceMotion),U.removeEventListener("devicemotion",this._onDeviceMotion),this._isEnabled=!1},n._onChromeWithoutDeviceMotion=function(t){var e=t.alpha,n=t.beta,t=t.gamma;null!==e&&(e=(e||0)*Math.PI/180,n=(n||0)*Math.PI/180,t=(t||0)*Math.PI/180,this.trigger(new p("devicemotion",{inputEvent:{deviceorientation:{alpha:e,beta:n,gamma:-t}}})))},n._onDeviceOrientation=function(){var n=this;this._timer&&clearTimeout(this._timer),this._timer=U.setTimeout(function(){var t,e;(new Date).getTime()-n.lastDevicemotionTimestamp<200&&(t=n.stillGyroVec,e=n.rawGyroVec,t[0]=e[0],t[1]=e[1],t[2]=e[2])},200)},n._onDeviceMotion=function(t){var e,n,i=!(null==t.rotationRate.alpha),r=!(null==t.accelerationIncludingGravity.x);0!==t.interval&&i&&r&&((e=u({},t)).interval=t.interval,e.timeStamp=t.timeStamp,e.type=t.type,e.rotationRate={alpha:t.rotationRate.alpha,beta:t.rotationRate.beta,gamma:t.rotationRate.gamma},e.accelerationIncludingGravity={x:t.accelerationIncludingGravity.x,y:t.accelerationIncludingGravity.y,z:t.accelerationIncludingGravity.z},e.acceleration={x:t.acceleration.x,y:t.acceleration.y,z:t.acceleration.z},this.isAndroid&&(n=this.rawGyroVec,i=t.rotationRate.alpha||0,r=t.rotationRate.beta||0,t=t.rotationRate.gamma||0,n[0]=i,n[1]=r,n[2]=t,Vn(this.adjustedGyroVec,this.rawGyroVec,this.stillGyroVec),this.lastDevicemotionTimestamp=(new Date).getTime(),e.adjustedRotationRate={alpha:this.adjustedGyroVec[0],beta:this.adjustedGyroVec[1],gamma:this.adjustedGyroVec[2]}),this.trigger(new p("devicemotion",{inputEvent:e})))},t}(e),Ni=function(){function t(t,e){this.set(t,e)}var e=t.prototype;return e.set=function(t,e){this.sample=t,this.timestampS=e},e.copy=function(t){this.set(t.sample,t.timestampS)},t}(),Ui=function(){function t(t){this.addGyroMeasurement=function(t,e){this.currentGyroMeasurement.set(t,e);e-=this.previousGyroMeasurement.timestampS;Di.isTimestampDeltaValid(e)&&this.run_(),this.previousGyroMeasurement.copy(this.currentGyroMeasurement)},this.kFilter=t,this.currentAccelMeasurement=new Ni,this.currentGyroMeasurement=new Ni,this.previousGyroMeasurement=new Ni,Di.isIOS()?this.filterQ=new Ei.Quaternion(-1,0,0,1):this.filterQ=new Ei.Quaternion(1,0,0,1),this.previousFilterQ=new Ei.Quaternion,this.previousFilterQ.copy(this.filterQ),this.accelQ=new Ei.Quaternion,this.isOrientationInitialized=!1,this.estimatedGravity=new Ei.Vector3,this.measuredGravity=new Ei.Vector3,this.gyroIntegralQ=new Ei.Quaternion}var e=t.prototype;return e.addAccelMeasurement=function(t,e){this.currentAccelMeasurement.set(t,e)},e.getOrientation=function(){return this.filterQ},e.run_=function(){if(!this.isOrientationInitialized)return this.accelQ=this.accelToQuaternion_(this.currentAccelMeasurement.sample),this.previousFilterQ.copy(this.accelQ),void(this.isOrientationInitialized=!0);var t=this.currentGyroMeasurement.timestampS-this.previousGyroMeasurement.timestampS,e=this.gyroToQuaternionDelta_(this.currentGyroMeasurement.sample,t);this.gyroIntegralQ.multiply(e),this.filterQ.copy(this.previousFilterQ),this.filterQ.multiply(e);t=new Ei.Quaternion;t.copy(this.filterQ),t.inverse(),this.estimatedGravity.set(0,0,-1),this.estimatedGravity.applyQuaternion(t),this.estimatedGravity.normalize(),this.measuredGravity.copy(this.currentAccelMeasurement.sample),this.measuredGravity.normalize();e=new Ei.Quaternion;e.setFromUnitVectors(this.estimatedGravity,this.measuredGravity),e.inverse(),Di.isDebug()&&console.log("Delta: %d deg, G_est: (%s, %s, %s), G_meas: (%s, %s, %s)",Ei.radToDeg*Di.getQuaternionAngle(e),this.estimatedGravity.x.toFixed(1),this.estimatedGravity.y.toFixed(1),this.estimatedGravity.z.toFixed(1),this.measuredGravity.x.toFixed(1),this.measuredGravity.y.toFixed(1),this.measuredGravity.z.toFixed(1));t=new Ei.Quaternion;t.copy(this.filterQ),t.multiply(e),this.filterQ.slerp(t,1-this.kFilter),this.previousFilterQ.copy(this.filterQ)},e.accelToQuaternion_=function(t){var e=new Ei.Vector3;e.copy(t),e.normalize();t=new Ei.Quaternion;return t.setFromUnitVectors(new Ei.Vector3(0,0,-1),e),t.inverse(),t},e.gyroToQuaternionDelta_=function(t,e){var n=new Ei.Quaternion,i=new Ei.Vector3;return i.copy(t),i.normalize(),n.setFromAxisAngle(i,t.length()*e),n},t}();Ui.prototype.run_=function(){if(!this.isOrientationInitialized)return this.accelQ=this.accelToQuaternion_(this.currentAccelMeasurement.sample),this.previousFilterQ.copy(this.accelQ),void(this.isOrientationInitialized=!0);var t=this.currentGyroMeasurement.timestampS-this.previousGyroMeasurement.timestampS,e=this.gyroToQuaternionDelta_(this.currentGyroMeasurement.sample,t);this.gyroIntegralQ.multiply(e),this.filterQ.copy(this.previousFilterQ),this.filterQ.multiply(e);t=new Ei.Quaternion;t.copy(this.filterQ),t.inverse(),this.estimatedGravity.set(0,0,-1),this.estimatedGravity.applyQuaternion(t),this.estimatedGravity.normalize(),this.measuredGravity.copy(this.currentAccelMeasurement.sample),this.measuredGravity.normalize();e=new Ei.Quaternion;e.setFromUnitVectors(this.estimatedGravity,this.measuredGravity),e.inverse();t=new Ei.Quaternion;t.copy(this.filterQ),t.multiply(e),this.filterQ.slerp(t,1-this.kFilter),this.previousFilterQ.copy(this.filterQ),this.isFilterQuaternionInitialized||(this.isFilterQuaternionInitialized=!0)},Ui.prototype.getOrientation=function(){return this.isFilterQuaternionInitialized?this.filterQ:null};var ki=function(e){function t(){var t=e.call(this)||this;return t.deviceMotion=new Li,t.accelerometer=new Ei.Vector3,t.gyroscope=new Ei.Vector3,t._onDeviceMotionChange=t._onDeviceMotionChange.bind(t),t._onScreenOrientationChange=t._onScreenOrientationChange.bind(t),t.filter=new Ui(.98),t.posePredictor=new Vi(.04),t.filterToWorldQ=new Ei.Quaternion,t.isFirefoxAndroid=Di.isFirefoxAndroid(),t.isIOS=X||Y,t.isChromeUsingDegrees=66<=gi,t._isEnabled=!1,t.isIOS?t.filterToWorldQ.setFromAxisAngle(new Ei.Vector3(1,0,0),Math.PI/2):t.filterToWorldQ.setFromAxisAngle(new Ei.Vector3(1,0,0),-Math.PI/2),t.inverseWorldToScreenQ=new Ei.Quaternion,t.worldToScreenQ=new Ei.Quaternion,t.originalPoseAdjustQ=new Ei.Quaternion,t.originalPoseAdjustQ.setFromAxisAngle(new Ei.Vector3(0,0,1),-U.orientation*Math.PI/180),t._setScreenTransform(),Di.isLandscapeMode()&&t.filterToWorldQ.multiply(t.inverseWorldToScreenQ),t.resetQ=new Ei.Quaternion,t.deviceMotion.on("devicemotion",t._onDeviceMotionChange),t.enable(),t}a(t,e);var n=t.prototype;return n.enable=function(){this.isEnabled()||(this.deviceMotion.enable(),this._isEnabled=!0,U.addEventListener("orientationchange",this._onScreenOrientationChange))},n.disable=function(){this.isEnabled()&&(this.deviceMotion.disable(),this._isEnabled=!1,U.removeEventListener("orientationchange",this._onScreenOrientationChange))},n.isEnabled=function(){return this._isEnabled},n.destroy=function(){this.disable(),this.deviceMotion=null},n.getOrientation=function(){var t,e=this;if(this.deviceMotion.isWithoutDeviceMotion&&this._deviceOrientationQ){this.deviceOrientationFixQ=this.deviceOrientationFixQ||(new Ei.Quaternion).setFromAxisAngle(new Ei.Vector3(0,1,0),-e._alpha),t=this._deviceOrientationQ,(i=new Ei.Quaternion).copy(t),i.multiply(this.filterToWorldQ),i.multiply(this.resetQ),i.multiply(this.worldToScreenQ),i.multiplyQuaternions(this.deviceOrientationFixQ,i);var n=ei(i.x,i.y,i.z,i.w);return ii(n,n)}if(!(t=this.filter.getOrientation()))return null;var i=this._convertFusionToPredicted(t),n=ei(i.x,i.y,i.z,i.w);return ii(n,n)},n._triggerChange=function(){var t=this.getOrientation();t&&(this._prevOrientation?oi(this._prevOrientation,t)||this.trigger(new p("change",{quaternion:t})):this._prevOrientation=t)},n._convertFusionToPredicted=function(t){this.predictedQ=this.posePredictor.getPrediction(t,this.gyroscope,this.previousTimestampS);t=new Ei.Quaternion;return t.copy(this.filterToWorldQ),t.multiply(this.resetQ),t.multiply(this.predictedQ),t.multiply(this.worldToScreenQ),t},n._onDeviceMotionChange=function(t){var e=t.inputEvent,n=e.deviceorientation,i=e.accelerationIncludingGravity,t=e.adjustedRotationRate||e.rotationRate,e=e.timeStamp/1e3;n?(this._alpha||(this._alpha=n.alpha),this._deviceOrientationQ=this._deviceOrientationQ||new Ei.Quaternion,this._deviceOrientationQ.setFromEulerYXZ(n.beta,n.alpha,n.gamma),this._triggerChange()):(this.isFirefoxAndroid&&(e/=1e3),this.accelerometer.set(-i.x,-i.y,-i.z),this.gyroscope.set(t.alpha,t.beta,t.gamma),(this.isIOS||this.isFirefoxAndroid||this.isChromeUsingDegrees)&&this.gyroscope.multiplyScalar(Math.PI/180),this.filter.addAccelMeasurement(this.accelerometer,e),this.filter.addGyroMeasurement(this.gyroscope,e),this._triggerChange(),this.previousTimestampS=e)},n._onScreenOrientationChange=function(){this._setScreenTransform()},n._setScreenTransform=function(){this.worldToScreenQ.set(0,0,0,1);var t=U.orientation;switch(t){case 0:break;case 90:case-90:case 180:this.worldToScreenQ.setFromAxisAngle(new Ei.Vector3(0,0,1),t/-180*Math.PI)}this.inverseWorldToScreenQ.copy(this.worldToScreenQ),this.inverseWorldToScreenQ.inverse()},t}(e),zi=function(i){function t(t,e){void 0===e&&(e={});var n=i.call(this)||this;return n.element=t,n._prevQuaternion=null,n._quaternion=null,n.fusionPoseSensor=null,n.options=u({scale:1,threshold:0},e),n._onPoseChange=n._onPoseChange.bind(n),n}a(t,i);var e=t.prototype;return e.mapAxes=function(t){this.axes=t},e.connect=function(t){return this.observer||(this.observer=t,this.fusionPoseSensor=new ki,this.fusionPoseSensor.enable(),this._attachEvent()),this},e.disconnect=function(){return this.observer&&(this._dettachEvent(),this.fusionPoseSensor.disable(),this.fusionPoseSensor.destroy(),this.fusionPoseSensor=null,this.observer=null),this},e.destroy=function(){this.disconnect(),this.element=null,this.options=null,this.axes=null,this._prevQuaternion=null,this._quaternion=null},e._onPoseChange=function(t){if(!this._prevQuaternion)return this._prevQuaternion=ti(t.quaternion),void(this._quaternion=ti(t.quaternion));var i,e,n;ni(this._prevQuaternion,this._quaternion),ni(this._quaternion,t.quaternion),this.observer.change(this,t,(i=this.axes,[(e=this._prevQuaternion,n=this._quaternion,t=fi.getRotationDelta(e,n,di.YAW_DELTA_BY_YAW),fi.getRotationDelta(e,n,di.YAW_DELTA_BY_ROLL)*Math.sin(fi.extractPitchFromQuat(n))+t),(n=this._prevQuaternion,t=this._quaternion,fi.getRotationDelta(n,t,di.PITCH_DELTA))].reduce(function(t,e,n){return i[n]&&(t[i[n]]=e),t},{})))},e._attachEvent=function(){this.fusionPoseSensor.on("change",this._onPoseChange)},e._dettachEvent=function(){this.fusionPoseSensor.off("change",this._onPoseChange)},t}(e),Qi=null,Wi=0,Xi=function(){function t(){if(Wi++,Qi)return Qi;(Qi=this)._onDeviceOrientation=this._onDeviceOrientation.bind(this),this._onOrientationChange=this._onOrientationChange.bind(this),this._spinR=0,this._screenOrientationAngle=0,U.addEventListener("deviceorientation",this._onDeviceOrientation),U.addEventListener("orientationchange",this._onOrientationChange)}var e=t.prototype;return e.getRadian=function(){return this._spinR+Rn(this._screenOrientationAngle)},e.unref=function(){0<--Wi||(U.removeEventListener("deviceorientation",this._onDeviceOrientation),U.removeEventListener("orientationchange",this._onOrientationChange),this._spinR=0,this._screenOrientationAngle=0,Qi=null,Wi=0)},e._onDeviceOrientation=function(t){var e;null!==t.beta&&null!==t.gamma&&(e=Rn(t.beta),t=Rn(t.gamma),this._spinR=Math.atan2(Math.cos(e)*Math.sin(t),Math.sin(e)))},e._onOrientationChange=function(){U.screen&&U.screen.orientation&&void 0!==U.screen.orientation.angle?this._screenOrientationAngle=screen.orientation.angle:void 0!==U.orientation&&(this._screenOrientationAngle=0<=U.orientation?U.orientation:360+U.orientation)},t}(),Yi=function(r){function t(t,e){void 0===e&&(e={});t=r.call(this,t,e)||this;return t._useRotation=!1,t._screenRotationAngle=null,t.setUseRotation(!(!e||!e.useRotation)),t._userDirection=un.DIRECTION_ALL,t}a(t,r);var e=t.prototype;return e.setUseRotation=function(t){this._useRotation=t,this._screenRotationAngle&&(this._screenRotationAngle.unref(),this._screenRotationAngle=null),this._useRotation&&(this._screenRotationAngle=new Xi)},e.connect=function(t){return this._userDirection=this._direction,this._useRotation&&this._direction&un.DIRECTION_ALL&&(this._direction=un.DIRECTION_HORIZONTAL),r.prototype.connect.call(this,t)},e.destroy=function(){this._useRotation&&this._screenRotationAngle&&this._screenRotationAngle.unref(),r.prototype.destroy.call(this)},e.getOffset=function(t,e){if(!1===this._useRotation)return r.prototype.getOffset.call(this,t,e);var n=r.prototype.getOffset.call(this,t,[!0,!0]),i=[0,0],e=this._screenRotationAngle.getRadian(),t=Math.cos(e),e=Math.sin(e);return i[0]=n[0]*t-n[1]*e,i[1]=n[1]*t+n[0]*e,this._userDirection&un.DIRECTION_HORIZONTAL?this._userDirection&un.DIRECTION_VERTICAL||(i[1]=0):i[0]=0,i},t}(gn),ji=Fn(0,1,0),Bi=function(t){function e(){var e=t.call(this)||this;return e._fusionPoseSensor=new ki,e._quaternion=jn(),e._fusionPoseSensor.enable(),e._fusionPoseSensor.on("change",function(t){e._quaternion=t.quaternion,e.trigger(new p("change",{isTrusted:!0}))}),e}a(e,t);var n=e.prototype;return n.getCombinedQuaternion=function(t){var e,n,i,r,o,s,a=Bn(jn(),ji,-t*Tn),h=(s=jn(),o=this._quaternion,s[0]=-o[0],s[1]=-o[1],s[2]=-o[2],s[3]=o[3],s);return e=jn(),i=a,r=(n=h)[0],t=n[1],o=n[2],s=n[3],a=i[0],h=i[1],n=i[2],i=i[3],e[0]=r*i+s*a+t*n-o*h,e[1]=t*i+s*h+o*a-r*n,e[2]=o*i+s*n+r*h-t*a,e[3]=s*i-r*a-t*h-o*n,e},n.destroy=function(){this.off(),this._fusionPoseSensor&&(this._fusionPoseSensor.off(),this._fusionPoseSensor.destroy(),this._fusionPoseSensor=null)},e}(e),Hi=[-180,180],Gi=[-90,90],qi=[-180,180],Ki=function(n){function t(t){var e=n.call(this)||this;e.options={};t=u({element:null,yaw:0,pitch:0,fov:65,showPolePoint:!1,useZoom:!0,useKeyboard:!0,gyroMode:wi.YAWPITCH,touchDirection:6,yawRange:Hi,pitchRange:Gi,fovRange:[30,110],aspectRatio:1},t);return e._element=t.element,e._initialFov=t.fov,e._enabled=!1,e._isAnimating=!1,e._deviceQuaternion=null,e._initAxes(t),e.option(t),e}a(t,n);var e=t.prototype;return e.updatePanScale=function(t){void 0===t&&(t={});var e=this._axes.get().fov,t=t.height||parseInt(window.getComputedStyle(this._element).height,10),t=xi[0]*e/this._initialFov*320/t;return this._axesPanInput.options.scale=[t,t],this._axes.options.deceleration=.0014*e/110,this},e.option=function(t,e){if(!t)return this._getOptions();if(t&&"string"==typeof t&&void 0===e)return this._getOptions(t);var n={},i=[];return"string"==typeof t?(i.push(t),n[t]=e):(t=t,i=Object.keys(t),n=u({},t)),this._setOptions(this._getValidatedOptions(n)),this._applyOptions(i),this},e.enable=function(){return this._enabled||(this._enabled=!0,this._applyOptions(Object.keys(this.options)),this.updatePanScale()),this},e.disable=function(t){return void 0===t&&(t=!1),this._enabled&&(t||this._resetOrientation(),this._axes.disconnect(),this._enabled=!1),this},e.lookAt=function(t,e){var n=t.yaw,i=t.pitch,r=t.fov,t=this._axes.get(),n=void 0===n?0:n-t.yaw,i=void 0===i?0:i-t.pitch,t=void 0===r?0:r-t.fov;this._axes.options.maximumDuration=1/0,this._axes.setBy({yaw:n,pitch:i,fov:t},e)},e.getYawPitch=function(){var t=this._axes.get();return{yaw:t.yaw,pitch:t.pitch}},e.getFov=function(){return this._axes.get().fov},e.getQuaternion=function(){var t=this._axes.get();return this._deviceQuaternion.getCombinedQuaternion(t.yaw)},e.shouldRenderWithQuaternion=function(){return this.options.gyroMode===wi.VR},e.destroy=function(){this._axes&&this._axes.destroy(),this._axesPanInput&&this._axesPanInput.destroy(),this._axesWheelInput&&this._axesWheelInput.destroy(),this._axesTiltMotionInput&&this._axesTiltMotionInput.destroy(),this._axesPinchInput&&this._axesPinchInput.destroy(),this._axesMoveKeyInput&&this._axesMoveKeyInput.destroy(),this._deviceQuaternion&&this._deviceQuaternion.destroy()},e._initAxes=function(t){var e=this,n=this._updateYawRange(t.yawRange,t.fov,t.aspectRatio),i=this._updatePitchRange(t.pitchRange,t.fov,t.showPolePoint),r=t.gyroMode===wi.VR;this._axesPanInput=new Yi(this._element,{useRotation:r}),this._axesWheelInput=new yn(this._element,{scale:-4}),this._axesTiltMotionInput=null,this._axesPinchInput=B?new _n(this._element,{scale:-1}):null,this._axesMoveKeyInput=new xn(this._element,{scale:[-6,6]}),this._axes=new un({yaw:{range:n,circular:this._isCircular(n),bounce:[0,0]},pitch:{range:i,circular:this._isCircular(i),bounce:[0,0]},fov:{range:t.fovRange,circular:[!1,!1],bounce:[0,0]}},{deceleration:.0014,maximumDuration:1e3},{yaw:t.yaw,pitch:t.pitch,fov:t.fov}).on({hold:function(t){e._axes.options.maximumDuration=1e3,e.trigger(new p("hold",{isTrusted:t.isTrusted}))},change:function(t){0!==t.delta.fov&&(e._updateControlScale(t),e.updatePanScale()),e._triggerChange(t)},release:function(t){e._triggerChange(t)},animationEnd:function(t){e.trigger(new p("animationEnd",{isTrusted:t.isTrusted}))}})},e._getValidatedOptions=function(t){return t.yawRange&&(t.yawRange=this._getValidYawRange(t.yawRange,t.fov,t.aspectRatio)),t.pitchRange&&(t.pitchRange=this._getValidPitchRange(t.pitchRange,t.fov)),t},e._getOptions=function(t){var e;return"string"==typeof t?e=this.options[t]:0===arguments.length&&(e=this.options),e},e._setOptions=function(t){for(var e in t)this.options[e]=t[e]},e._applyOptions=function(t){var e,n,i,r=this.options,o=this._axes,s=r.gyroMode===wi.VR,a=r.gyroMode===wi.YAWPITCH,h=s?2&r.touchDirection:r.touchDirection;t.some(function(t){return"showPolePoint"===t||"fov"===t||"aspectRatio"===t||"yawRange"===t||"pitchRange"===t})&&(0<=t.indexOf("fov")&&(o.setTo({fov:r.fov}),this.updatePanScale()),this._updateControlScale()),t.some(function(t){return"fovRange"===t})&&(e=r.fovRange,n=o.get().fov,i=o.get().fov,ai(o.axis.fov.range,e),i<e[0]?i=e[0]:n>e[1]&&(i=e[1]),n!==i&&(o.setTo({fov:i},0),this._updateControlScale(),this.updatePanScale())),t.some(function(t){return"gyroMode"===t})&&H&&(this._axesTiltMotionInput&&(this._axes.disconnect(this._axesTiltMotionInput),this._axesTiltMotionInput.destroy(),this._axesTiltMotionInput=null),this._deviceQuaternion&&(this._deviceQuaternion.destroy(),this._deviceQuaternion=null),s?this._initDeviceQuaternion():a&&(this._axesTiltMotionInput=new zi(this._element),this._axes.connect(["yaw","pitch"],this._axesTiltMotionInput)),this._axesPanInput.setUseRotation(s)),t.some(function(t){return"useKeyboard"===t})&&(r.useKeyboard?o.connect(["yaw","pitch"],this._axesMoveKeyInput):o.disconnect(this._axesMoveKeyInput)),t.some(function(t){return"useZoom"===t})&&(s=r.useZoom,o.disconnect(this._axesWheelInput),s&&o.connect(["fov"],this._axesWheelInput)),this._togglePinchInputByOption(r.touchDirection,r.useZoom),t.some(function(t){return"touchDirection"===t})&&this._enabled&&this._enableTouch(h)},e._togglePinchInputByOption=function(t,e){this._axesPinchInput&&(this._axes.disconnect(this._axesPinchInput),e&&6===t&&-1===this._axes._inputs.indexOf(this._axesPinchInput)&&this._axes.connect(["fov"],this._axesPinchInput))},e._enableTouch=function(t){this._axesPanInput&&this._axes.disconnect(this._axesPanInput);var e=2&t?"yaw":null,t=4&t?"pitch":null;this._axes.connect([e,t],this._axesPanInput)},e._initDeviceQuaternion=function(){var e=this;this._deviceQuaternion=new Bi,this._deviceQuaternion.on("change",function(t){e._triggerChange(t)})},e._getValidYawRange=function(t,e,n){n=this._adjustAspectRatio(n||this.options.aspectRatio||1),n=(e||this._axes.get().fov)*n;return t[1]-t[0]>=n?t:this.options.yawRange||Hi},e._getValidPitchRange=function(t,e){e=e||this._axes.get().fov;return t[1]-t[0]>=e?t:this.options.pitchRange||Gi},e._isCircular=function(t){return t[1]-t[0]<360?[!1,!1]:[!0,!0]},e._updateControlScale=function(t){var e=this.options,n=this._axes.get().fov,i=this._updatePitchRange(e.pitchRange,n,e.showPolePoint),r=this._updateYawRange(e.yawRange,n,e.aspectRatio),n=this._axes.get(),e=n.yaw,n=n.pitch;return ai(this._axes.axis.yaw.range,r),ai(this._axes.axis.pitch.range,i),this._axes.axis.yaw.circular=this._isCircular(r),this._axes.axis.pitch.circular=this._isCircular(i),e<r[0]?e=r[0]:e>r[1]&&(e=r[1]),n<i[0]?n=i[0]:n>i[1]&&(n=i[1]),t&&t.set({yaw:e,pitch:n}),this._axes.setTo({yaw:e,pitch:n},0),this},e._updatePitchRange=function(t,e,n){if(this.options.gyroMode===wi.VR)return qi;var i=t[1]-t[0],e=e/2;return!n||i<180?[t[0]+e,t[1]-e]:t.concat()},e._updateYawRange=function(t,e,n){if(this.options.gyroMode===wi.VR)return Hi;if(360<=t[1]-t[0])return t.concat();e=fi.toDegree(Math.atan2(n,1/Math.tan(e/2*Tn)));return[t[0]+e,t[1]-e]},e._triggerChange=function(t){var e=this._axes.get(),n=this.options,t={targetElement:n.element,isTrusted:t.isTrusted,yaw:e.yaw,pitch:e.pitch,fov:e.fov,quaternion:null};n.gyroMode===wi.VR&&this._deviceQuaternion&&(t.quaternion=this._deviceQuaternion.getCombinedQuaternion(e.yaw)),this.trigger(new p("change",t))},e._adjustAspectRatio=function(t){for(var e=[.52,.54,.563,.57,.584,.59,.609,.67,.702,.72,.76,.78,.82,.92,.97,1,1.07,1.14,1.19,1.25,1.32,1.38,1.4,1.43,1.53,1.62,1.76,1.77,1.86,1.96,2.26,2.3,2.6,3,5,6],n=[.51,.54,.606,.56,.628,.63,.647,.71,.736,.757,.78,.77,.8,.89,.975,1,1.07,1.1,1.15,1.18,1.22,1.27,1.3,1.33,1.39,1.45,1.54,1.55,1.58,1.62,1.72,1.82,1.92,2,2.24,2.3],i=-1,r=0;r<e.length-1;r++)if(e[r]<=t&&t<=e[r+1]){i=r;break}if(-1===i)return t<e[0]?n[0]:n[n[0].length-1];var o=e[i],s=e[i+1],a=n[i],n=n[i+1];return this._lerp(a,n,(t-o)/(s-o))},e._lerp=function(t,e,n){return t+n*(e-t)},e._resetOrientation=function(){var t=this.options;return this._axes.setTo({yaw:t.yaw,pitch:t.pitch,fov:t.fov},0),this},t.VERSION=i,t.CONTROL_MODE_VR=1,t.CONTROL_MODE_YAWPITCH=2,t.TOUCH_DIRECTION_ALL=6,t.TOUCH_DIRECTION_YAW=2,t.TOUCH_DIRECTION_PITCH=4,t.TOUCH_DIRECTION_NONE=1,t}(e);function Zi(t){return void 0===t}var st=function(){function t(){this.options={},this._eventHandler={}}var e=t.prototype;return e.trigger=function(t){for(var e=this,n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];if(!(0<(s=this._eventHandler[t]||[]).length))return!0;var r=n[0]||{},o=n.slice(1),s=s.concat(),a=!1;r.eventType=t,r.stop=function(){a=!0},r.currentTarget=this;var h=[r];return 1<=o.length&&(h=h.concat(o)),s.forEach(function(t){t.apply(e,h)}),!a},e.once=function(n,i){var r,o=this;if("object"==typeof n&&Zi(i)){var t,e=n;for(t in e)this.once(t,e[t]);return this}return"string"==typeof n&&"function"==typeof i&&(r=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];i.apply(o,t),o.off(n,r)},this.on(n,r)),this},e.hasOn=function(t){return!!this._eventHandler[t]},e.on=function(t,e){if("object"==typeof t&&Zi(e)){var n,i=t;for(n in i)this.on(n,i[n]);return this}var r;return"string"==typeof t&&"function"==typeof e&&(Zi(r=this._eventHandler[t])&&(this._eventHandler[t]=[],r=this._eventHandler[t]),r.push(e)),this},e.off=function(t,e){var n,i;if(Zi(t))return this._eventHandler={},this;if(Zi(e)){if("string"==typeof t)return delete this._eventHandler[t],this;var r,o=t;for(r in o)this.off(r,o[r]);return this}var s=this._eventHandler[t];if(s){var a=0;try{for(var h=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],i=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(s),u=h.next();!u.done;u=h.next()){if(u.value===e){s.splice(a,1);break}a++}}catch(t){n={error:t}}finally{try{u&&!u.done&&(i=h.return)&&i.call(h)}finally{if(n)throw n.error}}}return this},t.VERSION="2.2.2",t}(),Ji=function(t,e){return(Ji=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function $i(t,e){function n(){this.constructor=t}Ji(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var tr=function(){return(tr=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};var j="undefined"!=typeof window,W=j?window.navigator.userAgent:"",er=j&&!!("getComputedStyle"in window),nr=/MSIE|Trident|Windows Phone|Edge/.test(W),ir=j&&!!("addEventListener"in document),rr="width",or="height";function sr(t,e){return t.getAttribute(e)||""}function ar(t){return[].slice.call(t)}function hr(t){return"loading"in t&&"lazy"===t.getAttribute("loading")}function ur(t,e,n){ir?t.addEventListener(e,n,!1):t.attachEvent?t.attachEvent("on"+e,n):t["on"+e]=n}function cr(t,e,n){t.removeEventListener?t.removeEventListener(e,n,!1):t.detachEvent?t.detachEvent("on"+e,n):t["on"+e]=null}function lr(t,e){var n=t["client"+e]||t["offset"+e];return parseFloat(n||(t=t,((er?window.getComputedStyle(t):t.currentStyle)||{})[e.toLowerCase()]))||0}function fr(t,e,n){var i=ar(t.querySelectorAll(function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;for(var i=Array(t),r=0,e=0;e<n;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,r++)i[r]=o[s];return i}(["["+n+"skip] ["+n+"width]"],e.map(function(t){return["["+n+"skip] "+t,t+"["+n+"skip]","["+n+"width] "+t].join(", ")})).join(", ")));return ar(t.querySelectorAll("["+n+"width], "+e.join(", "))).filter(function(t){return-1===i.indexOf(t)})}var dr=[];function pr(t,e){dr.length||ur(window,"resize",vr),t.__PREFIX__=e,dr.push(t),mr(t)}function mr(t,e){void 0===e&&(e="data-");var n,i=t.__PREFIX__||e,r=parseInt(sr(t,""+i+rr),10)||0,e=parseInt(sr(t,""+i+or),10)||0;sr(t,i+"fixed")===or?(n=lr(t,"Height")||e,t.style[rr]=r/e*n+"px"):(n=lr(t,"Width")||r,t.style[or]=e/r*n+"px")}function vr(){dr.forEach(function(t){mr(t)})}for(var W=function(o){function t(t,e){void 0===e&&(e={});var n,i,r=o.call(this)||this;return r.isReady=!1,r.isPreReady=!1,r.hasDataSize=!1,r.hasLoading=!1,r.isSkip=!1,r.onCheck=function(t){r.clear(),t&&"error"===t.type&&r.onError(r.element);t=!r.hasDataSize&&!r.hasLoading;r.onReady(t)},r.options=tr({prefix:"data-"},e),r.element=t,r.hasDataSize=(n=t,void 0===(e=r.options.prefix)&&(e="data-"),!!n.getAttribute(e+"width")),r.hasLoading=hr(t),r.isSkip=(t=r.element,void 0===i&&(i="data-"),!!t.getAttribute(i+"skip")),r}$i(t,o);var e=t.prototype;return e.check=function(){return this.isSkip||!this.checkElement()?(this.onAlreadyReady(!0),!1):(this.hasDataSize&&pr(this.element,this.options.prefix),(this.hasDataSize||this.hasLoading)&&this.onAlreadyPreReady(),!0)},e.addEvents=function(){var e=this,n=this.element;this.constructor.EVENTS.forEach(function(t){ur(n,t,e.onCheck)})},e.clear=function(){var e=this,n=this.element;this.constructor.EVENTS.forEach(function(t){cr(n,t,e.onCheck)}),this.removeAutoSizer()},e.destroy=function(){this.clear(),this.off()},e.removeAutoSizer=function(){var t,e,n;this.hasDataSize&&(n=this.options.prefix,t=this.element,e=n,(n=dr.indexOf(t))<0||(e=sr(t,e+"fixed"),delete t.__PREFIX__,t.style[e===or?rr:or]="",dr.splice(n,1),dr.length||cr(window,"resize",vr)))},e.onError=function(t){this.trigger("error",{element:this.element,target:t})},e.onPreReady=function(){this.isPreReady||(this.isPreReady=!0,this.trigger("preReady",{element:this.element,hasLoading:this.hasLoading,isSkip:this.isSkip}))},e.onReady=function(t){this.isReady||(t&&(this.isPreReady=!0),this.removeAutoSizer(),this.isReady=!0,this.trigger("ready",{element:this.element,withPreReady:t,hasLoading:this.hasLoading,isSkip:this.isSkip}))},e.onAlreadyError=function(t){var e=this;setTimeout(function(){e.onError(t)})},e.onAlreadyPreReady=function(){var t=this;setTimeout(function(){t.onPreReady()})},e.onAlreadyReady=function(t){var e=this;setTimeout(function(){e.onReady(t)})},t.EVENTS=[],t}(st),gr=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}$i(e,t);var n=e.prototype;return n.setHasLoading=function(t){this.hasLoading=t},n.check=function(){return this.isSkip?(this.onAlreadyReady(!0),!1):(this.hasDataSize?(pr(this.element,this.options.prefix),this.onAlreadyPreReady()):this.trigger("requestChildren"),!0)},n.checkElement=function(){return!0},n.destroy=function(){this.clear(),this.trigger("requestDestroy"),this.off()},n.onAlreadyPreReady=function(){t.prototype.onAlreadyPreReady.call(this),this.trigger("reqeustReadyChildren")},e.EVENTS=[],e}(W),j=function(n){function t(t){void 0===t&&(t={});var e=n.call(this)||this;return e.readyCount=0,e.preReadyCount=0,e.totalCount=0,e.totalErrorCount=0,e.isPreReadyOver=!0,e.elementInfos=[],e.options=tr({loaders:{},prefix:"data-"},t),e}$i(t,n);var e=t.prototype;return e.check=function(t){var o=this,n=this.options.prefix;this.clear(),this.elementInfos=ar(t).map(function(t,r){var e=o.getLoader(t,{prefix:n});return e.check(),e.on("error",function(t){o.onError(r,t.target)}).on("preReady",function(t){var e=o.elementInfos[r];e.hasLoading=t.hasLoading,e.isSkip=t.isSkip;t=o.checkPreReady(r);o.onPreReadyElement(r),t&&o.onPreReady()}).on("ready",function(t){var e=t.withPreReady,n=t.hasLoading,i=t.isSkip,t=o.elementInfos[r];t.hasLoading=n,t.isSkip=i;t=e&&o.checkPreReady(r),i=o.checkReady(r);e&&o.onPreReadyElement(r),o.onReadyElement(r),t&&o.onPreReady(),i&&o.onReady()}),{loader:e,element:t,hasLoading:!1,hasError:!1,isPreReady:!1,isReady:!1,isSkip:!1}});t=this.elementInfos.length;return(this.totalCount=t)||setTimeout(function(){o.onPreReady(),o.onReady()}),this},e.getTotalCount=function(){return this.totalCount},e.isPreReady=function(){return this.elementInfos.every(function(t){return t.isPreReady})},e.isReady=function(){return this.elementInfos.every(function(t){return t.isReady})},e.hasError=function(){return 0<this.totalErrorCount},e.clear=function(){this.isPreReadyOver=!1,this.totalCount=0,this.preReadyCount=0,this.readyCount=0,this.totalErrorCount=0,this.elementInfos.forEach(function(t){!t.isReady&&t.loader&&t.loader.destroy()}),this.elementInfos=[]},e.destroy=function(){this.clear(),this.off()},e.getLoader=function(e,t){var n=this,i=e.tagName.toLowerCase(),r=this.options.loaders,o=Object.keys(r);if(r[i])return new r[i](e,t);var s=new gr(e,t),a=ar(e.querySelectorAll(o.join(", ")));s.setHasLoading(a.some(hr));var h=!1,u=this.clone().on("error",function(t){s.onError(t.target)}).on("ready",function(){s.onReady(h)});return s.on("requestChildren",function(){var t=fr(e,o,n.options.prefix);u.check(t).on("preReady",function(t){(h=t.isReady)||s.onPreReady()})}).on("reqeustReadyChildren",function(){u.check(a)}).on("requestDestroy",function(){u.destroy()}),s},e.clone=function(){return new t(tr({},this.options))},e.checkPreReady=function(t){return this.elementInfos[t].isPreReady=!0,++this.preReadyCount,!(this.preReadyCount<this.totalCount)},e.checkReady=function(t){return this.elementInfos[t].isReady=!0,++this.readyCount,!(this.readyCount<this.totalCount)},e.onError=function(t,e){var n=this.elementInfos[t];n.hasError=!0,this.trigger("error",{element:n.element,index:t,target:e,errorCount:this.getErrorCount(),totalErrorCount:++this.totalErrorCount})},e.onPreReadyElement=function(t){var e=this.elementInfos[t];this.trigger("preReadyElement",{element:e.element,index:t,preReadyCount:this.preReadyCount,readyCount:this.readyCount,totalCount:this.totalCount,isPreReady:this.isPreReady(),isReady:this.isReady(),hasLoading:e.hasLoading,isSkip:e.isSkip})},e.onPreReady=function(){this.isPreReadyOver=!0,this.trigger("preReady",{readyCount:this.readyCount,totalCount:this.totalCount,isReady:this.isReady(),hasLoading:this.hasLoading()})},e.onReadyElement=function(t){var e=this.elementInfos[t];this.trigger("readyElement",{index:t,element:e.element,hasError:e.hasError,errorCount:this.getErrorCount(),totalErrorCount:this.totalErrorCount,preReadyCount:this.preReadyCount,readyCount:this.readyCount,totalCount:this.totalCount,isPreReady:this.isPreReady(),isReady:this.isReady(),hasLoading:e.hasLoading,isPreReadyOver:this.isPreReadyOver,isSkip:e.isSkip})},e.onReady=function(){this.trigger("ready",{errorCount:this.getErrorCount(),totalErrorCount:this.totalErrorCount,totalCount:this.totalCount})},e.getErrorCount=function(){return this.elementInfos.filter(function(t){return t.hasError}).length},e.hasLoading=function(){return this.elementInfos.some(function(t){return t.hasLoading})},t}(st),_r=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return $i(e,t),e.prototype.checkElement=function(){var t=this.element,e=t.getAttribute("src");return t.complete&&e?(t.naturalWidth||this.onAlreadyError(t),!1):(this.addEvents(),nr&&t.setAttribute("src",e),!0)},e.EVENTS=["load","error"],e}(W),yr=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return $i(e,t),e.prototype.checkElement=function(){var t=this.element;return!(1<=t.readyState)&&(t.error?(this.onAlreadyError(t),!1):(this.addEvents(),!0))},e.EVENTS=["loadedmetadata","error"],e}(W),xr=function(e){function t(t){return void 0===t&&(t={}),e.call(this,tr({loaders:{img:_r,video:yr}},t))||this}return $i(t,e),t}(j),wr={INVALID_DEVICE:10,NO_WEBGL:11,FAIL_IMAGE_LOAD:12,FAIL_BIND_TEXTURE:13,INVALID_RESOURCE:14,RENDERING_CONTEXT_LOST:15},Er={READY:"ready",VIEW_CHANGE:"viewChange",ANIMATION_END:"animationEnd",ERROR:"error"},Tr={EQUIRECTANGULAR:"equirectangular",CUBEMAP:"cubemap",CUBESTRIP:"cubestrip",PANORAMA:"panorama",STEREOSCOPIC_EQUI:"stereoequi"},Rr={TOP_BOTTOM:"3dv",LEFT_RIGHT:"3dh",NONE:""},br="view360-canvas",Cr=function(i){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];return t.forEach(function(n){Object.keys(n).forEach(function(t){var e=n[t];Array.isArray(i[t])&&Array.isArray(e)?i[t]=d(i[t],e):i[t]=e})}),i},Pr=function(t,e){var n,i;if("object"==typeof e?(n=e.src,i=e.type):"string"==typeof e&&(n=e),!n)return!1;e=document.createElement("source");e.src=n,i&&(e.type=i),t.appendChild(e)},Ir={0:"NO_ERROR",1280:"INVALID_ENUM",1281:"INVALID_VALUE",1282:"INVALID_OPERATION",1285:"OUT_OF_MEMORY",1286:"INVALID_FRAMEBUFFER_OPERATION",37442:"CONTEXT_LOST_WEBGL"},Ar=null,Sr=function(){function e(){}return e.createShader=function(t,e,n){e=t.createShader(e);return t.shaderSource(e,n),t.compileShader(e),t.getShaderParameter(e,t.COMPILE_STATUS)?e:(console.error(t.getShaderInfoLog(e)),null)},e.createProgram=function(t,e,n){var i=t.createProgram();return t.attachShader(i,e),t.attachShader(i,n),t.linkProgram(i),t.deleteShader(e),t.deleteShader(n),t.getProgramParameter(i,t.LINK_STATUS)?i:(t.deleteProgram(i),null)},e.initBuffer=function(t,e,n,i,r){var o=t.createBuffer();return t.bindBuffer(e,o),t.bufferData(e,n,t.STATIC_DRAW),o&&(o.itemSize=i,o.numItems=n.length/i),void 0!==r&&(t.enableVertexAttribArray(r),t.vertexAttribPointer(r,o.itemSize,t.FLOAT,!1,0,0)),o},e.getWebglContext=function(t,e){var n,i,r=null,o=u({preserveDrawingBuffer:!1,antialias:!1},e),e=function(t){return t.statusMessage};t.addEventListener("webglcontextcreationerror",e);try{for(var s=f(["webgl","experimental-webgl","webkit-3d","moz-webgl"]),a=s.next();!a.done;a=s.next()){var h=a.value;try{r=t.getContext(h,o)}catch(t){}if(r)break}}catch(t){n={error:t}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}return t.removeEventListener("webglcontextcreationerror",e),r},e.createTexture=function(t,e){var n=t.createTexture();return t.bindTexture(e,n),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(e,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(e,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.bindTexture(e,null),n},e.isWebGLAvailable=function(){var t;return null===Ar&&(t=document.createElement("canvas"),t=e.getWebglContext(t),Ar=!!t,!t||(t=t.getExtension("WEBGL_lose_context"))&&t.loseContext()),!!Ar},e.isStableWebGL=function(){var t,e=N(),n=!0;return"android"!==e.os.name||((t=parseFloat(e.os.version))<=4.3&&1<=t||4.4===t&&"chrome"!==e.browser.name)&&(n=!1),n},e.getErrorNameFromWebGLErrorCode=function(t){return t in Ir?Ir[t]:"UNKNOWN_ERROR"},e.texImage2D=function(t,e,n){try{t.texImage2D(e,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n)}catch(t){console.error("WebGLUtils.texImage2D error:",t)}},e.getMaxTextureSize=function(t){return t.getParameter(t.MAX_TEXTURE_SIZE)},e}(),st=N(),Or="ie"===st.browser.name&&11===st.browser.majorVersion,Mr={ERROR:"error"},Dr=function(e){function t(){var t=e.call(this)||this;return t._forceDimension=null,t._pixelCanvas=null,t._pixelContext=null,t}a(t,e);var n=t.prototype;return n.render=function(t){var e=t.gl,n=t.shaderProgram,i=t.indexBuffer,r=t.mvMatrix,t=t.pMatrix;e.uniformMatrix4fv(n.pMatrixUniform,!1,t),e.uniformMatrix4fv(n.mvMatrixUniform,!1,r),i&&e.drawElements(e.TRIANGLES,i.numItems,e.UNSIGNED_SHORT,0)},n.getDimension=function(t){return{width:t.naturalWidth||t.videoWidth,height:t.naturalHeight||t.videoHeight}},n.updateShaderData=function(t){},n._initPixelSource=function(t,e){var n;void 0===e&&(e=null),(Or&&t instanceof HTMLVideoElement||e)&&(t=(n=e||this.getDimension(t)).width,n=n.height,this._pixelCanvas=document.createElement("canvas"),this._pixelCanvas.width=t,this._pixelCanvas.height=n,this._pixelContext=this._pixelCanvas.getContext("2d")),this._forceDimension=e},n._getPixelSource=function(t){if(!this._pixelCanvas)return t;var e=this.getDimension(t),n=this._forceDimension||e;return this._pixelCanvas.width!==n.width&&(this._pixelCanvas.width=n.width),this._pixelCanvas.height!==n.height&&(this._pixelCanvas.height=n.height),this._forceDimension?this._pixelContext.drawImage(t,0,0,e.width,e.height,0,0,n.width,n.height):this._pixelContext.drawImage(t,0,0),this._pixelCanvas},n._extractTileConfig=function(t){return(Array.isArray(t.tileConfig)?t.tileConfig:Array.apply(void 0,d(Array(6))).map(function(){return t.tileConfig})).map(function(t){return u({flipHorizontal:!1,rotation:0},t)})},n._triggerError=function(t){console.error("Renderer Error:",t),this.trigger(new p(Mr.ERROR,{message:"string"==typeof t?t:t.message}))},t.EVENTS=Mr,t}(e),Fr=function(t){function u(){return null!==t&&t.apply(this,arguments)||this}a(u,t);var e=u.prototype;return u.extractOrder=function(t){return t.order||"RLUDBF"},e.getVertexPositionData=function(){return u._VERTEX_POSITION_DATA=null!==u._VERTEX_POSITION_DATA?u._VERTEX_POSITION_DATA:[1,-1,1,-1,-1,1,-1,1,1,1,1,1,-1,-1,-1,1,-1,-1,1,1,-1,-1,1,-1,-1,1,-1,1,1,-1,1,1,1,-1,1,1,1,-1,-1,-1,-1,-1,-1,-1,1,1,-1,1,1,-1,-1,1,-1,1,1,1,1,1,1,-1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1]},e.getIndexData=function(){if(u._INDEX_DATA)return u._INDEX_DATA;for(var t=[],e=this.getVertexPositionData(),n=0;n<e.length/3;n+=4)t.push(n,n+2,n+1,n,n+3,n+2);return u._INDEX_DATA=t},e.getTextureCoordData=function(t){var e=this,n=t.image,t=t.imageConfig,i=u.extractOrder(t),h=this.getVertexPositionData(),r=this._extractTileConfig(t),o=t.trim;return"BFUDRL".split("").map(function(t){return r[i.indexOf(t)]}).map(function(t,e){for(var n=Math.floor(t.rotation/90),i=t.flipHorizontal?[0,1,2,3]:[1,0,3,2],r=0;r<Math.abs(n);r++)t.flipHorizontal&&0<n||!t.flipHorizontal&&n<0?i.push(i.shift()):i.unshift(i.pop());for(var o=h.slice(12*e,12*e+12),s=[],a=0;a<4;a++)s[i[a]]=o.splice(0,3);return s}).map(function(t){return e._shrinkCoord({image:n,faceCoords:t,trim:o})}).reduce(function(t,e){return d(t,e.reduce(function(t,e){return d(t,e)},[]))},[])},e.getVertexShaderSource=function(){return"\nattribute vec3 aVertexPosition;\nattribute vec3 aTextureCoord;\nuniform mat4 uMVMatrix;\nuniform mat4 uPMatrix;\nvarying highp vec3 vVertexDirectionVector;\nvoid main(void) {\n vVertexDirectionVector = aTextureCoord;\n gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);\n}"},e.getFragmentShaderSource=function(){return"\nprecision highp float;\nuniform samplerCube uSampler;\nvarying highp vec3 vVertexDirectionVector;\nvoid main(void) {\n gl_FragColor = textureCube(uSampler, vVertexDirectionVector);\n}"},e.updateTexture=function(t,e,n){var n=u.extractOrder(n),i={};n.split("").forEach(function(t,e){i[t]=e});try{if(e instanceof Array)for(var r=0;r<6;r++){var o=i["RLUDBF"[r]];Sr.texImage2D(t,t.TEXTURE_CUBE_MAP_POSITIVE_X+r,e[o])}else for(var s=this.getMaxCubeMapTextureSize(t,e),r=0;r<6;r++){var o=i["RLUDBF"[r]],a=this.extractTileFromImage(e,o,s);Sr.texImage2D(t,t.TEXTURE_CUBE_MAP_POSITIVE_X+r,a)}}catch(t){this._triggerError(t)}},e.bindTexture=function(t,e,n,i){t.bindTexture(t.TEXTURE_CUBE_MAP,e),this.updateTexture(t,n,i)},e.getSourceTileSize=function(t){var e=this.getDimension(t),n=e.width,t=e.height,e=n/t,n=e==1/6?n:6==e?t:e==2/3?n/2:n/3;return n},e.extractTileFromImage=function(t,e,n){var i=this.getDimension(t).width,r=this.getSourceTileSize(t),o=document.createElement("canvas");o.width=n,o.height=n;var s=o.getContext("2d"),a=i/r,i=r*e%(r*a),a=Math.floor(e/a)*r;return s.drawImage(t,i,a,r,r,0,0,n,n),o},e.getMaxCubeMapTextureSize=function(t,e){var n=N(),i=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),r=this.getSourceTileSize(e);if("ie"===n.browser.name&&11===n.browser.majorVersion&&!fi.isPowerOfTwo(r))for(var o=1;o<i;o*=2)if(!(o<r)){r=o;break}return"ios"===n.os.name&&(9===(n=n.os.majorVersion)&&(r=1024),8===n&&(r=512)),Math.min(i,r)},e._shrinkCoord=function(t){var e=t.image,i=t.faceCoords,n=1-t.trim*(2/(Array.isArray(e)?this.getDimension(e[0]).width:this.getSourceTileSize(e))),r=[0,1,2].map(function(e){var n=fi.sign(i[0][e]);return i.some(function(t){return fi.sign(t[e])!==n})}).map(function(t){return t?n:1});return i.map(function(t){return t.map(function(t,e){return t*r[e]})})},u._VERTEX_POSITION_DATA=null,u._INDEX_DATA=null,u}(Dr),Vr=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}a(e,t);var n=e.prototype;return n.getVertexShaderSource=function(){return"\nattribute vec3 aVertexPosition;\nattribute vec2 aTextureCoord;\nuniform mat4 uMVMatrix;\nuniform mat4 uPMatrix;\nvarying highp vec2 vTextureCoord;\nvoid main(void) {\n vTextureCoord = aTextureCoord;\n gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);\n}"},n.getFragmentShaderSource=function(){return"\n#define PI 3.14159265359\nprecision highp float;\nvarying highp vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform bool uIsEAC;\nconst vec2 OPERATE_COORDS_RANGE = vec2(-1.0, 1.0);\nconst vec2 TEXTURE_COORDS_RANGE = vec2(0.0, 1.0);\n// vector type is used for initializing values instead of array.\nconst vec4 TEXTURE_DIVISION_X = vec4(0.0, 1.0 / 3.0, 2.0 / 3.0, 1.0);\nconst vec3 TEXTURE_DIVISION_Y = vec3(0.0, 1.0 / 2.0, 1.0);\nconst float EAC_CONST = 2.0 / PI;\nfloat scale(vec2 domainRange, vec2 targetRange, float val) {\n float unit = 1.0 / (domainRange[1] - domainRange[0]);\n return targetRange[0] + (targetRange[1] - targetRange[0]) * (val - domainRange[0]) * unit;\n}\nvoid main(void) {\n float transformedCoordX;\n float transformedCoordY;\n\n if (uIsEAC) {\n vec2 orgTextureRangeX;\n vec2 orgTextureRangeY;\n\n // Apply EAC transform\n if (vTextureCoord.s >= TEXTURE_DIVISION_X[2]) {\n orgTextureRangeX = vec2(TEXTURE_DIVISION_X[2], TEXTURE_DIVISION_X[3]);\n } else if (vTextureCoord.s >= TEXTURE_DIVISION_X[1]) {\n orgTextureRangeX = vec2(TEXTURE_DIVISION_X[1], TEXTURE_DIVISION_X[2]);\n } else {\n orgTextureRangeX = vec2(TEXTURE_DIVISION_X[0], TEXTURE_DIVISION_X[1]);\n }\n\n if (vTextureCoord.t >= TEXTURE_DIVISION_Y[1]) {\n orgTextureRangeY = vec2(TEXTURE_DIVISION_Y[1], TEXTURE_DIVISION_Y[2]);\n } else {\n orgTextureRangeY = vec2(TEXTURE_DIVISION_Y[0], TEXTURE_DIVISION_Y[1]);\n }\n\n // scaling coors by the coordinates following the range from -1.0 to 1.0.\n float px = scale(orgTextureRangeX, OPERATE_COORDS_RANGE, vTextureCoord.s);\n float py = scale(orgTextureRangeY, OPERATE_COORDS_RANGE, vTextureCoord.t);\n\n float qu = EAC_CONST * atan(px) + 0.5;\n float qv = EAC_CONST * atan(py) + 0.5;\n\n // re-scaling coors by original coordinates ranges\n transformedCoordX = scale(TEXTURE_COORDS_RANGE, orgTextureRangeX, qu);\n transformedCoordY = scale(TEXTURE_COORDS_RANGE, orgTextureRangeY, qv);\n } else {\n // normal cubemap\n transformedCoordX = vTextureCoord.s;\n transformedCoordY = vTextureCoord.t;\n }\n\n gl_FragColor = texture2D(uSampler, vec2(transformedCoordX, transformedCoordY));\n}"},n.getVertexPositionData=function(){return this._vertices||(this._vertices=[1,-1,1,-1,-1,1,-1,1,1,1,1,1,-1,-1,-1,1,-1,-1,1,1,-1,-1,1,-1,-1,1,-1,1,1,-1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,-1,-1,-1,-1,-1,1,-1,-1,1,-1,1,1,1,1,1,1,-1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1]),this._vertices},n.getIndexData=function(){var n=this;return function(){for(var t=[],e=0;e<n._vertices.length/3;e+=4)t.push(e,e+1,e+2,e,e+2,e+3);return t}()},n.getTextureCoordData=function(t){for(var n=this,e=t.image,t=t.imageConfig,i=this.getDimension(e),r=t.trim,o=t.order||"RLUDFB",s=[],a=1;0<=a;a--)for(var h=0;h<3;h++){var u=[h/3,a/2,(h+1)/3,a/2,(h+1)/3,(a+1)/2,h/3,(a+1)/2];s.push(u)}var c=this._extractTileConfig(t),s=s.map(function(t){return n._shrinkCoord(t,i,r)}).map(function(t,e){return n._transformCoord(t,c[e])});return"BFUDRL".split("").map(function(t){return o.indexOf(t)}).map(function(t){return s[t]}).reduce(function(t,e){return t.concat(e)},[])},n.updateTexture=function(t,e){Sr.texImage2D(t,t.TEXTURE_2D,this._getPixelSource(e))},n.bindTexture=function(t,e,n){var i=this.getDimension(n),r=i.width,o=i.height,i=Math.max(r,o),o=Sr.getMaxTextureSize(t);o<i?this._triggerError("Image width("+r+") exceeds device limit("+o+"))"):(this._initPixelSource(n),t.activeTexture(t.TEXTURE0),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!0),t.bindTexture(t.TEXTURE_2D,e),this.updateTexture(t,n))},n._transformCoord=function(t,e){t=t.slice();return e.flipHorizontal&&(t=this._flipHorizontalCoord(t)),e.rotation&&(t=this._rotateCoord(t,e.rotation)),t},n._shrinkCoord=function(t,e,n){var i=e.width,e=n*(1/e.height),i=n*(1/i);return[t[0]+i,t[1]+e,t[2]-i,t[3]+e,t[4]-i,t[5]-e,t[6]+i,t[7]-e]},n._rotateCoord=function(t,e){var n,e=Math.floor(e/90)%4;if(0==e)return t;return 0<e?(n=t.splice(0,2*e),t.concat(n)):(n=t.splice(2*(4+e),2*-e)).concat(t)},n._flipHorizontalCoord=function(t){return[t[2],t[3],t[0],t[1],t[6],t[7],t[4],t[5]]},e}(Dr),Lr=-.5*Math.PI,Nr=[],Ur=[],kr=[],zr=0;zr<=60;zr++)for(var Qr=(zr/60-.5)*Math.PI,Wr=Math.sin(Qr),Xr=Math.cos(Qr),Yr=0;Yr<=60;Yr++){var jr=2*(Yr/60-.5)*Math.PI+Lr,Br=Math.sin(jr),Hr=Math.cos(jr)*Xr,Gr=Wr,qr=Br*Xr,jr=Yr/60,Br=zr/60;Nr.push(jr,Br),Ur.push(2*Hr,2*Gr,2*qr),60!==Yr&&60!==zr&&(qr=(Gr=61*zr+Yr)+60+1,kr.push(Gr,qr,Gr+1,qr,qr+1,Gr+1))}var Kr=function(o){function t(t){var e=o.call(this)||this;return e._stereoFormat=t,e}a(t,o);var e=t.prototype;return e.render=function(t){var e,n,i=t.gl,r=t.shaderProgram;switch(this._stereoFormat){case Rr.TOP_BOTTOM:e=[1,.5,0,0],n=[1,.5,0,.5];break;case Rr.LEFT_RIGHT:e=[.5,1,0,0],n=[.5,1,.5,0];break;default:e=[1,1,0,0],n=[1,1,0,0]}r=i.getUniformLocation(r,"uTexScaleOffset");i.uniform4fv(r,d(e,n)),o.prototype.render.call(this,t)},e.getVertexPositionData=function(){return t._VERTEX_POSITION_DATA},e.getIndexData=function(){return t._INDEX_DATA},e.getTextureCoordData=function(){return t._TEXTURE_COORD_DATA},e.getVertexShaderSource=function(){return"\nattribute vec3 aVertexPosition;\nattribute vec2 aTextureCoord;\nuniform mat4 uMVMatrix;\nuniform mat4 uPMatrix;\nuniform float uEye;\nuniform vec4 uTexScaleOffset[2];\nvarying highp vec2 vTextureCoord;\nvoid main(void) {\n vec4 scaleOffset = uTexScaleOffset[int(uEye)];\n vTextureCoord = aTextureCoord.xy * scaleOffset.xy + scaleOffset.zw;\n gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);\n}"},e.getFragmentShaderSource=function(){return"\nprecision highp float;\nvarying highp vec2 vTextureCoord;\nuniform sampler2D uSampler;\nvoid main(void) {\n gl_FragColor = texture2D(uSampler, vTextureCoord.st);\n}"},e.updateTexture=function(t,e){Sr.texImage2D(t,t.TEXTURE_2D,this._getPixelSource(e))},e.bindTexture=function(t,e,n){var i=this.getDimension(n),r=i.width,o=i.height,i=Math.max(r,o),o=Sr.getMaxTextureSize(t);o<i?this._triggerError("Image width("+r+") exceeds device limit("+o+"))"):(this._initPixelSource(n),t.activeTexture(t.TEXTURE0),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!0),t.bindTexture(t.TEXTURE_2D,e),this.updateTexture(t,n))},t._VERTEX_POSITION_DATA=Ur,t._TEXTURE_COORD_DATA=Nr,t._INDEX_DATA=kr,t}(Dr),Zr=[],Jr=[],$r=[],to=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}a(e,t);var n=e.prototype;return n.getVertexPositionData=function(){return e._VERTEX_POSITION_DATA},n.getIndexData=function(){return e._INDEX_DATA},n.getTextureCoordData=function(){return e._TEXTURE_COORD_DATA},n.getVertexShaderSource=function(){return"\nattribute vec3 aVertexPosition;\nattribute vec2 aTextureCoord;\nuniform mat4 uMVMatrix;\nuniform mat4 uPMatrix;\nvarying highp vec2 vTextureCoord;\nvoid main(void) {\n vTextureCoord = aTextureCoord;\n gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);\n}"},n.getFragmentShaderSource=function(){return"\nprecision highp float;\nvarying highp vec2 vTextureCoord;\nuniform sampler2D uSampler;\nvoid main(void) {\n gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));\n}"},n.updateTexture=function(t,e){Sr.texImage2D(t,t.TEXTURE_2D,this._getPixelSource(e))},n.bindTexture=function(t,e,n){var i,r=this.getDimension(n),o=r.width,s=r.height,a=Math.max(o,s),r=Sr.getMaxTextureSize(t);r<a&&(this._triggerError("Image width("+o+") exceeds device texture limit("+r+"))"),i=s<o?{width:r,height:r*s/o}:{width:r*o/s,height:r}),this._initPixelSource(n,i),t.activeTexture(t.TEXTURE0),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!0),t.bindTexture(t.TEXTURE_2D,e),this.updateTexture(t,n)},n.updateShaderData=function(t){var e,n,i,r=t.imageAspectRatio,t=void 0===r?6:r,r=t<1?(n=!0,1/t):(n=!1,t);r=6<=r?(t=360/r,i=2*Math.PI,Math.tan(t/2*Tn)):(i=r,.5),Zr.length=0,Jr.length=0,$r.length=0;for(var o=[-r,r],s=Math.PI/2+(2*Math.PI-i)/2,a=0,h=o.length;a<h;a++)for(e=0;e<=60;e++){var u=s+e/60*i,c=Math.cos(u),l=o[a],f=Math.sin(u),d=void 0,u=void 0,u=n?(d=1-a,e/60):(d=e/60,a);Zr.push(d,u),Jr.push(c,l,f),0===a&&e<60&&(f=e+60+1,$r.push(e,f,e+1,f,f+1,e+1))}},e._VERTEX_POSITION_DATA=Jr,e._TEXTURE_COORD_DATA=Zr,e._INDEX_DATA=$r,e}(Dr),eo="vrdisplaypresentchange",no=[0,0,.5,1],io=[.5,0,.5,1],ro="left",oo="right",so=function(){function t(){var e=this;this.destroy=function(){var t=e._vrDisplay;e.removeEndCallback(e.destroy),t&&t.isPresenting&&t.exitPresent(),e._clear()},this._frameData=new window.VRFrameData,this._clear()}var e=t.prototype;return Object.defineProperty(e,"context",{get:function(){return this._vrDisplay},enumerable:!1,configurable:!0}),e.canRender=function(){return Boolean(this._vrDisplay)},e.beforeRender=function(t){t.bindFramebuffer(t.FRAMEBUFFER,null)},e.afterRender=function(){this._vrDisplay.submitFrame()},e.getEyeParams=function(t){var e=this._vrDisplay,n=.5*t.drawingBufferWidth,i=t.drawingBufferHeight,r=this._frameData;e.getFrameData(r);t=r.leftViewMatrix,e=r.rightViewMatrix;return Sn(t,t,this._yawOffset),Sn(e,e,this._yawOffset),[{viewport:[0,0,n,i],mvMatrix:t,pMatrix:r.leftProjectionMatrix},{viewport:[n,0,n,i],mvMatrix:e,pMatrix:r.rightProjectionMatrix}]},e.isPresenting=function(){return Boolean(this._vrDisplay&&this._vrDisplay.isPresenting)},e.addEndCallback=function(t){window.addEventListener(eo,t)},e.removeEndCallback=function(t){window.removeEventListener(eo,t)},e.requestPresent=function(i){var r=this;return navigator.getVRDisplays().then(function(t){var n=t.length&&t[0];return n?n.capabilities.canPresent?n.requestPresent([{source:i}]).then(function(){var t=n.getEyeParameters(ro),e=n.getEyeParameters(oo);i.width=2*Math.max(t.renderWidth,e.renderWidth),i.height=Math.max(t.renderHeight,e.renderHeight),r._setDisplay(n)}):_.reject(new Error("Display lacking capability to present.")):_.reject(new Error("No displays available."))})},e.setYawOffset=function(t){this._yawOffset=t},e._setDisplay=function(t){t=(this._vrDisplay=t).getLayers();t.length&&(t=t[0],this._leftBounds=t.leftBounds,this._rightBounds=t.rightBounds),this.addEndCallback(this.destroy)},e._clear=function(){this._vrDisplay=null,this._leftBounds=no,this._rightBounds=io,this._yawOffset=0},t}(),ao=function(){function t(t){var e=this;void 0===t&&(t={}),this.destroy=function(){var t=e._xrSession;e.removeEndCallback(e.destroy),t&&t.end().then(function(){},function(){}),e._clear()},this._clear(),this._options=t}var e=t.prototype;return Object.defineProperty(e,"context",{get:function(){return this._xrSession},enumerable:!1,configurable:!0}),e.canRender=function(t){t=t.getViewerPose(this._xrRefSpace);return Boolean(t)},e.beforeRender=function(t,e){e=e.session.renderState.baseLayer;t.bindFramebuffer(t.FRAMEBUFFER,e.framebuffer)},e.afterRender=function(){},e.getEyeParams=function(t,e){var i=this,n=e.session,e=e.getViewerPose(this._xrRefSpace);if(!e)return null;var r=n.renderState.baseLayer;return e.views.map(function(t){var e=r.getViewport(t),n=t.transform.inverse.matrix;return Y&&An(n,n,180*Tn),Sn(n,n,i._yawOffset),{viewport:[e.x,e.y,e.width,e.height],mvMatrix:n,pMatrix:t.projectionMatrix}})},e.isPresenting=function(){return this._presenting},e.addEndCallback=function(t){var e;null!==(e=this._xrSession)&&void 0!==e&&e.addEventListener("end",t)},e.removeEndCallback=function(t){var e;null!==(e=this._xrSession)&&void 0!==e&&e.removeEventListener("end",t)},e.requestPresent=function(t,r){return n(this,void 0,void 0,function(){var e,n,i=this;return o(this,function(t){switch(t.label){case 0:return e=Cr({requiredFeatures:["local"]},this._options),(n=r.getContextAttributes())&&!0!==n.xrCompatible?[4,r.makeXRCompatible()]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2,navigator.xr.requestSession("immersive-vr",e).then(function(e){var n=new window.XRWebGLLayer(e,r);return e.updateRenderState({baseLayer:n}),e.requestReferenceSpace("local").then(function(t){i._setSession(e,n,t)})})]}})})},e.setYawOffset=function(t){this._yawOffset=t},e._setSession=function(t,e,n){this._xrSession=t,this._xrLayer=e,this._xrRefSpace=n,this._presenting=!0,this.addEndCallback(this.destroy)},e._clear=function(){this._xrSession=null,this._xrLayer=null,this._xrRefSpace=null,this._presenting=!1,this._yawOffset=0,this._options={}},t}(),ho=function(){function t(){var i=this;this._onLoop=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];i._callback.apply(i,d(t)),i._rafId=i._context.requestAnimationFrame(i._onLoop)},this._onLoopNextTick=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=performance.now();i._callback.apply(i,d(t));n=performance.now()-n;0<=i._rafTimer&&(clearTimeout(i._rafTimer),i._rafTimer=-1),n<16?i._rafId=i._context.requestAnimationFrame(i._onLoop):i._rafTimer=window.setTimeout(i._onLoop,0)},this._callback=null,this._context=window,this._rafId=-1,this._rafTimer=-1}var e=t.prototype;return e.setCallback=function(t){this._callback=t},e.setContext=function(t){this._context=t},e.start=function(){var t=this._context,e=this._callback;t&&e&&(0<=this._rafId||0<=this._rafTimer||(this._rafId=Y?t.requestAnimationFrame(this._onLoopNextTick):t.requestAnimationFrame(this._onLoop)))},e.stop=function(){0<=this._rafId&&this._context.cancelAnimationFrame(this._rafId),0<=this._rafTimer&&clearTimeout(this._rafTimer),this._rafId=-1,this._rafTimer=-1},t}(),uo=Tr,co=q||1;2<co&&(co=2);function lo(t,r,o){[e.prototype,t.prototype].forEach(function(n){Object.getOwnPropertyNames(n).filter(function(t){return!r[t]&&!t.startsWith("_")&&"constructor"!==t}).forEach(function(t){var e,i=Object.getOwnPropertyDescriptor(n,t);i.value?Object.defineProperty(r,t,{value:function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return(t=i.value).call.apply(t,d([this[o]],e))}}):(e={},i.get&&(e.get=function(){var t;return null===(t=i.get)||void 0===t?void 0:t.call(this[o])}),i.set&&(e.set=function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return null===(t=i.set)||void 0===t?void 0:t.call.apply(t,d([this[o]],e))}),Object.defineProperty(r,t,e))})})}var fo={BIND_TEXTURE:"bindTexture",IMAGE_LOADED:"imageLoaded",ERROR:"error",RENDERING_CONTEXT_LOST:"renderingContextLost",RENDERING_CONTEXT_RESTORE:"renderingContextRestore"},po={INVALID_DEVICE:10,NO_WEBGL:11,FAIL_IMAGE_LOAD:12,RENDERER_ERROR:13},mo=function(h){function t(t,e,n,i,r,o,s,a){var l=h.call(this)||this;return l.textureCoordBuffer=null,l.vertexBuffer=null,l.indexBuffer=null,l.exitVR=function(){var t=l._vr,e=l.context,n=l._animator;t&&(t.removeEndCallback(l.exitVR),t.destroy(),l._vr=null,X&&l._restoreStyle(),l.updateViewportDimensions(l.width,l.height),l._updateViewport(),e.bindFramebuffer(e.FRAMEBUFFER,null),l._bindBuffers(),l._shouldForceDraw=!0,n.stop(),n.setContext(window),n.setCallback(l._render.bind(l)),n.start())},l._renderStereo=function(t,e){var n,i,r=l._vr,o=l.context,s=r.getEyeParams(o,e);if(s){r.beforeRender(o,e);try{for(var a=f([0,1]),h=a.next();!h.done;h=a.next()){var u=h.value,c=s[u];l.mvMatrix=c.mvMatrix,l.pMatrix=c.pMatrix,o.viewport.apply(o,d(c.viewport)),o.uniform1f(l.shaderProgram.uEye,u),l._bindBuffers(),l._draw()}}catch(t){n={error:t}}finally{try{h&&!h.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}r.afterRender()}},l._onFirstVRFrame=function(t,e){var n,i=l._vr,r=l.context,o=l._animator;i.canRender(e)&&(n=Fn(0,0,-1),r=i.getEyeParams(r,e)[0],e=Cn(bn(),r.mvMatrix),r=Cn(bn(),r.pMatrix),e=Pn(bn(),e),r=Pn(bn(),r),r=kn(Mn(),n,r),kn(r,r,e),0!==(r=fi.yawOffsetBetween(r,Fn(0,0,1)))&&(i.setYawOffset(r),o.setCallback(l._renderStereo)))},l.sphericalConfig=s,l.fieldOfView=s.fieldOfView,l.width=e,l.height=n,l._lastQuaternion=null,l._lastYaw=null,l._lastPitch=null,l._lastFieldOfView=null,l.pMatrix=In(),l.mvMatrix=In(),On(l.pMatrix,Rn(l.fieldOfView),e/n,.1,100),l.textureCoordBuffer=null,l.vertexBuffer=null,l.indexBuffer=null,l.canvas=l._initCanvas(r,o,e,n),l._setDefaultCanvasStyle(),l._wrapper=null,l._wrapperOrigStyle=null,l._renderingContextAttributes=a,l._image=null,l._imageConfig=null,l._imageIsReady=!1,l._shouldForceDraw=!1,l._keepUpdate=!1,l._onContentLoad=l._onContentLoad.bind(l),l._onContentError=l._onContentError.bind(l),l._animator=new ho,l._vr=null,t&&l.setImage({image:t,imageType:s.imageType,isVideo:i,cubemapConfig:s.cubemapConfig}),l}a(t,h);var e=t.prototype;return e.setYawPitchControl=function(t){this._yawPitchControl=t},e.getContent=function(){return this._image},e.setImage=function(t){var e=t.image,n=t.imageType,i=t.isVideo,i=void 0!==i&&i,t=t.cubemapConfig;this._imageIsReady=!1,this._isVideo=i,this._imageConfig=u({order:n===uo.CUBEMAP?"RLUDBF":"RLUDFB",tileConfig:{flipHorizontal:!1,rotation:0},trim:0},t),this._setImageType(n),this._contentLoader&&this._contentLoader.destroy(),this._contentLoader=(new xr).on("ready",this._onContentLoad).on("error",this._onContentError),i?(this._image=function(t){if(t instanceof HTMLVideoElement)return t;var e=document.createElement("video");return e.setAttribute("crossorigin","anonymous"),e.setAttribute("webkit-playsinline",""),e.setAttribute("playsinline",""),t instanceof Array?t.forEach(function(t){return Pr(e,t)}):Pr(e,t),0<e.querySelectorAll("source").length&&e.readyState<1&&e.load(),e}(e),this._contentLoader.check([this._image]),this._keepUpdate=!0):(this._image=function(t){t=(t instanceof Array?t:[t]).map(function(t){var e=t;return"string"==typeof t&&((e=new Image).crossOrigin="anonymous",e.src=t),e});return 1===t.length?t[0]:t}(e),this._contentLoader.check(Array.isArray(this._image)?this._image:[this._image]),this._keepUpdate=!1)},e.isImageLoaded=function(){return!!this._image&&this._imageIsReady&&(!this._isVideo||2<=this._image.readyState)},e.bindTexture=function(){var i=this;return new _(function(e,n){var t=i._contentLoader;return i._image?t?void(t.isReady()?(i._bindTexture(),e()):(t.check(Array.isArray(i._image)?i._image:[i._image]),t.once("ready",function(t){0<t.errorCount?n("Failed to load images."):(i._bindTexture(),e())}))):n("ImageLoader is not initialized"):n("Image is not defined")})},e.attachTo=function(t){this._hasExternalCanvas||(this.detach(),t.appendChild(this.canvas)),this._wrapper=t},e.forceContextLoss=function(){var t;!this.hasRenderingContext()||(t=this.context.getExtension("WEBGL_lose_context"))&&t.loseContext()},e.detach=function(){!this._hasExternalCanvas&&this.canvas.parentElement&&this.canvas.parentElement.removeChild(this.canvas)},e.destroy=function(){this._contentLoader&&this._contentLoader.destroy(),this._animator.stop(),this.detach(),this.forceContextLoss(),this.off(),this.canvas.removeEventListener("webglcontextlost",this._onWebglcontextlost),this.canvas.removeEventListener("webglcontextrestored",this._onWebglcontextrestored)},e.hasRenderingContext=function(){var t=this.context;return!(!t||t.isContextLost()||!t.getProgramParameter(this.shaderProgram,t.LINK_STATUS))},e.updateFieldOfView=function(t){this.fieldOfView=t,this._updateViewport()},e.updateViewportDimensions=function(t,e){var n=!1;this.width=t,this.height=e;t*=co,e*=co;t!==this.canvas.width&&(this.canvas.width=t,n=!0),e!==this.canvas.height&&(this.canvas.height=e,n=!0),n&&(this._updateViewport(),this._shouldForceDraw=!0)},e.keepUpdate=function(t){t&&!1===this.isImageLoaded()&&(this._shouldForceDraw=!0),this._keepUpdate=t},e.startRender=function(){this._animator.setCallback(this._render.bind(this)),this._animator.start()},e.stopRender=function(){this._animator.stop()},e.renderWithQuaternion=function(t,e){var n,i,r,o,s,a,h,u,c,l;this.isImageLoaded()&&(!1===this._keepUpdate&&this._lastQuaternion&&ri(this._lastQuaternion,t)&&this.fieldOfView&&this.fieldOfView===e&&!1===this._shouldForceDraw||(void 0!==e&&e!==this.fieldOfView&&this.updateFieldOfView(e),this.mvMatrix=(n=In(),r=(i=t)[0],o=i[1],s=i[2],a=i[3],h=r*(c=r+r),u=o*c,i=o*(l=o+o),r=s*c,o=s*l,s*=e=s+s,c*=a,l*=a,e*=a,n[0]=1-i-s,n[1]=u+e,n[2]=r-l,n[3]=0,n[4]=u-e,n[5]=1-h-s,n[6]=o+c,n[7]=0,n[8]=r+l,n[9]=o-c,n[10]=1-h-i,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n),this._draw(),this._lastQuaternion=ti(t),this._shouldForceDraw&&(this._shouldForceDraw=!1)))},e.renderWithYawPitch=function(t,e,n){this.isImageLoaded()&&(!1===this._keepUpdate&&null!==this._lastYaw&&this._lastYaw===t&&null!==this._lastPitch&&this._lastPitch===e&&this.fieldOfView&&this.fieldOfView===n&&!1===this._shouldForceDraw||(void 0!==n&&n!==this.fieldOfView&&this.updateFieldOfView(n),(n=this.mvMatrix)[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,An(this.mvMatrix,this.mvMatrix,-e*Tn),Sn(this.mvMatrix,this.mvMatrix,-t*Tn),this._draw(),this._lastYaw=t,this._lastPitch=e,this._shouldForceDraw&&(this._shouldForceDraw=!1)))},e.getProjectionRenderer=function(){return this._renderer},e.enterVR=function(t){var e=this._vr;return J||navigator.getVRDisplays?e&&e.isPresenting()?_.resolve("VR already enabled."):this._requestPresent(t):_.reject("VR is not available on this browser.")},e._setImageType=function(t){var e=this;if(t&&this._imageType!==t){switch(this._imageType=t,this._isCubeMap=t===uo.CUBEMAP,this._renderer&&this._renderer.off(),t){case uo.CUBEMAP:this._renderer=new Fr;break;case uo.CUBESTRIP:this._renderer=new Vr;break;case uo.PANORAMA:this._renderer=new to;break;case uo.STEREOSCOPIC_EQUI:this._renderer=new Kr(this.sphericalConfig.stereoFormat);break;default:this._renderer=new Kr(Rr.NONE)}this._renderer.on(Dr.EVENTS.ERROR,function(t){e.trigger(new p(fo.ERROR,{type:po.RENDERER_ERROR,message:t.message}))}),this._initWebGL()}},e._initCanvas=function(t,e,n,i){t=t.querySelector("."+e),e=t||this._createCanvas(e);return this._hasExternalCanvas=!!t,e.width=n,e.height=i,this._onWebglcontextlost=this._onWebglcontextlost.bind(this),this._onWebglcontextrestored=this._onWebglcontextrestored.bind(this),e.addEventListener("webglcontextlost",this._onWebglcontextlost),e.addEventListener("webglcontextrestored",this._onWebglcontextrestored),e},e._createCanvas=function(t){var e=document.createElement("canvas");return e.className=t,e},e._setDefaultCanvasStyle=function(){var t=this.canvas;t.style.bottom="0",t.style.left="0",t.style.right="0",t.style.top="0",t.style.margin="auto",t.style.maxHeight="100%",t.style.maxWidth="100%",t.style.outline="none",t.style.position="absolute"},e._onContentError=function(){return this._imageIsReady=!1,this._image=null,this.trigger(new p(fo.ERROR,{type:po.FAIL_IMAGE_LOAD,message:"failed to load image"})),!1},e._triggerContentLoad=function(){this.trigger(new p(fo.IMAGE_LOADED,{content:this._image,isVideo:this._isVideo,projectionType:this._imageType}))},e._onContentLoad=function(t){0<t.errorCount||(this._imageIsReady=!0,this._triggerContentLoad())},e._initShaderProgram=function(){var t=this.context;this.shaderProgram&&(t.deleteProgram(this.shaderProgram),this.shaderProgram=null);var e=this._renderer,n=e.getVertexShaderSource(),e=e.getFragmentShaderSource(),n=Sr.createShader(t,t.VERTEX_SHADER,n),e=Sr.createShader(t,t.FRAGMENT_SHADER,e),e=Sr.createProgram(t,n,e);if(!e)throw new Error("Failed to initialize shaders: "+Sr.getErrorNameFromWebGLErrorCode(t.getError()));t.useProgram(e),e.vertexPositionAttribute=t.getAttribLocation(e,"aVertexPosition"),e.pMatrixUniform=t.getUniformLocation(e,"uPMatrix"),e.mvMatrixUniform=t.getUniformLocation(e,"uMVMatrix"),e.samplerUniform=t.getUniformLocation(e,"uSampler"),e.textureCoordAttribute=t.getAttribLocation(e,"aTextureCoord"),e.uEye=t.getUniformLocation(e,"uEye"),t.enableVertexAttribArray(e.vertexPositionAttribute),t.enableVertexAttribArray(e.textureCoordAttribute),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT|t.STENCIL_BUFFER_BIT),t.uniform1i(e.samplerUniform,0),this.shaderProgram=e},e._onWebglcontextlost=function(t){t.preventDefault(),this.trigger(new p(fo.RENDERING_CONTEXT_LOST))},e._onWebglcontextrestored=function(){this._initWebGL(),this.trigger(new p(fo.RENDERING_CONTEXT_RESTORE))},e._updateViewport=function(){On(this.pMatrix,Rn(this.fieldOfView),this.canvas.width/this.canvas.height,.1,100),this.context.viewport(0,0,this.context.drawingBufferWidth,this.context.drawingBufferHeight)},e._initWebGL=function(){var t;try{this._initRenderingContext(),t=this.context,this.updateViewportDimensions(this.width,this.height),this._initShaderProgram()}catch(t){return this.trigger(new p(fo.ERROR,{type:po.NO_WEBGL,message:"no webgl support"})),this.destroy(),void console.error(t)}t.clearColor(0,0,0,0);var e=this._isCubeMap?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D;this.texture&&t.deleteTexture(this.texture),this.texture=Sr.createTexture(t,e),this._imageType===uo.CUBESTRIP&&t.enable(t.CULL_FACE)},e._initRenderingContext=function(){if(!this.hasRenderingContext()){if(!window.WebGLRenderingContext)throw new Error("WebGLRenderingContext not available.");if(this.context=Sr.getWebglContext(this.canvas,this._renderingContextAttributes),!this.context)throw new Error("Failed to acquire 3D rendering context")}},e._initBuffers=function(){var t=this._image,e=this._renderer.getVertexPositionData(),n=this._renderer.getIndexData(),i=this._renderer.getTextureCoordData({image:t,imageConfig:this._imageConfig}),t=this.context;this.vertexBuffer=Sr.initBuffer(t,t.ARRAY_BUFFER,new Float32Array(e),3,this.shaderProgram.vertexPositionAttribute),this.indexBuffer=Sr.initBuffer(t,t.ELEMENT_ARRAY_BUFFER,new Uint16Array(n),1),this.textureCoordBuffer=Sr.initBuffer(t,t.ARRAY_BUFFER,new Float32Array(i),this._isCubeMap?3:2,this.shaderProgram.textureCoordAttribute),this._bindBuffers()},e._bindTexture=function(){var t,e,n;this._imageType===uo.CUBESTRIP?(e=(t=this._renderer.getDimension(this._image)).width,n=t.height,t=e&&n&&e/n!=1.5?1:0,this.context.uniform1f(this.context.getUniformLocation(this.shaderProgram,"uIsEAC"),t)):this._imageType===uo.PANORAMA&&(e=(t=this._renderer.getDimension(this._image)).width,n=t.height,n=e&&n&&e/n,this._renderer.updateShaderData({imageAspectRatio:n})),this._initBuffers(),this._renderer.bindTexture(this.context,this.texture,this._image,this._imageConfig),this._shouldForceDraw=!0,this.trigger(new p(fo.BIND_TEXTURE))},e._updateTexture=function(){this._renderer.updateTexture(this.context,this._image,this._imageConfig)},e._render=function(){var t,e=this._yawPitchControl,n=e.getFov();e.shouldRenderWithQuaternion()?(t=e.getQuaternion(),this.renderWithQuaternion(t,n)):(e=e.getYawPitch(),this.renderWithYawPitch(e.yaw,e.pitch,n))},e._bindBuffers=function(){var t=this.context,e=this.shaderProgram,n=this.vertexBuffer,i=this.textureCoordBuffer;t.bindBuffer(t.ARRAY_BUFFER,n),t.enableVertexAttribArray(e.vertexPositionAttribute),t.vertexAttribPointer(e.vertexPositionAttribute,n.itemSize,t.FLOAT,!1,0,0),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bindBuffer(t.ARRAY_BUFFER,i),t.enableVertexAttribArray(e.textureCoordAttribute),t.vertexAttribPointer(e.textureCoordAttribute,i.itemSize,t.FLOAT,!1,0,0)},e._draw=function(){this._isVideo&&this._keepUpdate&&this._updateTexture(),this._renderer.render({gl:this.context,shaderProgram:this.shaderProgram,indexBuffer:this.indexBuffer,mvMatrix:this.mvMatrix,pMatrix:this.pMatrix})},e._requestPresent=function(t){var n=this,i=this.context,r=this.canvas,o=this._animator;this._vr=J?new ao(t):new so;var s=this._vr;return o.stop(),new _(function(t,e){s.requestPresent(r,i).then(function(){s.addEndCallback(n.exitVR),o.setContext(s.context),o.setCallback(n._onFirstVRFrame),X&&n._setWrapperFullscreen(),n._shouldForceDraw=!0,o.start(),t("success")}).catch(function(t){s.destroy(),n._vr=null,o.start(),e(t)})})},e._setWrapperFullscreen=function(){var t=this._wrapper;t&&(this._wrapperOrigStyle=t.getAttribute("style"),(t=t.style).width="100vw",t.height="100vh",t.position="fixed",t.left="0",t.top="0",t.zIndex="9999")},e._restoreStyle=function(){var t=this._wrapper,e=this.canvas;t&&(this._wrapperOrigStyle?t.setAttribute("style",this._wrapperOrigStyle):t.removeAttribute("style"),this._wrapperOrigStyle=null,e.removeAttribute("style"),this._setDefaultCanvasStyle())},t.EVENTS=fo,t.ERROR_TYPE=po,t}(e),vo=function(o){function s(t,e){void 0===e&&(e={});var n=o.call(this)||this;if(!Sr.isWebGLAvailable())return setTimeout(function(){n.trigger(new p(Er.ERROR,{type:wr.NO_WEBGL,message:"no webgl support"}))},0),n;if(!Sr.isStableWebGL())return setTimeout(function(){n.trigger(new p(Er.ERROR,{type:wr.INVALID_DEVICE,message:"blacklisted browser"}))},0),n;if(e.image&&e.video)return setTimeout(function(){n.trigger(new p(Er.ERROR,{type:wr.INVALID_RESOURCE,message:"Specifying multi resouces(both image and video) is not valid."}))},0),n;$(),n._container=t,n._image=e.image||e.video,n._isVideo=!!e.video,n._projectionType=e.projectionType||Tr.EQUIRECTANGULAR,n._cubemapConfig=u({order:n._projectionType===Tr.CUBEMAP?"RLUDBF":"RLUDFB",tileConfig:{flipHorizontal:!1,rotation:0},trim:0},e.cubemapConfig),n._stereoFormat=e.stereoFormat||Rr.TOP_BOTTOM,n._width=e.width||parseInt(window.getComputedStyle(t).width,10),n._height=e.height||parseInt(window.getComputedStyle(t).height,10),n._yaw=e.yaw||0,n._pitch=e.pitch||0,n._fov=e.fov||65,n._gyroMode=e.gyroMode||wi.YAWPITCH,n._quaternion=null,n._aspectRatio=0!==n._height?n._width/n._height:1,n._canvasClass=e.canvasClass||br;var i=e.fovRange||[30,110],r=s._isValidTouchDirection(e.touchDirection)?e.touchDirection:Ki.TOUCH_DIRECTION_ALL,r=u(u({},e),{element:t,yaw:n._yaw,pitch:n._pitch,fov:n._fov,gyroMode:n._gyroMode,fovRange:i,aspectRatio:n._aspectRatio,touchDirection:r});return n._isReady=!1,n._initYawPitchControl(r),n._initRenderer(n._yaw,n._pitch,n._fov,n._projectionType,n._cubemapConfig),n}a(s,o);var t=s.prototype;return s.isSupported=function(){return Sr.isWebGLAvailable()&&Sr.isStableWebGL()},s.isWebGLAvailable=function(){return Sr.isWebGLAvailable()},s.isGyroSensorAvailable=function(t){var n;G||!t?_.race([new _(function(e){n=function(t){t=!(null==t.rotationRate.alpha);e(t)},window.addEventListener("devicemotion",n)}),new _(function(t){setTimeout(function(){return t(!1)},1e3)})]).then(function(e){window.removeEventListener("devicemotion",n),t&&t(e),s.isGyroSensorAvailable=function(t){return t&&t(e),e}}):t(!1)},s._isValidTouchDirection=function(t){return t===s.TOUCH_DIRECTION.NONE||t===s.TOUCH_DIRECTION.YAW||t===s.TOUCH_DIRECTION.PITCH||t===s.TOUCH_DIRECTION.ALL},t.getVideo=function(){return this._isVideo?this._photoSphereRenderer.getContent():null},t.setVideo=function(t,e){return void 0===e&&(e={}),t&&this.setImage(t,{projectionType:e.projectionType,isVideo:!0,cubemapConfig:e.cubemapConfig,stereoFormat:e.stereoFormat}),this},t.getImage=function(){return this._isVideo?null:this._photoSphereRenderer.getContent()},t.setImage=function(t,e){void 0===e&&(e={});var n=u({order:"RLUDBF",tileConfig:{flipHorizontal:!1,rotation:0},trim:0},e.cubemapConfig),i=e.stereoFormat||Rr.TOP_BOTTOM,r=!!e.isVideo;return this._image&&this._isVideo!==r?console.warn("PanoViewer is not currently supporting content type changes. (Image <--\x3e Video)"):t&&(this._deactivate(),this._image=t,this._isVideo=r,this._projectionType=e.projectionType||Tr.EQUIRECTANGULAR,this._cubemapConfig=n,this._stereoFormat=i,this._initRenderer(this._yaw,this._pitch,this._fov,this._projectionType,this._cubemapConfig)),this},t.keepUpdate=function(t){return this._photoSphereRenderer.keepUpdate(t),this},t.getProjectionType=function(){return this._projectionType},t.enableSensor=function(){return new _(function(e,n){G&&"function"==typeof G.requestPermission?G.requestPermission().then(function(t){"granted"===t?e():n(new Error("permission denied"))}).catch(function(t){n(t)}):e()})},t.disableSensor=function(){return this},t.enterVR=function(t){var i=this;return void 0===t&&(t={}),this._isReady?new _(function(e,n){i.enableSensor().then(function(){return i._photoSphereRenderer.enterVR(t)}).then(function(t){return e(t)}).catch(function(t){return n(t)})}):_.reject(new Error("PanoViewer is not ready to show image."))},t.exitVR=function(){return this._photoSphereRenderer.exitVR(),this},t.setUseZoom=function(t){return"boolean"==typeof t&&this._yawPitchControl.option("useZoom",t),this},t.setUseKeyboard=function(t){return this._yawPitchControl.option("useKeyboard",t),this},t.setGyroMode=function(t){return this._yawPitchControl.option("gyroMode",t),this},t.setFovRange=function(t){return this._yawPitchControl.option("fovRange",t),this},t.getFovRange=function(){return this._yawPitchControl.option("fovRange")},t.updateViewportDimensions=function(t){if(void 0===t&&(t={}),!this._isReady)return this;void 0!==t.width&&void 0!==t.height||(n=window.getComputedStyle(this._container));var e=t.width||parseInt(n.width,10),n=t.height||parseInt(n.height,10);return e===this._width&&n===this._height||(this._width=e,this._height=n,this._aspectRatio=e/n,this._photoSphereRenderer.updateViewportDimensions(e,n),this._yawPitchControl.option("aspectRatio",this._aspectRatio),this._yawPitchControl.updatePanScale({height:n}),this.lookAt({},0)),this},t.getFov=function(){return this._fov},t.getYaw=function(){return this._yaw},t.getPitch=function(){return this._pitch},t.getYawRange=function(){return this._yawPitchControl.option("yawRange")},t.getPitchRange=function(){return this._yawPitchControl.option("pitchRange")},t.setYawRange=function(t){return this._yawPitchControl.option("yawRange",t),this},t.setPitchRange=function(t){return this._yawPitchControl.option("pitchRange",t),this},t.setShowPolePoint=function(t){return this._yawPitchControl.option("showPolePoint",t),this},t.lookAt=function(t,e){if(void 0===e&&(e=0),!this._isReady)return this;var n=void 0!==t.yaw?t.yaw:this._yaw,i=void 0!==t.pitch?t.pitch:this._pitch,r=this._yawPitchControl.option("pitchRange"),r=r[1]-r[0],t=void 0!==t.fov?t.fov:this._fov;return r<t&&(t=r),this._yawPitchControl.lookAt({yaw:n,pitch:i,fov:t},e),0===e&&this._photoSphereRenderer.renderWithYawPitch(n,i,t),this},t.setTouchDirection=function(t){return s._isValidTouchDirection(t)&&this._yawPitchControl.option("touchDirection",t),this},t.getTouchDirection=function(){return this._yawPitchControl.option("touchDirection")},t.destroy=function(){return this._deactivate(),this._yawPitchControl&&(this._yawPitchControl.destroy(),this._yawPitchControl=null),this},t._initRenderer=function(t,e,n,i,r){var o=this;this._photoSphereRenderer=new mo(this._image,this._width,this._height,this._isVideo,this._container,this._canvasClass,{initialYaw:t,initialPitch:e,fieldOfView:n,imageType:i,cubemapConfig:r,stereoFormat:this._stereoFormat}),this._photoSphereRenderer.setYawPitchControl(this._yawPitchControl),this._bindRendererHandler(),this._photoSphereRenderer.bindTexture().then(function(){return o._activate()}).catch(function(){o.trigger(new p(Er.ERROR,{type:wr.FAIL_BIND_TEXTURE,message:"failed to bind texture"}))})},t._updateYawPitchIfNeeded=function(){var t,e,n;this._projectionType===s.ProjectionType.PANORAMA&&(e=t=void 0,(n=(n=this._photoSphereRenderer.getContent()).naturalWidth/n.naturalHeight)<1&&(n=1/n),e=n<6?(t=fi.toDegree(n),2*fi.toDegree(Math.atan(.5))):(t=360)/n,n=this._yawPitchControl.option("fovRange")[0],this._yawPitchControl.option({fov:e,yawRange:[-t/2,t/2],pitchRange:[-e/2,e/2],fovRange:[n,e]}),this.lookAt({fov:e}))},t._bindRendererHandler=function(){var e=this;this._photoSphereRenderer.on(mo.EVENTS.ERROR,function(t){e.trigger(new p(Er.ERROR,t))}),this._photoSphereRenderer.on(mo.EVENTS.RENDERING_CONTEXT_LOST,function(){e._deactivate(),e.trigger(new p(Er.ERROR,{type:wr.RENDERING_CONTEXT_LOST,message:"webgl rendering context lost"}))})},t._initYawPitchControl=function(t){var e=this;this._yawPitchControl=new Ki(t),this._yawPitchControl.on(Er.ANIMATION_END,function(t){e.trigger(new p(Er.ANIMATION_END,t))}),this._yawPitchControl.on("change",function(t){e._yaw=t.yaw,e._pitch=t.pitch,e._fov=t.fov,e._quaternion=t.quaternion,e.trigger(new p(Er.VIEW_CHANGE,t))})},t._activate=function(){this._photoSphereRenderer.attachTo(this._container),this._yawPitchControl.enable(),this.updateViewportDimensions(),this._isReady=!0,this._updateYawPitchIfNeeded(),this.trigger(new p(Er.READY)),this._photoSphereRenderer.startRender()},t._deactivate=function(){var t=this.getVideo();t&&t.pause(),this._isReady&&(this._photoSphereRenderer.stopRender(),this._yawPitchControl.disable(),this._isReady=!1),this._photoSphereRenderer&&(this._photoSphereRenderer.destroy(),this._photoSphereRenderer=null)},s.VERSION=i,s.ERROR_TYPE=wr,s.EVENTS=Er,s.PROJECTION_TYPE=Tr,s.GYRO_MODE=wi,s.ProjectionType=Tr,s.STEREO_FORMAT=Rr,s.TOUCH_DIRECTION={NONE:Ki.TOUCH_DIRECTION_NONE,YAW:Ki.TOUCH_DIRECTION_YAW,PITCH:Ki.TOUCH_DIRECTION_PITCH,ALL:Ki.TOUCH_DIRECTION_ALL},s}(e),W={__proto__:null,PanoViewer:vo,VERSION:i,GYRO_MODE:wi,PANOVIEWER_EVENTS:Er,ERROR_TYPE:wr,PROJECTION_TYPE:Tr,STEREO_FORMAT:Rr,PANOVIEWER_OPTIONS:{image:!0,video:!0,projectionType:!0,cubemapConfig:!0,stereoFormat:!0,width:!0,height:!0,yaw:!0,pitch:!0,fov:!0,showPolePoint:!0,useZoom:!0,useKeyboard:!0,gyroMode:!0,yawRange:!0,pitchRange:!0,fovRange:!0,touchDirection:!0,canvasClass:!0},DEFAULT_CANVAS_CLASS:br},go="view360-wrapper",_o="view360-image",yo=function(h){function u(t,e){void 0===e&&(e={});var n=h.call(this)||this,i=e||{};n._el=t,n._rowCount=i.rowCount||1,n._colCount=i.colCount||1,n._totalCount=n._rowCount*n._colCount,n._width=i.width||"auto",n._height=i.height||"auto",n._autoHeight=null==i.autoHeight||i.autoHeight,n._colRow=[0,0],i.colRow?n._colRow=i.colRow:i.frameIndex&&n.setFrameIndex(i.frameIndex),n._el.style.width=u._getSizeString(n._width),n._el.style.height=u._getSizeString(n._height);var r=i.wrapperClass||go,e=i.imageClass||_o;if(!i.imageUrl)return setTimeout(function(){n.trigger(new p("imageError",{imageUrl:i.imageUrl}))},0),n;var o=t.querySelector("."+e),s=t.querySelector("."+r);s&&o&&(o.style.display="none"),n._image=o||new Image;var a=n._image;return a.onload=function(){s&&o&&(o.style.display=""),n._bg=u._createBgDiv(s,a,n._rowCount,n._colCount,n._autoHeight),n._el.appendChild(n._bg),n.setColRow(n._colRow[0],n._colRow[1]),n.trigger(new p("load",{target:n._el,bgElement:n._bg})),n._autoPlayReservedInfo&&(n.play(n._autoPlayReservedInfo),n._autoPlayReservedInfo=null)},a.onerror=function(){n.trigger(new p("imageError",{imageUrl:i.imageUrl}))},a.src=i.imageUrl,n}a(u,h);var t=u.prototype;return u._createBgDiv=function(t,e,n,i,r){t=t||document.createElement("div");t.style.position="relative",t.style.overflow="hidden",e.style.position="absolute",e.style.width=100*i+"%",e.style.height=100*n+"%",e.ondragstart=function(){return!1},Z&&(e.style.willChange="transform"),t.appendChild(e);i=e.naturalWidth/i,n=e.naturalHeight/n;return r?(i=n/i,t.style.paddingBottom=100*i+"%"):t.style.height="100%",t},u._getSizeString=function(t){return"number"==typeof t?t+"px":t},t.setFrameIndex=function(t){t=this.toColRow(t);this.setColRow(t[0],t[1])},t.getFrameIndex=function(){return this._colRow[1]*this._colCount+this._colRow[0]},t.setColRow=function(t,e){e>this._rowCount-1||t>this._colCount-1||(this._image&&K&&(this._image.style[K]="translate("+-(t/this._colCount)*100+"%, "+-(e/this._rowCount)*100+"%)"),this._colRow=[t,e])},t.getColRow=function(){return this._colRow},t.stop=function(){this._autoPlayTimer&&(clearInterval(this._autoPlayTimer),this._autoPlayTimer=-1)},t.play=function(t){var e,n,i,r=this,o=void 0===t?{interval:1e3/this._totalCount,playCount:0}:t,t=o.interval,s=o.playCount;this._bg?(this._autoPlayTimer&&(clearInterval(this._autoPlayTimer),this._autoPlayTimer=-1),e=this.getFrameIndex(),i=n=0,this._autoPlayTimer=window.setInterval(function(){e%=r._totalCount;var t=r.toColRow(e);r.setColRow(t[0],t[1]),e++,++i===r._totalCount&&(i=0,n++),0<s&&n===s&&clearInterval(r._autoPlayTimer)},t)):this._autoPlayReservedInfo={interval:t,playCount:s}},t.toColRow=function(t){var e=this._colCount,n=this._rowCount;return t<0?[0,0]:t>=this._totalCount?[e-1,n-1]:[t%e,Math.floor(t/e)]},u.VERSION=i,u}(e),xo=function(o){function t(t,e){void 0===e&&(e={});var n=o.call(this)||this;n._el=t;var i=u({},e),r=i.colCount||1,e=i.rowCount||1;return n._scale=i.scale||1,n._panScale=.21*n._scale,n._frameCount=r*e,n._sprites=new yo(t,i).on({load:function(t){n.trigger(new p("load",t))},imageError:function(t){n.trigger(new p("imageError",{imageUrl:t.imageUrl}))}}),n._panInput=new gn(n._el,{scale:[n._panScale,n._panScale]}),n._axes=new un({angle:{range:[0,359],circular:!0}}).on({change:function(t){var e=Math.floor(t.pos.angle/(360/n._frameCount)),e=n._frameCount-e-1;n._sprites.setFrameIndex(e),n.trigger(new p("change",{frameIndex:e,colRow:n._sprites.getColRow(),angle:t.pos.angle}))},animationEnd:function(t){n.trigger(new p("animationEnd",{isTrusted:t.isTrusted}))}}),n._axes.connect("angle",n._panInput),n}a(t,o);var e=t.prototype;return e.setScale=function(t){return isNaN(t)||t<0||(this._scale=t,this._panScale=.21*t,this._panInput.options.scale=[this._panScale,this._panScale]),this},e.getScale=function(){return this._scale},e.spinBy=function(t,e){return void 0===t&&(t=0),void 0===e&&(e={duration:0}),this._axes.setBy({angle:t},e.duration),this},e.spinTo=function(t,e){return void 0===t&&(t=0),void 0===e&&(e={duration:0}),this._axes.setTo({angle:t},e.duration),this},e.getAngle=function(){return this._axes.get().angle||0},t.VERSION=i,t}(e),j={__proto__:null,SpinViewer:xo,SpriteImage:yo,VERSION:i,SPINVIEWER_OPTIONS:{imageUrl:!0,rowCount:!0,colCount:!0,width:!0,height:!0,autoHeight:!0,colRow:!0,scale:!0,frameIndex:!0,wrapperClass:!0,imageClass:!0},SPINVIEWER_EVENTS:{LOAD:"load",IMAGE_ERROR:"imageError",CHANGE:"change",ANIMATION_END:"animationEnd"},DEFAULT_WRAPPER_CLASS:go,DEFAULT_IMAGE_CLASS:_o},wo=function(t,e){return null!=t&&t!==e},Eo=function(t,e,n,i){wo(n[e],i[e])&&t["set"+e[0].toUpperCase()+e.slice(1)](n[e])},st={__proto__:null,withMethods:lo,withPanoViewerMethods:function(t,e){lo(vo,t,e)},withSpinViewerMethods:function(t,e){lo(xo,t,e)},updatePanoViewer:function(e,n,i){wo(n.image,i.image)?e.setImage(n.image,{projectionType:n.projectionType,cubemapConfig:n.cubemapConfig,stereoFormat:n.stereoFormat,isVideo:!1}):wo(n.video,i.video)&&e.setVideo(n.video,{projectionType:n.projectionType,cubemapConfig:n.cubemapConfig,stereoFormat:n.stereoFormat});["fovRange","gyroMode","pitchRange","showPolePoint","touchDirection","useKeyboard","useZoom","yawRange"].forEach(function(t){Eo(e,t,n,i)})}},q={};return Cr(q,W),Cr(q,j),Cr(q,st),q});
10//# sourceMappingURL=view360.pkgd.min.js.map