@egjs/view360
Version:
360 integrated viewing solution from inside-out view to outside-in view. It provides user-friendly service by rotating 360 degrees through various user interaction such as motion sensor and touch.
11 lines (10 loc) • 44.8 kB
JavaScript
/*
Copyright (c) 2017-present NAVER Corp.
name: @egjs/view360
license: MIT
author: NAVER Corp.
repository: https://github.com/naver/egjs-view360
version: 3.6.4
*/
!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 n="3.6.4",i=function(t,e){return(i=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 r(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var s=function(){return(s=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 o(){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 h(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 a(){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 u=function(){function t(t,e){var n,i;if(this._canceled=!1,e)try{for(var r=h(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}}this.eventType=t}var e=t.prototype;return e.stop=function(){this._canceled=!0},e.isCanceled=function(){return this._canceled},t}(),c=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 u?e.eventType:e,i=a(this._eventHandler[i]||[]);return i.length<=0||(e instanceof u?(e.currentTarget=this,i.forEach(function(t){t(e)})):i.forEach(function(t){t.apply(void 0,a(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,a(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 u=h(s),c=u.next();!c.done;c=u.next()){if(c.value===e){s.splice(a,1),s.length<=0&&delete this._eventHandler[t];break}a++}}catch(t){n={error:t}}finally{try{c&&!c.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}}return this},t.VERSION="3.0.2",t}(),f=u;function d(t,e){for(var n=t.length,i=0;i<n;++i)if(e(t[i],i))return!0;return!1}function v(t,e){for(var n=t.length,i=0;i<n;++i)if(e(t[i],i))return t[i];return null}function g(t,e){try{return new RegExp(t,"g").exec(e)}catch(t){return null}}function _(t){return t.replace(/_/g,".")}function p(t,n){var i=null,r="-1";return d(t,function(t){var e=g("("+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=g("("+t+")((?:\\/|\\s|:)([0-9|\\.|_]+))?",t=n))?t[3]:"")||r),r=_(r),1)}),{preset:i,version:r}}function m(t,e){return v(t,function(t){t=t.brand;return g(""+e.test,t.toLowerCase())})}var y=[{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"}],E=[{test:"(?=.*applewebkit/(53[0-7]|5[0-2]|[0-4]))(?=.*\\schrome)",id:"chrome"},{test:"chromium",id:"chrome"},{test:"whale",id:"chrome",brand:!0}],w=[{test:"applewebkit",id:"webkit"}],x=[{test:"(?=(iphone|ipad))(?!(.*version))",id:"webview"},{test:"(?=(android|iphone|ipad))(?=.*(naver|daum|; wv))",id:"webview"},{test:"webview",id:"webview"}],b=[{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 M(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:!!p(x,e).preset,chromium:!!p(E,e).preset,webkit:!1},r={name:"unknown",version:"-1",majorVersion:-1},o=p(y,e),s=o.preset,a=o.version,t=p(b,e),o=t.preset,t=t.version;return i.webkit=!i.chromium&&!!p(w,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 t(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:d(x,function(t){return m(i,t)}),chromium:d(E,function(t){return m(i,t)})},a={name:"unknown",version:"-1",majorVersion:-1},s.webkit=!s.chromium&&d(w,function(t){return m(i,t)}),n&&(e=n.platform.toLowerCase(),o=v(b,function(t){return new RegExp(""+t.test,"g").exec(e)}),a.name=o?o.id:e,a.version=n.platformVersion),d(y,function(t){var e=m(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=_(a.version),s.version=_(s.version),a.majorVersion=parseInt(a.version,10),s.majorVersion=parseInt(s.version,10),{browser:s,os:a,isMobile:r,isHints:!0}):M(t);var n,e,i,r,o,s,a}var e="__observers__",P=function(){function t(t){this._emitter=new c,this._current=t}var e=t.prototype;return Object.defineProperty(e,"current",{get:function(){return this._current},set:function(t){var e=t!==this._current;this._current=t,e&&this._emitter.trigger("update",t)},enumerable:!1,configurable:!0}),e.subscribe=function(t){this._emitter.on("update",t)},e.unsubscribe=function(t){this._emitter.off("update",t)},t}();function T(t){return t[e]||(t[e]={}),t[e]}function O(t,e,n){t=T(t);return t[e]||(t[e]=new P(n)),t[e]}function C(t){t.subscribe=function(t,e){O(this,t).subscribe(e)},t.unsubscribe=function(t,e){var n,i=this;if(!t)return n=T(this),void Object.keys(n).forEach(function(t){i.unsubscribe(t)});t in this&&O(this,t).unsubscribe(e)}}function I(t){C(t.prototype)}var A=function(t,e){return(A=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 S(t,e){function n(){this.constructor=t}A(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var R,D=function(){return(D=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)};R="undefined"==typeof window?{navigator:{userAgent:""}}:window;function j(t){for(var e=[],n=0,i=t.length;n<i;n++)e.push(t[n]);return e}var k,N,L=24,V="left",B="right",F="middle",X="ontouchstart"in R&&"safari"===t().browser.name,Y=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""}(),H={"user-select":"none","-webkit-user-drag":"none"},U=function(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,j(n.childNodes)):j(document.querySelectorAll(t)),e||(n=1<=n.length?n[0]:void 0)):t===R?n=t:"value"in t||"current"in t?n=t.value||t.current:!t.nodeName||1!==t.nodeType&&9!==t.nodeType?"jQuery"in R&&t instanceof jQuery||t.constructor.prototype.jquery?n=e?t.toArray():t.get(0):Array.isArray(t)&&(n=t.map(function(t){return U(t)}),e||(n=1<=n.length?n[0]:void 0)):n=t,n},W=R.requestAnimationFrame||R.webkitRequestAnimationFrame,K=R.cancelAnimationFrame||R.webkitCancelAnimationFrame;W&&!K?(k={},N=W,W=function(e){var n=N(function(t){k[n]&&e(t)});return k[n]=!0,n},K=function(t){delete k[t]}):W&&K||(W=function(t){return R.setTimeout(function(){t(R.performance&&R.performance.now&&R.performance.now()||(new Date).getTime())},16)},K=R.clearTimeout);function q(t,e){var n,i={};for(n in t)n&&(i[n]=e(t[n],n));return i}function z(t,e){var n,i={};for(n in t)n&&e(t[n],n)&&(i[n]=t[n]);return i}function G(t,e){for(var n in t)if(n&&!e(t[n],n))return!1;return!0}function Q(t,n){return G(t,function(t,e){return t===n[e]})}function Z(t,e){return st[e]||(st[e]=at(e)),st[e](t)}function J(t,n){return t&&n?q(t,function(t,e){return Z(t,"number"==typeof n?n:n[e])}):t}function $(t){if(!isFinite(t))return 0;var e="".concat(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 tt(t,e,n){return n?!!(30===e||e&t&&n&t):!!(e&t)}function et(t,e,n,i){return 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),t=Math.min(e[1],t)}function nt(t,e){return t<e[0]||t>e[1]}function it(t,e,n){return n[1]&&t>e[1]||n[0]&&t<e[0]}function rt(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 ot(i,t){return t.reduce(function(t,e,n){return i[n]&&(t[i[n]]=e),t},{})}var st={},at=function(e){var n=e<1?Math.pow(10,$(e)):1;return function(t){return 0===e?0:Math.round(Math.round(t/e)*e*n)/n}},ut=function(){function t(t){this._axes=t}var e=t.prototype;return e.hold=function(t,e){t=this._getRoundPos(t).roundPos;this._axes.trigger(new f("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(new f("release",D(D({},t),{bounceRatio:this._getBounceRatio(n)})))},e.triggerChange=function(t,e,n,i){var r=this;void 0===i&&(i=!1);var o=this.animationManager,s=o.axisManager,o=o.getEventInfo(),t=this._getRoundPos(t,e),e=t.roundPos,t=t.roundDepa,a=s.moveTo(e,t),t=(null==n?void 0:n.event)||(null==o?void 0:o.event)||null,n={pos:a.pos,delta:a.delta,bounceRatio:this._getBounceRatio(a.pos),holding:i,inputEvent:t,isTrusted:!!t,input:(null==n?void 0:n.input)||(null==o?void 0:o.input)||null,set:t?this._createUserControll(a.pos):function(){}},o=new f("change",n);return this._axes.trigger(o),Object.keys(a.pos).forEach(function(t){var e=a.pos[t];O(r._axes,t,e).current=e}),t&&s.set(n.set().destPos),!o.isCanceled()},e.triggerAnimationStart=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);t=new f("animationStart",t);return this._axes.trigger(t),!t.isCanceled()},e.triggerAnimationEnd=function(t){void 0===t&&(t=!1),this._axes.trigger(new f("animationEnd",{isTrusted:t}))},e.triggerFinish=function(t){void 0===t&&(t=!1),this._axes.trigger(new f("finish",{isTrusted:t}))},e.setAnimationManager=function(t){this.animationManager=t},e.destroy=function(){this._axes.off()},e._createUserControll=function(t,e){void 0===e&&(e=0);var n={destPos:D({},t),duration:e};return function(t,e){return t&&(n.destPos=D({},t)),void 0!==e&&(n.duration=e),n}},e._getRoundPos=function(t,e){var n=this._axes.options.round;return{roundPos:J(t,n),roundDepa:J(e,n)}},e._getBounceRatio=function(t){return this._axes.axisManager.map(t,function(t,e){return t<e.range[0]&&0!==e.bounce[0]?(e.range[0]-t)/e.bounce[0]:t>e.range[1]&&0!==e.bounce[1]?(t-e.range[1])/e.bounce[1]:0})},t}(),ct=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}(),ht=function(){function t(t){var n=this;this._axis=t,this._complementOptions(),this._pos=Object.keys(this._axis).reduce(function(t,e){return t[e]=n._axis[e].startPos,t},{})}var e=t.prototype;return e.getDelta=function(t,e){var n=this.get(t);return q(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},{}):D(D({},this._pos),t||{})},e.moveTo=function(n,i){void 0===i&&(i=this._pos);var t=q(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?rt(t,e.range,e.circular):0})),{pos:D({},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 G(t,function(t,e){return n(t,i[e],e)})},e.filter=function(t,n){var i=this._axis;return z(t,function(t,e){return n(t,i[e],e)})},e.map=function(t,n){var i=this._axis;return q(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!nt(t,e.range)})},e.getAxisOptions=function(t){return this._axis[t]},e.setAxis=function(e){var n=this;Object.keys(e).forEach(function(t){if(!n._axis[t])throw new Error("Axis ".concat(t," does not exist in Axes instance"));n._axis[t]=D(D({},n._axis[t]),e[t])}),this._complementOptions()},e._complementOptions=function(){var r=this;Object.keys(this._axis).forEach(function(i){r._axis[i]=D({range:[0,100],startPos:r._axis[i].range[0],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])})})},t}(),lt="ontouchstart"in R,ft="PointerEvent"in R,dt="MSPointerEvent"in R,vt=ft||dt,gt=function(){function t(){var e=this;this._stopContextMenu=function(t){t.preventDefault(),R.removeEventListener("contextmenu",e._stopContextMenu)}}var e=t.prototype;return e.extendEvent=function(t){var e=this.prevEvent,n=this._getCenter(t),i=e?this._getMovement(t):{x:0,y:0},r=e?this._getScale(t):1,o=e?(f=n.x-e.center.x,l=n.y-e.center.y,180*Math.atan2(l,f)/Math.PI):0,s=e?e.deltaX+i.x:i.x,a=e?e.deltaY+i.y:i.y,u=i.x,c=i.y,h=this._latestInterval,l=Date.now(),f=h?l-h.timestamp:0,i=e?e.velocityX:0,e=e?e.velocityY:0;return(!h||16<=f)&&(h&&(i=(f=[(s-h.deltaX)/f,(a-h.deltaY)/f])[0],e=f[1]),this._latestInterval={timestamp:l,deltaX:s,deltaY:a}),{srcEvent:t,scale:r,angle:o,center:n,deltaX:s,deltaY:a,offsetX:u,offsetY:c,velocityX:i,velocityY:e,preventSystemEvent:!0}},e._getDistance=function(t,e){var n=e.clientX-t.clientX,t=e.clientY-t.clientY;return Math.sqrt(n*n+t*t)},e._getButton=function(t){var e={1:V,2:B,4:F},t=this._isTouchEvent(t)?V:e[t.buttons];return t||null},e._isTouchEvent=function(t){return t.type&&-1<t.type.indexOf("touch")},e._isValidButton=function(t,e){return-1<e.indexOf(t)},e._isValidEvent=function(t,e,n){return(!e||(i=t,!!(!(e=e)||-1<e.indexOf("any")||-1<e.indexOf("none")&&!i.shiftKey&&!i.ctrlKey&&!i.altKey&&!i.metaKey||-1<e.indexOf("shift")&&i.shiftKey||-1<e.indexOf("ctrl")&&i.ctrlKey||-1<e.indexOf("alt")&&i.altKey||-1<e.indexOf("meta")&&i.metaKey)))&&(!n||this._isValidButton(this._getButton(t),n));var i},e._preventMouseButton=function(t,e){e===B?R.addEventListener("contextmenu",this._stopContextMenu):e===F&&t.preventDefault()},t}(),_t=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.start=["mousedown"],t.move=["mousemove"],t.end=["mouseup"],t}S(t,e);var n=t.prototype;return n.onEventStart=function(t,e,n){var i=this._getButton(t);return this._isValidEvent(t,e,n)?(this._preventMouseButton(t,i),this.extendEvent(t)):null},n.onEventMove=function(t,e,n){return this._isValidEvent(t,e,n)?this.extendEvent(t):null},n.onEventEnd=function(){},n.onRelease=function(){this.prevEvent=null},n.getTouches=function(t,e){if(e){var n={1:V,2:F,3:B};return this._isValidButton(n[t.which],e)&&-1===this.end.indexOf(t.type)?1:0}return 0},n._getScale=function(){return 1},n._getCenter=function(t){return{x:t.clientX,y:t.clientY}},n._getMovement=function(t){var e=this.prevEvent.srcEvent;return{x:t.clientX-e.clientX,y:t.clientY-e.clientY}},t}(gt),pt=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.start=["touchstart"],t.move=["touchmove"],t.end=["touchend","touchcancel"],t}S(t,e);var n=t.prototype;return n.onEventStart=function(t,e){return this._baseTouches=t.touches,this._isValidEvent(t,e)?this.extendEvent(t):null},n.onEventMove=function(t,e){return this._isValidEvent(t,e)?this.extendEvent(t):null},n.onEventEnd=function(t){this._baseTouches=t.touches},n.onRelease=function(){this.prevEvent=null,this._baseTouches=null},n.getTouches=function(t){return t.touches.length},n._getScale=function(t){return 2!==t.touches.length||this._baseTouches.length<2?null:this._getDistance(t.touches[0],t.touches[1])/this._getDistance(this._baseTouches[0],this._baseTouches[1])},n._getCenter=function(t){return{x:t.touches[0].clientX,y:t.touches[0].clientY}},n._getMovement=function(t){var e=this.prevEvent.srcEvent;return t.touches[0].identifier!==e.touches[0].identifier?{x:0,y:0}:{x:t.touches[0].clientX-e.touches[0].clientX,y:t.touches[0].clientY-e.touches[0].clientY}},t}(gt),mt=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.start=ft?["pointerdown"]:["MSPointerDown"],t.move=ft?["pointermove"]:["MSPointerMove"],t.end=ft?["pointerup","pointercancel"]:["MSPointerUp","MSPointerCancel"],t._firstInputs=[],t._recentInputs=[],t}S(t,e);var n=t.prototype;return n.onEventStart=function(t,e,n){var i=this._getButton(t);return this._isValidEvent(t,e,n)?(this._preventMouseButton(t,i),this._updatePointerEvent(t),this.extendEvent(t)):null},n.onEventMove=function(t,e,n){return this._isValidEvent(t,e,n)?(this._updatePointerEvent(t),this.extendEvent(t)):null},n.onEventEnd=function(t){this._removePointerEvent(t)},n.onRelease=function(){this.prevEvent=null,this._firstInputs=[],this._recentInputs=[]},n.getTouches=function(){return this._recentInputs.length},n._getScale=function(){return 2!==this._recentInputs.length?null:this._getDistance(this._recentInputs[0],this._recentInputs[1])/this._getDistance(this._firstInputs[0],this._firstInputs[1])},n._getCenter=function(t){return{x:t.clientX,y:t.clientY}},n._getMovement=function(t){var e=this.prevEvent.srcEvent;return t.pointerId!==e.pointerId?{x:0,y:0}:{x:t.clientX-e.clientX,y:t.clientY-e.clientY}},n._updatePointerEvent=function(n){var i=this,r=!1;this._recentInputs.forEach(function(t,e){t.pointerId===n.pointerId&&(r=!0,i._recentInputs[e]=n)}),r||(this._firstInputs.push(n),this._recentInputs.push(n))},n._removePointerEvent=function(e){this._firstInputs=this._firstInputs.filter(function(t){return t.pointerId!==e.pointerId}),this._recentInputs=this._recentInputs.filter(function(t){return t.pointerId!==e.pointerId})},t}(gt),yt=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.start=["mousedown","touchstart"],t.move=["mousemove","touchmove"],t.end=["mouseup","touchend","touchcancel"],t}S(t,e);var n=t.prototype;return n.onEventStart=function(t,e,n){var i=this._getButton(t);return this._isTouchEvent(t)&&(this._baseTouches=t.touches),this._isValidEvent(t,e,n)?(this._preventMouseButton(t,i),this.extendEvent(t)):null},n.onEventMove=function(t,e,n){return this._isValidEvent(t,e,n)?this.extendEvent(t):null},n.onEventEnd=function(t){this._isTouchEvent(t)&&(this._baseTouches=t.touches)},n.onRelease=function(){this.prevEvent=null,this._baseTouches=null},n.getTouches=function(t){return this._isTouchEvent(t)?t.touches.length:0},n._getScale=function(t){return this._isTouchEvent(t)?2!==t.touches.length||this._baseTouches.length<2?1:this._getDistance(t.touches[0],t.touches[1])/this._getDistance(this._baseTouches[0],this._baseTouches[1]):this.prevEvent.scale},n._getCenter=function(t){return this._isTouchEvent(t)?{x:t.touches[0].clientX,y:t.touches[0].clientY}:{x:t.clientX,y:t.clientY}},n._getMovement=function(t){var e=this,n=[t,this.prevEvent.srcEvent].map(function(t){return e._isTouchEvent(t)?{id:t.touches[0].identifier,x:t.touches[0].clientX,y:t.touches[0].clientY}:{id:null,x:t.clientX,y:t.clientY}}),t=n[0],n=n[1];return t.id===n.id?{x:t.x-n.x,y:t.y-n.y}:{x:0,y:0}},t}(gt);function Et(t){return-1<t.indexOf("touch")&&{passive:!1}}function wt(t,e,n){return Math.max(Math.min(t,n),e)}var xt=function(){function t(t){var e=t.options,n=t.interruptManager,i=t.eventManager,r=t.axisManager,t=t.animationManager;this._isOutside=!1,this._moveDistance=null,this._isStopped=!1,this.options=e,this._interruptManager=n,this._eventManager=i,this._axisManager=r,this._animationManager=t}var e=t.prototype;return e.get=function(t){return this._axisManager.get(t.axes)},e.hold=function(t,e){!this._interruptManager.isInterrupted()&&t.axes.length&&(e={input:t,event:e},this._isStopped=!1,this._interruptManager.setInterrupt(!0),this._animationManager.stopAnimation(e),this._moveDistance||this._eventManager.hold(this._axisManager.get(),e),this._isOutside=this._axisManager.isOutside(t.axes),this._moveDistance=this._axisManager.get(t.axes))},e.change=function(t,e,n,i){var r,o,s;this._isStopped||!this._interruptManager.isInterrupting()||this._axisManager.every(n,function(t){return 0===t})||((r=e.srcEvent||e).__childrenAxesAlreadyChanged||(o=this._moveDistance||this._axisManager.get(t.axes),s=q(o,function(t,e){return t+(n[e]||0)}),this._moveDistance&&(this._moveDistance=this._axisManager.map(s,function(t,e){var n=e.circular,e=e.range;return n&&(n[0]||n[1])?rt(t,e,n):t})),this._isOutside&&this._axisManager.every(o,function(t,e){return!nt(t,e.range)})&&(this._isOutside=!1),o=this._atOutside(o),s=this._atOutside(s),this.options.nested&&this._isEndofAxis(n,o,s)||(r.__childrenAxesAlreadyChanged=!0),e={input:t,event:e},i?(i=this._animationManager.getDuration(s,o),this._animationManager.animateTo(s,i,e)):this._eventManager.triggerChange(s,o,e,!0)||(this._isStopped=!0,this._moveDistance=null,this._animationManager.finish(!1))))},e.release=function(t,e,n,i){var r,o,s;!this._isStopped&&this._interruptManager.isInterrupting()&&this._moveDistance&&((r=e.srcEvent||e).__childrenAxesAlreadyReleased&&(n=n.map(function(){return 0})),o=this._axisManager.get(t.axes),s=this._axisManager.get(),n=this._animationManager.getDisplacement(n),n=ot(t.axes,n),n=this._axisManager.get(this._axisManager.map(n,function(t,e,n){return e.circular&&(e.circular[0]||e.circular[1])?o[n]+t:et(o[n]+t,e.range,e.circular,e.bounce)})),r.__childrenAxesAlreadyReleased=!0,0===(i=this._animationManager.getDuration(n,o,i))&&(n=D({},s)),n={depaPos:s,destPos:n,duration:i,delta:this._axisManager.getDelta(s,n),inputEvent:e,input:t,isTrusted:!0},this._eventManager.triggerRelease(n),this._moveDistance=null,n=this._animationManager.getUserControl(n),t={input:t,event:e},(e=Q(n.destPos,s))||0===n.duration?(e||this._eventManager.triggerChange(n.destPos,s,t,!0),this._interruptManager.setInterrupt(!1),this._axisManager.isOutside()?this._animationManager.restore(t):this._eventManager.triggerFinish(!0)):this._animationManager.animateTo(n.destPos,n.duration,t))},e._atOutside=function(t){var o=this;return this._isOutside?this._axisManager.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}):this._axisManager.map(t,function(t,e){var n=e.range[0],i=e.range[1],r=e.bounce,e=e.circular;return e[0]&&t<n||e[1]&&i<t?t:t<n?n-o._animationManager.interpolate(n-t,r[0]):i<t?i+o._animationManager.interpolate(t-i,r[1]):t})},e._isEndofAxis=function(r,o,s){return this._axisManager.every(o,function(t,e,n){return 0===r[n]||o[n]===s[n]&&(i=t,n=e.range,t=e.bounce,!(e=e.circular)[0]&&i===n[0]-t[0]||!e[1]&&i===n[1]+t[1]);var i})},t}(),bt=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._useDuration=!0,t}S(t,e);var n=t.prototype;return n.interpolate=function(t,e){var n=this._easing(1e-5)/1e-5;return this._easing(t/(e*n))*e},n.updateAnimation=function(t){var e,n,i,r,o=this._animateParam;o&&(e=(new Date).getTime()-o.startTime,n=(null==t?void 0:t.destPos)||o.destPos,i=null!==(r=null==t?void 0:t.duration)&&void 0!==r?r:o.duration,null!=t&&t.restart||i<=e?this.setTo(n,i-e):(null!=t&&t.destPos&&(r=this.axisManager.get(),this._initialEasingPer=this._prevEasingPer,o.delta=this.axisManager.getDelta(r,n),o.destPos=n),null!=t&&t.duration&&(t=(e+this._durationOffset)/o.duration,this._durationOffset=t*i-e,o.duration=i)))},n._initState=function(t){return this._initialEasingPer=0,this._prevEasingPer=0,this._durationOffset=0,{pos:t.depaPos,easingPer:0,finished:!1}},n._getNextState=function(t){var r=this,o=this._animateParam,s=t.pos,a=o.destPos,u=q(s,function(t,e){return t<=a[e]?1:-1}),c=((new Date).getTime()-o.startTime+this._durationOffset)/o.duration,h=this._easing(c);return{pos:this.axisManager.map(s,function(t,e,n){var i=1<=c?a[n]:t+o.delta[n]*(h-r._prevEasingPer)/(1-r._initialEasingPer),t=rt(i,e.range,e.circular);return i!==t&&(e=u[n]*(e.range[1]-e.range[0]),a[n]-=e,s[n]-=e),t}),easingPer:this._prevEasingPer=h,finished:1<=h}},n._easing=function(t){return 1<t?1:this._options.easing(t)},t}(function(){function t(t){var e=t.options,n=t.interruptManager,i=t.eventManager,t=t.axisManager;this._options=e,this.interruptManager=n,this.eventManager=i,this.axisManager=t,this.animationEnd=this.animationEnd.bind(this)}var e=t.prototype;return e.getDuration=function(n,t,e){var i,r=this;return t=void 0!==e?e:(i=q(t,function(t,e){return function(t,e){e=Math.sqrt(t/e*2);return e<100?0:e}(Math.abs(t-n[e]),r._options.deceleration)}),Object.keys(i).reduce(function(t,e){return Math.max(t,i[e])},-1/0)),wt(t,this._options.minimumDuration,this._options.maximumDuration)},e.getDisplacement=function(t){var e=Math.pow(t.reduce(function(t,e){return t+e*e},0),1/t.length),n=Math.abs(e/-this._options.deceleration);return t.map(function(t){return t/2*n})},e.stopAnimation=function(t){var n,e;this._animateParam&&(n=this.axisManager.get(),e=this.axisManager.map(n,function(t,e){return rt(t,e.range,e.circular)}),G(e,function(t,e){return n[e]===t})||this.eventManager.triggerChange(e,n,t,!!t),this._animateParam=null,this._raf&&(e=this._raf,K(e)),this._raf=null,this.eventManager.triggerAnimationEnd(!(null==t||!t.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.axisManager.get(),n=this.axisManager.map(e,function(t,e){return Math.min(e.range[1],Math.max(e.range[0],t))});this.stopAnimation(),this.animateTo(n,this.getDuration(e,n),t)},e.animationEnd=function(){var t=this.getEventInfo();this._animateParam=null;var e=this.axisManager.filter(this.axisManager.get(),function(t,e){return it(t,e.range,e.circular)});0<Object.keys(e).length&&this.setTo(this.axisManager.map(e,function(t,e){return rt(t,e.range,e.circular)})),this.interruptManager.setInterrupt(!1),this.eventManager.triggerAnimationEnd(!!t),this.axisManager.isOutside()?this.restore(t):this.finish(!!t)},e.finish=function(t){this._animateParam=null,this.interruptManager.setInterrupt(!1),this.eventManager.triggerFinish(t)},e.getUserControl=function(t){t=t.setTo();return t.destPos=this.axisManager.get(t.destPos),t.duration=wt(t.duration,this._options.minimumDuration,this._options.maximumDuration),t},e.animateTo=function(t,e,n){var i=this;this.stopAnimation();var r=this._createAnimationParam(t,e,n),t=D({},r.depaPos),e=this.eventManager.triggerAnimationStart(r),r=this.getUserControl(r);!e&&this.axisManager.every(r.destPos,function(t,e){return it(t,e.range,e.circular)})&&console.warn("You can't stop the 'animation' event when 'circular' is true."),e&&!Q(r.destPos,t)&&(e=(null==n?void 0:n.event)||null,this._animateLoop({depaPos:t,destPos:r.destPos,duration:r.duration,delta:this.axisManager.getDelta(t,r.destPos),isTrusted:!!e,inputEvent:e,input:(null==n?void 0:n.input)||null},function(){return i.animationEnd()}))},e.setTo=function(t,e){void 0===e&&(e=0);var n=Object.keys(t),i=this.axisManager.get(n);if(Q(t,i))return this;this.interruptManager.setInterrupt(!0);t=z(t,function(t,e){return i[e]!==t});return Object.keys(t).length?(t=this.axisManager.map(t,function(t,e){var n=e.range,e=e.circular;return e&&(e[0]||e[1])?t:et(t,n,e)}),Q(t,i)||(0<e?this.animateTo(t,e):(this.stopAnimation(),this.eventManager.triggerChange(t),this.finish(!1))),this):this},e.setBy=function(n,t){return void 0===t&&(t=0),this.setTo(q(this.axisManager.get(Object.keys(n)),function(t,e){return t+n[e]}),t)},e._createAnimationParam=function(t,e,n){var i=this.axisManager.get(),r=t,t=(null==n?void 0:n.event)||null;return{depaPos:i,destPos:r,duration:wt(e,this._options.minimumDuration,this._options.maximumDuration),delta:this.axisManager.getDelta(i,r),inputEvent:t,input:(null==n?void 0:n.input)||null,isTrusted:!!t,done:this.animationEnd}},e._animateLoop=function(t,i){var r,o,s,a=this;t.duration?(this._animateParam=D(D({},t),{startTime:(new Date).getTime()}),r=q(t.destPos,function(t){return t}),o=this._initState(this._animateParam),(s=function(){a._raf=null;var t=a._animateParam,e=a._getNextState(o),n=!a.eventManager.triggerChange(e.pos,o.pos);(o=e).finished?(t.destPos=a._getFinalPos(t.destPos,r),Q(t.destPos,a.axisManager.get(Object.keys(t.destPos)))||a.eventManager.triggerChange(t.destPos,e.pos),i()):n?a.finish(!1):a._raf=W(s)})()):(this.eventManager.triggerChange(t.destPos),i())},e._getFinalPos=function(t,n){var i=this;return q(t,function(t,e){if(t>=n[e]-1e-6&&t<=n[e]+1e-6)return n[e];e=i._getRoundUnit(t,e);return Z(t,e)})},e._getRoundUnit=function(t,e){var n=this._options.round,i=null;return n||(e=this.axisManager.getAxisOptions(e),t=Math.max($(e.range[0]),$(e.range[1]),$(t)),i=1/Math.pow(10,t)),i||n},t}()),Mt=function(r){function t(t,e,n){void 0===t&&(t={}),void 0===e&&(e={}),void 0===n&&(n={});var i=r.call(this)||this;return i.axis=t,i._inputs=[],i.options=D({easing:function(t){return 1-Math.pow(1-t,3)},interruptable:!0,maximumDuration:1/0,minimumDuration:0,deceleration:6e-4,round:null,nested:!1},e),Object.keys(n).forEach(function(t){i.axis[t].startPos=n[t]}),i.interruptManager=new ct(i.options),i.axisManager=new ht(i.axis),i.eventManager=new ut(i),i.animationManager=new bt(i),i.inputObserver=new xt(i),i.eventManager.setAnimationManager(i.animationManager),i.eventManager.triggerChange(i.axisManager.get()),i}S(t,r);var e=t.prototype;return e.connect=function(t,e){t="string"==typeof t?t.split(" "):t.concat();return~this._inputs.indexOf(e)&&this.disconnect(e),e.mapAxes(t),e.connect(this.inputObserver),this._inputs.push(e),this},e.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},e.get=function(t){return this.axisManager.get(t)},e.setTo=function(t,e){return void 0===e&&(e=0),this.animationManager.setTo(t,e),this},e.setBy=function(t,e){return void 0===e&&(e=0),this.animationManager.setBy(t,e),this},e.setOptions=function(t){return this.options=D(D({},this.options),t),this},e.setAxis=function(t){return this.axisManager.setAxis(t),this},e.stopAnimation=function(){return this.animationManager.stopAnimation(),this.animationManager.finish(!1),this},e.updateAnimation=function(t){return this.animationManager.updateAnimation(t),this},e.isBounceArea=function(t){return this.axisManager.isOutside(t)},e.destroy=function(){this.disconnect(),this.eventManager.destroy()},t.VERSION="3.8.3",t.TRANSFORM=Y,t.DIRECTION_NONE=1,t.DIRECTION_LEFT=2,t.DIRECTION_RIGHT=4,t.DIRECTION_UP=8,t.DIRECTION_DOWN=16,t.DIRECTION_HORIZONTAL=6,t.DIRECTION_VERTICAL=L,t.DIRECTION_ALL=30,function(t,e,n,i){var r,o=arguments.length,s=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,i);else for(var a=t.length-1;0<=a;a--)(r=t[a])&&(s=(o<3?r(s):3<o?r(e,n,s):r(e,n))||s);return 3<o&&s&&Object.defineProperty(e,n,s),s}([I],t)}(c),Pt=function(){function t(t,e){var n=this;this.axes=[],this.element=null,this._enabled=!1,this._activeEvent=null,this._atRightEdge=!1,this._rightEdgeTimer=0,this._dragged=!1,this._isOverThreshold=!1,this._preventClickWhenDragged=function(t){n._dragged&&(t.preventDefault(),t.stopPropagation()),n._dragged=!1},this._voidFunction=function(){},this.element=U(t),this.options=D({inputType:["touch","mouse","pointer"],inputKey:["any"],inputButton:[V],scale:[1,1],thresholdAngle:45,threshold:0,preventClickOnDrag:!1,iOSEdgeSwipeThreshold:30,releaseOnScroll:!1,touchAction:null},e),this._onPanstart=this._onPanstart.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,n;this._direction=(e=!!t[0],n=!!t[1],e&&n?30:e?6:n?L:1),this.axes=t},e.connect=function(t){var e,n,i,r,o;return this._activeEvent&&(this._detachElementEvent(),this._detachWindowEvent(this._activeEvent)),this._attachElementEvent(t),this._originalCssProps=(e=this.element,n=this.options,i=this._direction,(t={})[1]="auto",t[30]="none",t[L]="pan-x",t[6]="pan-y",t,o={},e&&e.style&&(i=n.touchAction||t[i],r=D(D({},H),{"touch-action":"none"===e.style["touch-action"]?"none":i}),Object.keys(r).forEach(function(t){o[t]=e.style[t],e.style[t]=r[t]})),o),this},e.disconnect=function(){var e,n,i,r;return this._detachElementEvent(),this._detachWindowEvent(this._activeEvent),i=this._originalCssProps,r=!0,Object.keys(H).forEach(function(t){i&&i[t]===H[t]||(r=!1)}),r||(e=this.element,n=this._originalCssProps,e&&e.style&&n&&Object.keys(n).forEach(function(t){e.style[t]=n[t]})),this._direction=1,this},e.destroy=function(){this.disconnect(),this.element=null},e.enable=function(){return this._enabled=!0,this},e.disable=function(){return this._enabled=!1,this},e.isEnabled=function(){return this._enabled},e.release=function(){var t=this._activeEvent,e=t.prevEvent;return t.onRelease(),this._observer.release(this,e,[0,0]),this._detachWindowEvent(t),this},e._onPanstart=function(t){var e=this.options,n=e.inputKey,i=e.inputButton,e=this._activeEvent,n=e.onEventStart(t,n,i);!n||!this._enabled||1<e.getTouches(t,i)||!1!==n.srcEvent.cancelable&&(i=this.options.iOSEdgeSwipeThreshold,this._dragged=!1,this._isOverThreshold=!1,this._observer.hold(this,n),this._atRightEdge=X&&n.center.x>window.innerWidth-i,this._attachWindowEvent(e),e.prevEvent=n)},e._onPanmove=function(t){var e=this,n=this.options,i=n.iOSEdgeSwipeThreshold,r=n.preventClickOnDrag,o=n.releaseOnScroll,s=n.inputKey,a=n.inputButton,u=n.threshold,c=n.thresholdAngle,n=this._activeEvent,s=n.onEventMove(t,s,a),a=n.getTouches(t,a);if(0===a||o&&s&&!s.srcEvent.cancelable)this._onPanend(t);else if(s&&this._enabled&&!(1<a)){a=function(t,e){if(e<0||90<e)return 1;t=Math.abs(t);return e<t&&t<180-e?L:6}(s.angle,c),c=tt(6,this._direction,a),a=tt(L,this._direction,a);if(n.prevEvent&&X){if(s.center.x<0)return void this.release();this._atRightEdge&&(clearTimeout(this._rightEdgeTimer),s.deltaX<-i?this._atRightEdge=!1:this._rightEdgeTimer=window.setTimeout(function(){return e.release()},100))}i=this._getDistance([s.deltaX,s.deltaY],[c,a]),c=this._getOffset([s.offsetX,s.offsetY],[c,a]),a=c.some(function(t){return 0!==t});a&&(!1!==s.srcEvent.cancelable&&s.srcEvent.preventDefault(),s.srcEvent.stopPropagation()),(s.preventSystemEvent=a)&&(this._isOverThreshold||u<=i)&&(this._dragged=r,this._isOverThreshold=!0,this._observer.change(this,s,ot(this.axes,c))),n.prevEvent=s}},e._onPanend=function(t){var e=this.options.inputButton,n=this._activeEvent;n.onEventEnd(t),this._enabled&&0===n.getTouches(t,e)&&(this._detachWindowEvent(n),clearTimeout(this._rightEdgeTimer),t=n.prevEvent,e=this._isOverThreshold?this._getOffset([Math.abs(t.velocityX)*(t.offsetX<0?-1:1),Math.abs(t.velocityY)*(t.offsetY<0?-1:1)],[tt(6,this._direction),tt(L,this._direction)]):[0,0],n.onRelease(),this._observer.release(this,t,e))},e._attachWindowEvent=function(t){var e=this;null!=t&&t.move.forEach(function(t){window.addEventListener(t,e._onPanmove,Et(t))}),null!=t&&t.end.forEach(function(t){window.addEventListener(t,e._onPanend,Et(t))})},e._detachWindowEvent=function(t){var e=this;null!=t&&t.move.forEach(function(t){window.removeEventListener(t,e._onPanmove)}),null!=t&&t.end.forEach(function(t){window.removeEventListener(t,e._onPanend)})},e._getOffset=function(t,e){var n=this.options.scale;return[e[0]?t[0]*n[0]:0,e[1]?t[1]*n[1]:0]},e._getDistance=function(t,e){return Math.sqrt(Number(e[0])*Math.pow(t[0],2)+Number(e[1])*Math.pow(t[1],2))},e._attachElementEvent=function(t){var e=this,n=function(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=lt;break;case"pointer":i=vt}}),i?new mt:e&&n?new yt:e?new pt:n?new _t:null}(this.options.inputType),i=this.element;if(n){if(!i)throw new Error("Element to connect input does not exist.");this._observer=t,this._enabled=!0,this._activeEvent=n,i.addEventListener("click",this._preventClickWhenDragged,!0),n.start.forEach(function(t){i.addEventListener(t,e._onPanstart)}),n.move.forEach(function(t){i.addEventListener(t,e._voidFunction)})}},e._detachElementEvent=function(){var e=this,t=this._activeEvent,n=this.element;n&&(n.removeEventListener("click",this._preventClickWhenDragged,!0),null!=t&&t.start.forEach(function(t){n.removeEventListener(t,e._onPanstart)}),null!=t&&t.move.forEach(function(t){n.removeEventListener(t,e._voidFunction)})),this._enabled=!1,this._observer=null},t}(),dt="undefined"!=typeof window&&window.Math===Math?window:"undefined"!=typeof self&&self.Math===Math?self:Function("return this")(),Tt=dt.document,gt=(dt.navigator,t());gt.os.name,gt.browser.name;dt.Float32Array=void 0!==dt.Float32Array?dt.Float32Array:dt.Array;dt.Float32Array,dt.getComputedStyle,dt.navigator&&dt.navigator.userAgent,dt.DeviceMotionEvent,dt.devicePixelRatio;var Ot=function(){for(var t,e=null!==(t=null==Tt?void 0:Tt.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""}(),Ct=dt.CSS&&dt.CSS.supports&&dt.CSS.supports("will-change","transform"),It="view360-wrapper",At="view360-image",gt={__proto__:null,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:It,DEFAULT_IMAGE_CLASS:At},St=function(u){function c(t,e){void 0===e&&(e={});var n=u.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=c._getSizeString(n._width),n._el.style.height=c._getSizeString(n._height);var r=i.wrapperClass||It,e=i.imageClass||At;if(!i.imageUrl)return setTimeout(function(){n.trigger(new f("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=c._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 f("load",{target:n._el,bgElement:n._bg})),n._autoPlayReservedInfo&&(n.play(n._autoPlayReservedInfo),n._autoPlayReservedInfo=null)},a.onerror=function(){n.trigger(new f("imageError",{imageUrl:i.imageUrl}))},a.src=i.imageUrl,n}r(c,u);var t=c.prototype;return c._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},Ct&&(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},c._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&&Ot&&(this._image.style[Ot]="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)]},c.VERSION=n,c}(c),dt={SpinViewer:function(o){function t(t,e){void 0===e&&(e={});var n=o.call(this)||this;n._el=t;var i=s({},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 St(t,i).on({load:function(t){n.trigger(new f("load",t))},imageError:function(t){n.trigger(new f("imageError",{imageUrl:t.imageUrl}))}}),n._panInput=new Pt(n._el,{scale:[n._panScale,n._panScale]}),n._axes=new Mt({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 f("change",{frameIndex:e,colRow:n._sprites.getColRow(),angle:t.pos.angle}))},animationEnd:function(t){n.trigger(new f("animationEnd",{isTrusted:t.isTrusted}))}}),n._axes.connect("angle",n._panInput),n}r(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=n,t}(c),SpriteImage:St,VERSION:n};return function(i){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];t.forEach(function(n){Object.keys(n).forEach(function(t){var e=n[t];Array.isArray(i[t])&&Array.isArray(e)?i[t]=o(i[t],e):i[t]=e})})}(dt,gt),dt});
//# sourceMappingURL=view360.spinviewer.pkgd.min.js.map