/*! * Photo Sphere Viewer 3.3.2 * Copyright (c) 2014-2015 Jérémy Heleine * Copyright (c) 2015-2018 Damien "Mistic" Sorel * Licensed under MIT (http://opensource.org/licenses/MIT) */ !function(t,e){"function"==typeof define&&define.amd?define(["three","d.js","uevent","dot/doT"],e):"object"==typeof module&&module.exports?module.exports=e(require("three"),require("d.js"),require("uevent"),require("dot/doT")):t.PhotoSphereViewer=e(t.THREE,t.D,t.uEvent,t.doT)}(this,function(t,e,i,o){"use strict";function n(e){if(!(this instanceof n))return new n(e);if(n.SYSTEM.loaded||n._loadSystem(),this.config=M.clone(n.DEFAULTS),M.deepmerge(this.config,e),!e.container)throw new b("No value given for container.");if(!n.SYSTEM.isCanvasSupported)throw new b("Canvas is not supported.");if(!(n.SYSTEM.isWebGLSupported&&this.config.webgl||M.checkTHREE("CanvasRenderer","Projector")))throw new b("Missing Three.js components: CanvasRenderer, Projector. Get them from three.js-examples package.");if(this.config.longitude_range&&2!==this.config.longitude_range.length&&(this.config.longitude_range=null,console.warn("PhotoSphereViewer: longitude_range must have exactly two elements.")),this.config.latitude_range?2!==this.config.latitude_range.length?(this.config.latitude_range=null,console.warn("PhotoSphereViewer: latitude_range must have exactly two elements.")):this.config.latitude_range[0]>this.config.latitude_range[1]&&(this.config.latitude_range=[this.config.latitude_range[1],this.config.latitude_range[0]],console.warn("PhotoSphereViewer: latitude_range values must be ordered.")):void 0===this.config.tilt_up_max&&void 0===this.config.tilt_down_max||(this.config.latitude_range=[void 0!==this.config.tilt_down_max?this.config.tilt_down_max-Math.PI/4:-M.HalfPI,void 0!==this.config.tilt_up_max?this.config.tilt_up_max+Math.PI/4:M.HalfPI],console.warn("PhotoSphereViewer: tilt_up_max and tilt_down_max are deprecated, use latitude_range instead.")),this.config.max_fov"),a=t.substring(e,r);if(-1===e||-1===r||-1===a.indexOf("GPano:"))i.resolve(null);else{var h={full_width:parseInt(M.getXMPValue(a,"FullPanoWidthPixels")),full_height:parseInt(M.getXMPValue(a,"FullPanoHeightPixels")),cropped_width:parseInt(M.getXMPValue(a,"CroppedAreaImageWidthPixels")),cropped_height:parseInt(M.getXMPValue(a,"CroppedAreaImageHeightPixels")),cropped_x:parseInt(M.getXMPValue(a,"CroppedAreaLeftPixels")),cropped_y:parseInt(M.getXMPValue(a,"CroppedAreaTopPixels"))};h.full_width&&h.full_height&&h.cropped_width&&h.cropped_height?i.resolve(h):(console.warn("PhotoSphereViewer: invalid XMP data"),i.resolve(null))}}else 3===o.readyState&&n.loader.setProgress(s+=10)},o.onprogress=function(t){if(t.lengthComputable){var e=parseInt(t.loaded/t.total*100);e>s&&(s=e,n.loader.setProgress(s))}},o.onerror=function(){throw n.container.textContent="Cannot load image",new b("Cannot load image")},o.open("GET",t,!0),o.send(null),i.promise},n.prototype._loadTexture=function(t){var e=[];if(Array.isArray(t)){if(6!==t.length)throw new b("Must provide exactly 6 image paths when using cubemap.");for(var i=0;i<6;i++)e[i]=t[n.CUBE_MAP[i]];t=e}else if("object"==typeof t){if(!n.CUBE_HASHMAP.every(function(e){return!!t[e]}))throw new b("Must provide exactly left, front, right, back, top, bottom when using cubemap.");n.CUBE_HASHMAP.forEach(function(i,o){e[o]=t[i]}),t=e}if(Array.isArray(t)){if(!1===this.prop.isCubemap)throw new b("The viewer was initialized with an equirectangular panorama, cannot switch to cubemap.");return this.config.fisheye&&console.warn("PhotoSphereViewer: fisheye effect with cubemap texture can generate distorsions."),this.config.cache_texture===n.DEFAULTS.cache_texture&&(this.config.cache_texture*=6),this.prop.isCubemap=!0,this._loadCubemapTexture(t)}if(!0===this.prop.isCubemap)throw new b("The viewer was initialized with an cubemap, cannot switch to equirectangular panorama.");return this.prop.isCubemap=!1,this._loadEquirectangularTexture(t)},n.prototype._loadEquirectangularTexture=function(i){if(this.config.cache_texture){var o=this.getPanoramaCache(i);if(o)return this.prop.pano_data=o.pano_data,e.resolved(o.image)}return this._loadXMP(i).then(function(o){var s=e(),r=new t.ImageLoader,a=o?100:0;r.setCrossOrigin("anonymous");return r.load(i,function(e){a=100,this.loader.setProgress(a),this.trigger("panorama-load-progress",i,a),!o&&this.config.pano_data&&(o=M.clone(this.config.pano_data)),o||(o={full_width:e.width,full_height:e.height,cropped_width:e.width,cropped_height:e.height,cropped_x:0,cropped_y:0}),this.prop.pano_data=o;var r,h=Math.min(o.full_width,n.SYSTEM.maxTextureWidth)/o.full_width;if(1!==h||o.cropped_width!=o.full_width||o.cropped_height!=o.full_height){var p=M.clone(o);p.full_width*=h,p.full_height*=h,p.cropped_width*=h,p.cropped_height*=h,p.cropped_x*=h,p.cropped_y*=h,e.width=p.cropped_width,e.height=p.cropped_height;var c=document.createElement("canvas");c.width=p.full_width,c.height=p.full_height,c.getContext("2d").drawImage(e,p.cropped_x,p.cropped_y,p.cropped_width,p.cropped_height),r=new t.Texture(c)}else r=new t.Texture(e);r.needsUpdate=!0,r.minFilter=t.LinearFilter,r.generateMipmaps=!1,this.config.cache_texture&&this._putPanoramaCache({panorama:i,image:r,pano_data:o}),s.resolve(r)}.bind(this),function(t){if(t.lengthComputable){var e=parseInt(t.loaded/t.total*100);e>a&&(a=e,this.loader.setProgress(a),this.trigger("panorama-load-progress",i,a))}}.bind(this),function(t){throw this.container.textContent="Cannot load image",s.reject(t),new b("Cannot load image")}.bind(this)),s.promise}.bind(this))},n.prototype._loadCubemapTexture=function(i){var o=e(),s=new t.ImageLoader,r=[0,0,0,0,0,0],a=[],h=0;s.setCrossOrigin("anonymous");for(var p=function(e,s){h++,r[e]=100,this.loader.setProgress(M.sum(r)/6),this.trigger("panorama-load-progress",i[e],r[e]);var p=Math.min(s.width,n.SYSTEM.maxTextureWidth/2)/s.width;if(1!==p){var c=document.createElement("canvas");c.width=s.width*p,c.height=s.height*p;c.getContext("2d").drawImage(s,0,0,c.width,c.height),a[e]=new t.Texture(c)}else a[e]=new t.Texture(s);this.config.cache_texture&&this._putPanoramaCache({panorama:i[e],image:a[e]}),6===h&&(a.forEach(function(e){e.needsUpdate=!0,e.minFilter=t.LinearFilter,e.generateMipmaps=!1}),o.resolve(a))},c=function(t,e){if(e.lengthComputable){var o=parseInt(e.loaded/e.total*100);o>r[t]&&(r[t]=o,this.loader.setProgress(M.sum(r)/6),this.trigger("panorama-load-progress",i[t],r[t]))}},l=function(t,e){throw this.container.textContent="Cannot load image",o.reject(e),new b("Cannot load image "+t)},u=0;u<6;u++){if(this.config.cache_texture){var d=this.getPanoramaCache(i[u]);if(d){h++,r[u]=100,a[u]=d.image;continue}}s.load(i[u],p.bind(this,u),c.bind(this,u),l.bind(this,u))}return 6===h&&o.resolve(a),o.promise},n.prototype._setTexture=function(t){if(this.scene||this._createScene(),this.prop.isCubemap)for(var e=0;e<6;e++)this.mesh.material[e].map&&this.mesh.material[e].map.dispose(),this.mesh.material[e].map=t[e];else this.mesh.material.map&&this.mesh.material.map.dispose(),this.mesh.material.map=t;this.trigger("panorama-loaded"),this.render()},n.prototype._createScene=function(){this.raycaster=new t.Raycaster,this.renderer=n.SYSTEM.isWebGLSupported&&this.config.webgl?new t.WebGLRenderer:new t.CanvasRenderer,this.renderer.setSize(this.prop.size.width,this.prop.size.height),this.renderer.setPixelRatio(n.SYSTEM.pixelRatio);var e=n.SPHERE_RADIUS;this.prop.isCubemap&&(e*=Math.sqrt(3)),this.config.fisheye&&(e+=n.SPHERE_RADIUS),this.camera=new t.PerspectiveCamera(this.config.default_fov,this.prop.size.width/this.prop.size.height,1,e),this.camera.position.set(0,0,0),this.config.gyroscope&&M.checkTHREE("DeviceOrientationControls")&&(this.doControls=new t.DeviceOrientationControls(this.camera)),this.scene=new t.Scene,this.scene.add(this.camera),this.prop.isCubemap?this._createCubemap():this._createSphere(),this.canvas_container=document.createElement("div"),this.canvas_container.className="psv-canvas-container",this.renderer.domElement.className="psv-canvas",this.container.appendChild(this.canvas_container),this.canvas_container.appendChild(this.renderer.domElement)},n.prototype._createSphere=function(){var e=new t.SphereGeometry(n.SPHERE_RADIUS,n.SPHERE_VERTICES,n.SPHERE_VERTICES,-M.HalfPI),i=new t.MeshBasicMaterial({side:t.DoubleSide,overdraw:n.SYSTEM.isWebGLSupported&&this.config.webgl?0:1});this.mesh=new t.Mesh(e,i),this.mesh.scale.x=-1,this.mesh.rotation.x=this.config.sphere_correction.tilt,this.mesh.rotation.y=this.config.sphere_correction.pan,this.mesh.rotation.z=this.config.sphere_correction.roll,this.scene.add(this.mesh)},n.prototype._createCubemap=function(){for(var e=new t.BoxGeometry(2*n.SPHERE_RADIUS,2*n.SPHERE_RADIUS,2*n.SPHERE_RADIUS,n.CUBE_VERTICES,n.CUBE_VERTICES,n.CUBE_VERTICES),i=[],o=0;o<6;o++)i.push(new t.MeshBasicMaterial({side:t.BackSide,overdraw:n.SYSTEM.isWebGLSupported&&this.config.webgl?0:1}));this.mesh=new t.Mesh(e,i),this.mesh.position.x-=n.SPHERE_RADIUS,this.mesh.position.y-=n.SPHERE_RADIUS,this.mesh.position.z-=n.SPHERE_RADIUS,this.mesh.applyMatrix((new t.Matrix4).makeScale(1,1,-1)),this.scene.add(this.mesh)},n.prototype._transition=function(e,i){if(this.prop.isCubemap)throw new b("Transition is not available with cubemap.");var o=this,s=new t.SphereGeometry(.9*n.SPHERE_RADIUS,n.SPHERE_VERTICES,n.SPHERE_VERTICES,-M.HalfPI),r=new t.MeshBasicMaterial({side:t.DoubleSide,overdraw:n.SYSTEM.isWebGLSupported&&this.config.webgl?0:1,map:e,transparent:!0,opacity:0}),a=new t.Mesh(s,r);if(a.scale.x=-1,i){a.rotateY(i.longitude-this.prop.longitude);var h=new t.Vector3(0,1,0).cross(this.camera.getWorldDirection()).normalize(),p=(new t.Quaternion).setFromAxisAngle(h,i.latitude-this.prop.latitude);a.quaternion.multiplyQuaternions(p,a.quaternion)}return this.scene.add(a),this.render(),M.animation({properties:{opacity:{start:0,end:1}},duration:o.config.transition.duration,easing:"outCubic",onTick:function(t){r.opacity=t.opacity,o.render()}}).then(function(){o.mesh.material.map.dispose(),o.mesh.material.map=e,o.scene.remove(a),a.geometry.dispose(),a.geometry=null,a.material.dispose(),a.material=null,i?((o.config.latitude_range||o.config.longitude_range)&&(o.config.longitude_range=o.config.latitude_range=null,console.warn("PhotoSphereViewer: trying to perform transition with longitude_range and/or latitude_range, ranges cleared.")),o.rotate(i)):o.render()})},n.prototype._reverseAutorotate=function(){var t=this,e=-this.config.anim_speed,i=this.config.longitude_range;this.config.longitude_range=null,M.animation({properties:{speed:{start:this.config.anim_speed,end:0}},duration:300,easing:"inSine",onTick:function(e){t.config.anim_speed=e.speed}}).then(function(){return M.animation({properties:{speed:{start:0,end:e}},duration:300,easing:"outSine",onTick:function(e){t.config.anim_speed=e.speed}})}).then(function(){t.config.longitude_range=i,t.config.anim_speed=e})},n.prototype._putPanoramaCache=function(t){if(!this.config.cache_texture)throw new b("Cannot add panorama to cache, cache_texture is disabled");var e=this.getPanoramaCache(t.panorama);e?(e.image=t.image,e.pano_data=t.pano_data):(this.prop.cache=this.prop.cache.slice(0,this.config.cache_texture-1),this.prop.cache.unshift(t)),this.trigger("panorama-cached",t.panorama)},n.prototype._stopAll=function(){this.stopAutorotate(),this.stopAnimation(),this.stopGyroscopeControl()},n.MOVE_THRESHOLD=4,n.ANGLE_THRESHOLD=.003,n.DBLCLICK_DELAY=300,n.INERTIA_WINDOW=300,n.SPHERE_RADIUS=100,n.SPHERE_VERTICES=64,n.CUBE_VERTICES=8,n.CUBE_MAP=[0,2,4,5,3,1],n.CUBE_HASHMAP=["left","right","top","bottom","back","front"],n.KEYMAP={33:"PageUp",34:"PageDown",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",107:"+",109:"-"},n.SYSTEM={loaded:!1,pixelRatio:1,isWebGLSupported:!1,isCanvasSupported:!1,deviceOrientationSupported:null,maxTextureWidth:0,mouseWheelEvent:null,fullscreenEvent:null},n.ICONS={},n.DEFAULTS={panorama:null,container:null,caption:null,usexmpdata:!0,pano_data:null,webgl:!0,min_fov:30,max_fov:90,default_fov:null,default_long:0,default_lat:0,sphere_correction:{pan:0,tilt:0,roll:0},longitude_range:null,latitude_range:null,move_speed:1,time_anim:2e3,anim_speed:"2rpm",anim_lat:null,fisheye:!1,navbar:["autorotate","zoom","download","markers","caption","gyroscope","fullscreen"],tooltip:{offset:5,arrow_size:7,delay:100},lang:{autorotate:"Automatic rotation",zoom:"Zoom",zoomOut:"Zoom out",zoomIn:"Zoom in",download:"Download",fullscreen:"Fullscreen",markers:"Markers",gyroscope:"Gyroscope"},mousewheel:!0,mousewheel_factor:1,mousemove:!0,keyboard:!0,gyroscope:!1,move_inertia:!0,click_event_on_marker:!1,transition:{duration:1500,loader:!0},loading_img:null,loading_txt:"Loading...",size:null,cache_texture:0,templates:{},markers:[]},n.TEMPLATES={markersList:'

{{= it.config.lang.markers }}

'},n.prototype._bindEvents=function(){window.addEventListener("resize",this),this.config.mousemove&&(this.hud.container.style.cursor="move",this.hud.container.addEventListener("mousedown",this),this.hud.container.addEventListener("touchstart",this),window.addEventListener("mouseup",this),window.addEventListener("touchend",this),this.hud.container.addEventListener("mousemove",this),this.hud.container.addEventListener("touchmove",this)),n.SYSTEM.fullscreenEvent&&document.addEventListener(n.SYSTEM.fullscreenEvent,this),this.config.mousewheel&&this.hud.container.addEventListener(n.SYSTEM.mouseWheelEvent,this),this.on("_side-reached",function(t){this.isAutorotateEnabled()&&("left"!==t&&"right"!==t||this._reverseAutorotate())})},n.prototype.handleEvent=function(t){switch(t.type){case"resize":M.throttle(this._onResize(),50);break;case"keydown":this._onKeyDown(t);break;case"mousedown":this._onMouseDown(t);break;case"touchstart":this._onTouchStart(t);break;case"mouseup":this._onMouseUp(t);break;case"touchend":this._onTouchEnd(t);break;case"mousemove":this._onMouseMove(t);break;case"touchmove":this._onTouchMove(t);break;case n.SYSTEM.fullscreenEvent:this._fullscreenToggled();break;case n.SYSTEM.mouseWheelEvent:this._onMouseWheel(t)}},n.prototype._onResize=function(){this.container.clientWidth==this.prop.size.width&&this.container.clientHeight==this.prop.size.height||(this.prop.size.width=parseInt(this.container.clientWidth),this.prop.size.height=parseInt(this.container.clientHeight),this.prop.aspect=this.prop.size.width/this.prop.size.height,this.renderer&&(this.renderer.setSize(this.prop.size.width,this.prop.size.height),this.composer&&this.composer.reset(new t.WebGLRenderTarget(this.prop.size.width,this.prop.size.height)),this.render()),this.trigger("size-updated",this.getSize()))},n.prototype._onKeyDown=function(t){var e=0,i=0,o=0;switch(t.key||n.KEYMAP[t.keyCode||t.which]){case"ArrowUp":i=.01;break;case"ArrowDown":i=-.01;break;case"ArrowRight":e=.01;break;case"ArrowLeft":e=-.01;break;case"PageUp":case"+":o=1;break;case"PageDown":case"-":o=-1}0!==o?this.zoom(this.prop.zoom_lvl+o):0===i&&0===e||this.rotate({longitude:this.prop.longitude+e*this.prop.move_speed*this.prop.hFov,latitude:this.prop.latitude+i*this.prop.move_speed*this.prop.vFov})},n.prototype._onMouseDown=function(t){this._startMove(t)},n.prototype._onMouseUp=function(t){this._stopMove(t)},n.prototype._onMouseMove=function(t){0!==t.buttons&&(t.preventDefault(),this._move(t))},n.prototype._onTouchStart=function(t){1===t.touches.length?this._startMove(t.touches[0]):2===t.touches.length&&this._startZoom(t)},n.prototype._onTouchEnd=function(t){this._stopMove(t.changedTouches[0])},n.prototype._onTouchMove=function(t){1===t.touches.length?(t.preventDefault(),this._move(t.touches[0])):2===t.touches.length&&(t.preventDefault(),this._zoom(t))},n.prototype._startMove=function(t){this.isGyroscopeEnabled()||(this._stopAll(),this.prop.mouse_x=this.prop.start_mouse_x=parseInt(t.clientX),this.prop.mouse_y=this.prop.start_mouse_y=parseInt(t.clientY),this.prop.moving=!0,this.prop.zooming=!1,this.prop.mouse_history.length=0,this._logMouseMove(t))},n.prototype._startZoom=function(t){var e=[{x:parseInt(t.touches[0].clientX),y:parseInt(t.touches[0].clientY)},{x:parseInt(t.touches[1].clientX),y:parseInt(t.touches[1].clientY)}];this.prop.pinch_dist=Math.sqrt(Math.pow(e[0].x-e[1].x,2)+Math.pow(e[0].y-e[1].y,2)),this.prop.moving=!1,this.prop.zooming=!0},n.prototype._stopMove=function(t){M.getClosest(t.target,".psv-hud")&&(this.isGyroscopeEnabled()?this._click(t):(this.prop.moving&&(Math.abs(t.clientX-this.prop.start_mouse_x)n.INERTIA_WINDOW/10?(this.prop.mouse_history.splice(0,o),o=0,i=this.prop.mouse_history[0][o]):(o++,i=this.prop.mouse_history[0][o])},n.prototype.load=function(){if(!this.config.panorama)throw new b("No value given for panorama.");return this.setPanorama(this.config.panorama,!1)},n.prototype.getPosition=function(){return{longitude:this.prop.longitude,latitude:this.prop.latitude}},n.prototype.getZoomLevel=function(){return this.prop.zoom_lvl},n.prototype.getSize=function(){return{width:this.prop.size.width,height:this.prop.size.height}},n.prototype.isAutorotateEnabled=function(){return!!this.prop.autorotate_reqid},n.prototype.isGyroscopeEnabled=function(){return!!this.prop.orientation_reqid},n.prototype.isFullscreenEnabled=function(){return M.isFullscreenEnabled(this.container)},n.prototype.render=function(t){!1!==t&&(this.prop.direction=this.sphericalCoordsToVector3(this.prop),this.camera.position.set(0,0,0),this.camera.lookAt(this.prop.direction)),this.config.fisheye&&this.camera.position.copy(this.prop.direction).multiplyScalar(this.config.fisheye/2).negate(),this.camera.aspect=this.prop.aspect,this.camera.fov=this.prop.vFov,this.camera.updateProjectionMatrix(),this.composer?this.composer.render():this.renderer.render(this.scene,this.camera),this.trigger("render")},n.prototype.destroy=function(){this._stopAll(),this.stopKeyboardControl(),this.isFullscreenEnabled()&&M.exitFullscreen(),window.removeEventListener("resize",this),this.config.mousemove&&(this.hud.container.removeEventListener("mousedown",this),this.hud.container.removeEventListener("touchstart",this),window.removeEventListener("mouseup",this),window.removeEventListener("touchend",this),this.hud.container.removeEventListener("mousemove",this),this.hud.container.removeEventListener("touchmove",this)),n.SYSTEM.fullscreenEvent&&document.removeEventListener(n.SYSTEM.fullscreenEvent,this),this.config.mousewheel&&this.hud.container.removeEventListener(n.SYSTEM.mouseWheelEvent,this),this.tooltip&&this.tooltip.destroy(),this.hud&&this.hud.destroy(),this.loader&&this.loader.destroy(),this.navbar&&this.navbar.destroy(),this.panel&&this.panel.destroy(),this.doControls&&this.doControls.disconnect(),this.scene&&M.cleanTHREEScene(this.scene),this.canvas_container&&this.container.removeChild(this.canvas_container),this.parent.removeChild(this.container),delete this.parent.photoSphereViewer,delete this.parent,delete this.container,delete this.loader,delete this.navbar,delete this.hud,delete this.panel,delete this.tooltip,delete this.canvas_container,delete this.renderer,delete this.composer,delete this.scene,delete this.camera,delete this.mesh,delete this.doControls,delete this.raycaster,delete this.passes,delete this.config,this.prop.cache.length=0},n.prototype.setPanorama=function(t,e,i){if(null!==this.prop.loading_promise)throw new b("Loading already in progress");if("boolean"==typeof e&&(i=e,e=void 0),i&&this.prop.isCubemap)throw new b("Transition is not available with cubemap.");e&&(this.cleanPosition(e),this._stopAll()),this.config.panorama=t;var o=this;return i&&this.config.transition&&this.scene?(this.config.transition.loader&&this.loader.show(),this.prop.loading_promise=this._loadTexture(this.config.panorama).then(function(t){return o.loader.hide(),o._transition(t,e)}).ensure(function(){o.loader.hide(),o.prop.loading_promise=null}).rethrow()):(this.loader.show(),this.canvas_container&&(this.canvas_container.style.opacity=0),this.prop.loading_promise=this._loadTexture(this.config.panorama).then(function(t){o._setTexture(t),e&&o.rotate(e)}).ensure(function(){o.loader.hide(),o.canvas_container.style.opacity=1,o.prop.loading_promise=null}).rethrow()),this.prop.loading_promise},n.prototype.startAutorotate=function(){this._stopAll();var t=this,e=null,i=null;!function o(n){n&&(i=null===e?0:n-e,e=n,t.rotate({longitude:t.prop.longitude+t.config.anim_speed*i/1e3,latitude:t.prop.latitude-(t.prop.latitude-t.config.anim_lat)/200})),t.prop.autorotate_reqid=window.requestAnimationFrame(o)}(null),this.trigger("autorotate",!0)},n.prototype.stopAutorotate=function(){this.prop.start_timeout&&(window.clearTimeout(this.prop.start_timeout),this.prop.start_timeout=null),this.prop.autorotate_reqid&&(window.cancelAnimationFrame(this.prop.autorotate_reqid),this.prop.autorotate_reqid=null,this.trigger("autorotate",!1))},n.prototype.toggleAutorotate=function(){this.isAutorotateEnabled()?this.stopAutorotate():this.startAutorotate()},n.prototype.startGyroscopeControl=function(){if(this.doControls&&this.doControls.enabled&&this.doControls.deviceOrientation){this._stopAll();var t=this;!function e(){t.doControls.update(),t.prop.direction=t.camera.getWorldDirection();var i=t.vector3ToSphericalCoords(t.prop.direction);t.prop.longitude=i.longitude,t.prop.latitude=i.latitude,t.render(!1),t.prop.orientation_reqid=window.requestAnimationFrame(e)}(),this.trigger("gyroscope-updated",!0)}else console.warn("PhotoSphereViewer: gyroscope disabled")},n.prototype.stopGyroscopeControl=function(){this.prop.orientation_reqid&&(window.cancelAnimationFrame(this.prop.orientation_reqid),this.prop.orientation_reqid=null,this.trigger("gyroscope-updated",!1),this.render())},n.prototype.toggleGyroscopeControl=function(){this.isGyroscopeEnabled()?this.stopGyroscopeControl():this.startGyroscopeControl()},n.prototype.rotate=function(t,e){this.cleanPosition(t),this.applyRanges(t).forEach(this.trigger.bind(this,"_side-reached")),this.prop.longitude=t.longitude,this.prop.latitude=t.latitude,!1!==e&&this.renderer&&(this.render(),this.trigger("position-updated",this.getPosition()))},n.prototype.animate=function(t,i){if(this._stopAll(),this.cleanPosition(t),!i||Math.abs(t.longitude-this.prop.longitude)0&&this.zoom(this.prop.zoom_lvl-1)},n.prototype.resize=function(t){t.width&&(this.container.style.width=t.width),t.height&&(this.container.style.height=t.height),this._onResize()},n.prototype.toggleFullscreen=function(){this.isFullscreenEnabled()?M.exitFullscreen():M.requestFullscreen(this.container)},n.prototype.startKeyboardControl=function(){window.addEventListener("keydown",this)},n.prototype.stopKeyboardControl=function(){window.removeEventListener("keydown",this)},n.prototype.preloadPanorama=function(t){if(!this.config.cache_texture)throw new b("Cannot preload panorama, cache_texture is disabled");return this._loadTexture(t)},n.prototype.clearPanoramaCache=function(t){if(!this.config.cache_texture)throw new b("Cannot clear cache, cache_texture is disabled");if(t){for(var e=0,i=this.prop.cache.length;e=Math.PI?e-Math.PI:e+Math.PI,latitude:M.HalfPI-i}},n.prototype.sphericalCoordsToTextureCoords=function(t){if(this.prop.isCubemap)throw new b("Unable to use texture coords with cubemap.");var e=t.longitude/M.TwoPI*this.prop.pano_data.full_width,i=t.latitude/Math.PI*this.prop.pano_data.full_height;return{x:parseInt(t.longitudei[1]?e.longitude>i[1]&&e.longitudei[0]/2+i[1]/2?(e.longitude=i[0],n.push("left")):(e.longitude=i[1],n.push("right"))):e.longitudei[1]&&(e.longitude=i[1],n.push("right"))),this.config.latitude_range&&(i=M.clone(this.config.latitude_range),o=t.Math.degToRad(this.prop.vFov)/2,i[0]=M.parseAngle(Math.min(i[0]+o,i[1]),!0),i[1]=M.parseAngle(Math.max(i[1]-o,i[0]),!0),e.latitudei[1]&&(e.latitude=i[1],n.push("top"))),n};function s(t){this.psv=t instanceof n?t:t.psv,this.parent=t,this.container=null,this.constructor.publicMethods&&this.constructor.publicMethods.forEach(function(t){this.psv[t]=this[t].bind(this)},this)}s.className=null,s.publicMethods=[],s.prototype.create=function(){this.container=document.createElement("div"),this.constructor.className&&(this.container.className=this.constructor.className),this.parent.container.appendChild(this.container)},s.prototype.destroy=function(){this.parent.container.removeChild(this.container),this.constructor.publicMethods&&this.constructor.publicMethods.forEach(function(t){delete this.psv[t]},this),delete this.container,delete this.psv,delete this.parent},s.prototype.hide=function(){this.container.style.display="none"},s.prototype.show=function(){this.container.style.display=""};function r(t){s.call(this,t),this.svgContainer=null,this.markers={},this.currentMarker=null,this.hoveringMarker=null,this.prop={panelOpened:!1,panelOpening:!1,markersButton:this.psv.navbar.getNavbarButton("markers",!0)},this.create()}r.prototype=Object.create(s.prototype),r.prototype.constructor=r,r.className="psv-hud",r.publicMethods=["addMarker","removeMarker","updateMarker","clearMarkers","getMarker","getCurrentMarker","gotoMarker","hideMarker","showMarker","toggleMarker","toggleMarkersList","showMarkersList","hideMarkersList"],r.prototype.create=function(){s.prototype.create.call(this),this.svgContainer=document.createElementNS(M.svgNS,"svg"),this.svgContainer.setAttribute("class","psv-hud-svg-container"),this.container.appendChild(this.svgContainer),this.container.addEventListener("mouseenter",this,!0),this.container.addEventListener("mouseleave",this,!0),this.container.addEventListener("mousemove",this,!0),this.psv.on("click",this),this.psv.on("dblclick",this),this.psv.on("render",this),this.psv.on("open-panel",this),this.psv.on("close-panel",this)},r.prototype.destroy=function(){this.clearMarkers(!1),this.container.removeEventListener("mouseenter",this),this.container.removeEventListener("mouseleave",this),this.container.removeEventListener("mousemove",this),this.psv.off("click",this),this.psv.off("dblclick",this),this.psv.off("render",this),this.psv.off("open-panel",this),this.psv.off("close-panel",this),delete this.svgContainer,s.prototype.destroy.call(this)},r.prototype.handleEvent=function(t){switch(t.type){case"mouseenter":this._onMouseEnter(t);break;case"mouseleave":this._onMouseLeave(t);break;case"mousemove":this._onMouseMove(t);break;case"click":this._onClick(t.args[0],t,!1);break;case"dblclick":this._onClick(t.args[0],t,!0);break;case"render":this.renderMarkers();break;case"open-panel":this._onPanelOpened();break;case"close-panel":this._onPanelClosed()}},r.prototype.addMarker=function(t,e){if(!t.id)throw new b("missing marker id");if(this.markers[t.id])throw new b('marker "'+t.id+'" already exists');var i=new x(t,this.psv);return i.isNormal()?this.container.appendChild(i.$el):this.svgContainer.appendChild(i.$el),this.markers[i.id]=i,!1!==e&&this.renderMarkers(),i},r.prototype.getMarker=function(t){var e="object"==typeof t?t.id:t;if(!this.markers[e])throw new b('cannot find marker "'+e+'"');return this.markers[e]},r.prototype.getCurrentMarker=function(){return this.currentMarker},r.prototype.updateMarker=function(t,e){var i=this.getMarker(t);return i.update(t),!1!==e&&this.renderMarkers(),i},r.prototype.removeMarker=function(t,e){(t=this.getMarker(t)).isNormal()?this.container.removeChild(t.$el):this.svgContainer.removeChild(t.$el),this.hoveringMarker==t&&this.psv.tooltip.hideTooltip(),t.destroy(),delete this.markers[t.id],!1!==e&&this.renderMarkers()},r.prototype.clearMarkers=function(t){Object.keys(this.markers).forEach(function(t){this.removeMarker(t,!1)},this),!1!==t&&this.renderMarkers()},r.prototype.gotoMarker=function(t,e){return t=this.getMarker(t),this.psv.animate(t,e).then(function(){this.psv.trigger("goto-marker-done",t)}.bind(this))},r.prototype.hideMarker=function(t){this.getMarker(t).visible=!1,this.renderMarkers()},r.prototype.showMarker=function(t){this.getMarker(t).visible=!0,this.renderMarkers()},r.prototype.toggleMarker=function(t){this.getMarker(t).visible^=!0,this.renderMarkers()},r.prototype.toggleMarkersList=function(){this.prop.panelOpened?this.hideMarkersList():this.showMarkersList()},r.prototype.showMarkersList=function(){var t=[];for(var e in this.markers)t.push(this.markers[e]);var i=this.psv.config.templates.markersList({markers:this.psv.change("render-markers-list",t),config:this.psv.config});this.prop.panelOpening=!0,this.psv.panel.showPanel(i,!0),this.psv.panel.container.querySelector(".psv-markers-list").addEventListener("click",this._onClickItem.bind(this))},r.prototype.hideMarkersList=function(){this.prop.panelOpened&&this.psv.panel.hidePanel()},r.prototype.renderMarkers=function(){var e=this.psv.isGyroscopeEnabled()?t.Math.radToDeg(this.psv.camera.rotation.z):0;for(var i in this.markers){var o=this.markers[i],n=o.visible;if(n&&o.isPoly()){var s=this._getPolyPositions(o);if(n=s.length>(o.isPolygon()?2:1)){o.position2D=this._getPolyDimensions(o,s);var r="";s.forEach(function(t){r+=t.x+","+t.y+" "}),o.$el.setAttributeNS(null,"points",r)}}else if(n){var a=this._getMarkerPosition(o);if(n=this._isMarkerVisible(o,a)){o.position2D=a;var h=o.getScale(this.psv.getZoomLevel());o.isSvg()?o.$el.setAttributeNS(null,"transform","translate("+a.x+", "+a.y+")"+(1!==h?" scale("+h+", "+h+")":"")+(!o.lockRotation&&e?" rotate("+e+")":"")):o.$el.style.transform="translate3D("+a.x+"px, "+a.y+"px, 0px)"+(1!==h?" scale("+h+", "+h+")":"")+(!o.lockRotation&&e?" rotateZ("+e+"deg)":"")}}M.toggleClass(o.$el,"psv-marker--visible",n)}},r.prototype._isMarkerVisible=function(t,e){return t.position3D.dot(this.psv.prop.direction)>0&&e.x+t.width>=0&&e.x-t.width<=this.psv.prop.size.width&&e.y+t.height>=0&&e.y-t.height<=this.psv.prop.size.height},r.prototype._getMarkerPosition=function(t){if(t._dynamicSize){M.toggleClass(t.$el,"psv-marker--transparent",!0);var e=t.$el.style.transform;t.$el.style.transform=null;var i=t.$el.getBoundingClientRect();t.$el.style.transform=e,M.toggleClass(t.$el,"psv-marker--transparent",!1),t.width=i.right-i.left,t.height=i.bottom-i.top}var o=this.psv.vector3ToViewerCoords(t.position3D);return o.x-=t.width*t.anchor.left,o.y-=t.height*t.anchor.top,o},r.prototype._getPolyPositions=function(t){var e=t.positions3D.length,i=t.positions3D.map(function(t){return{vector:t,visible:t.dot(this.psv.prop.direction)>0}},this),o=[];return i.forEach(function(t,n){if(!t.visible){[0===n?i[e-1]:i[n-1],n===e-1?i[0]:i[n+1]].forEach(function(e){e.visible&&o.push({visible:e,invisible:t,index:n})})}}),o.reverse().forEach(function(t){i.splice(t.index,0,{vector:this._getPolyIntermediaryPoint(t.visible.vector,t.invisible.vector),visible:!0})},this),i.filter(function(t){return t.visible}).map(function(t){return this.psv.vector3ToViewerCoords(t.vector)},this)},r.prototype._getPolyIntermediaryPoint=function(e,i){var o=this.psv.prop.direction.clone().normalize(),s=(new t.Vector3).crossVectors(e,i).normalize(),r=(new t.Vector3).crossVectors(s,e).normalize(),a=(new t.Vector3).addVectors(e.clone().multiplyScalar(-o.dot(r)),r.clone().multiplyScalar(o.dot(e))).normalize(),h=(new t.Vector3).crossVectors(a,o);return a.applyAxisAngle(h,.01).multiplyScalar(n.SPHERE_RADIUS)},r.prototype._getPolyDimensions=function(t,e){var i=1/0,o=1/0,n=-1/0,s=-1/0;return e.forEach(function(t){i=Math.min(i,t.x),o=Math.min(o,t.y),n=Math.max(n,t.x),s=Math.max(s,t.y)}),t.width=n-i,t.height=s-o,{x:i,y:o}},r.prototype._onMouseEnter=function(t){var e;t.target&&(e=t.target.psvMarker)&&!e.isPoly()&&(this.hoveringMarker=e,this.psv.trigger("over-marker",e),e.tooltip&&this.psv.tooltip.showTooltip({content:e.tooltip.content,position:e.tooltip.position,left:e.position2D.x,top:e.position2D.y,box:{width:e.width,height:e.height}}))},r.prototype._onMouseLeave=function(t){var e;if(t.target&&(e=t.target.psvMarker)){if(e.isPoly()&&t.relatedTarget&&M.hasParent(t.relatedTarget,this.psv.tooltip.container))return;this.psv.trigger("leave-marker",e),this.hoveringMarker=null,this.psv.tooltip.hideTooltip()}},r.prototype._onMouseMove=function(t){if(!this.psv.prop.moving){var e;if(t.target&&(e=t.target.psvMarker)&&e.isPoly()||t.target&&M.hasParent(t.target,this.psv.tooltip.container)&&(e=this.hoveringMarker)){this.hoveringMarker||(this.psv.trigger("over-marker",e),this.hoveringMarker=e);var i=this.psv.container.getBoundingClientRect();e.tooltip&&this.psv.tooltip.showTooltip({content:e.tooltip.content,position:e.tooltip.position,top:t.clientY-i.top-this.psv.config.tooltip.arrow_size/2,left:t.clientX-i.left-this.psv.config.tooltip.arrow_size,box:{width:2*this.psv.config.tooltip.arrow_size,height:2*this.psv.config.tooltip.arrow_size}})}else this.hoveringMarker&&this.hoveringMarker.isPoly()&&(this.psv.trigger("leave-marker",e),this.hoveringMarker=null,this.psv.tooltip.hideTooltip())}},r.prototype._onClick=function(t,e,i){var o;t.target&&(o=M.getClosest(t.target,".psv-marker"))&&o.psvMarker?(this.currentMarker=o.psvMarker,this.psv.trigger("select-marker",this.currentMarker,i),this.psv.config.click_event_on_marker?t.marker=o.psvMarker:e.stopPropagation()):this.currentMarker&&(this.psv.trigger("unselect-marker",this.currentMarker),this.currentMarker=null),o&&o.psvMarker&&o.psvMarker.content?this.psv.panel.showPanel(o.psvMarker.content):this.psv.panel.prop.opened&&(e.stopPropagation(),this.psv.panel.hidePanel())},r.prototype._onClickItem=function(t){var e;if(t.target&&(e=M.getClosest(t.target,"li"))&&e.dataset.psvMarker){var i=this.getMarker(e.dataset.psvMarker);this.psv.trigger("select-marker-list",i),this.gotoMarker(i,1e3),this.psv.panel.hidePanel()}},r.prototype._onPanelOpened=function(){this.prop.panelOpening?(this.prop.panelOpening=!1,this.prop.panelOpened=!0):this.prop.panelOpened=!1,this.prop.markersButton&&this.prop.markersButton.toggleActive(this.prop.panelOpened)},r.prototype._onPanelClosed=function(){this.prop.panelOpened=!1,this.prop.panelOpening=!1,this.prop.markersButton&&this.prop.markersButton.toggleActive(!1)};function a(t){s.call(this,t),this.canvas=null,this.loader=null,this.create()}a.prototype=Object.create(s.prototype),a.prototype.constructor=a,a.className="psv-loader-container",a.prototype.create=function(){s.prototype.create.call(this),this.loader=document.createElement("div"),this.loader.className="psv-loader",this.container.appendChild(this.loader),this.canvas=document.createElement("canvas"),this.canvas.className="psv-loader-canvas",this.canvas.width=this.loader.clientWidth,this.canvas.height=this.loader.clientWidth,this.loader.appendChild(this.canvas),this.tickness=(this.loader.offsetWidth-this.loader.clientWidth)/2;var t;if(this.psv.config.loading_img?((t=document.createElement("img")).className="psv-loader-image",t.src=this.psv.config.loading_img):this.psv.config.loading_txt&&((t=document.createElement("div")).className="psv-loader-text",t.innerHTML=this.psv.config.loading_txt),t){var e=Math.round(Math.sqrt(2*Math.pow(this.canvas.width/2-this.tickness/2,2)));t.style.maxWidth=e+"px",t.style.maxHeight=e+"px",this.loader.appendChild(t)}},a.prototype.destroy=function(){delete this.loader,delete this.canvas,s.prototype.destroy.call(this)},a.prototype.setProgress=function(t){var e=this.canvas.getContext("2d");e.clearRect(0,0,this.canvas.width,this.canvas.height),e.lineWidth=this.tickness,e.strokeStyle=M.getStyle(this.loader,"color"),e.beginPath(),e.arc(this.canvas.width/2,this.canvas.height/2,this.canvas.width/2-this.tickness/2,-Math.PI/2,t/100*2*Math.PI-Math.PI/2),e.stroke()};function h(t){if(s.call(this,t),this.config=this.psv.config.navbar,this.items=[],!0===this.config)this.config=M.clone(n.DEFAULTS.navbar);else if("string"==typeof this.config)this.config=this.config.split(" ");else if(!Array.isArray(this.config)){console.warn('PhotoSphereViewer: hashmap form of "navbar" is deprecated, use an array instead.');var e=this.config;this.config=[];for(var i in e)e[i]&&this.config.push(i);this.config.sort(function(t,e){return n.DEFAULTS.navbar.indexOf(t)-n.DEFAULTS.navbar.indexOf(e)})}this.create()}h.prototype=Object.create(s.prototype),h.prototype.constructor=h,h.className="psv-navbar psv-navbar--open",h.publicMethods=["showNavbar","hideNavbar","toggleNavbar","getNavbarButton"],h.prototype.create=function(){s.prototype.create.call(this),this.config.forEach(function(t){if("object"==typeof t)this.items.push(new f(this,t));else switch(t){case g.id:this.items.push(new g(this));break;case w.id:this.items.push(new w(this));break;case m.id:this.items.push(new m(this));break;case _.id:this.items.push(new _(this));break;case v.id:this.items.push(new v(this));break;case y.id:this.psv.config.gyroscope&&this.items.push(new y(this));break;case"caption":this.items.push(new p(this,this.psv.config.caption));break;case"spacer":t="spacer-5";default:var e=t.match(/^spacer\-([0-9]+)$/);if(null===e)throw new b("Unknown button "+t);this.items.push(new c(this,e[1]))}},this)},h.prototype.destroy=function(){this.items.forEach(function(t){t.destroy()}),delete this.items,delete this.config,s.prototype.destroy.call(this)},h.prototype.getNavbarButton=function(t,e){var i=null;return this.items.some(function(e){if(e.id===t)return i=e,!0}),i||e||console.warn('PhotoSphereViewer: button "'+t+'" not found in the navbar.'),i},h.prototype.showNavbar=function(){this.toggleNavbar(!0)},h.prototype.hideNavbar=function(){this.toggleNavbar(!1)},h.prototype.toggleNavbar=function(t){M.toggleClass(this.container,"psv-navbar--open",t)};function p(t,e){s.call(this,t),this.create(),this.setCaption(e)}p.prototype=Object.create(s.prototype),p.prototype.constructor=p,p.className="psv-caption",p.publicMethods=["setCaption"],p.prototype.setCaption=function(t){this.container.innerHTML=t||""};function c(t,e){s.call(this,t),this.weight=e||5,this.create(),this.container.classList.add("psv-spacer--weight-"+this.weight)}c.prototype=Object.create(s.prototype),c.prototype.constructor=c,c.className="psv-spacer";function l(t){s.call(this,t),this.content=null,this.prop={mouse_x:0,mouse_y:0,mousedown:!1,opened:!1},this.create()}l.prototype=Object.create(s.prototype),l.prototype.constructor=l,l.className="psv-panel",l.publicMethods=["showPanel","hidePanel"],l.prototype.create=function(){s.prototype.create.call(this),this.container.innerHTML='
',this.content=this.container.querySelector(".psv-panel-content");this.container.querySelector(".psv-panel-close-button").addEventListener("click",this.hidePanel.bind(this)),this.psv.config.mousewheel&&this.container.addEventListener(n.SYSTEM.mouseWheelEvent,function(t){t.stopPropagation()});var t=this.container.querySelector(".psv-panel-resizer");t.addEventListener("mousedown",this),t.addEventListener("touchstart",this),this.psv.container.addEventListener("mouseup",this),this.psv.container.addEventListener("touchend",this),this.psv.container.addEventListener("mousemove",this),this.psv.container.addEventListener("touchmove",this)},l.prototype.destroy=function(){this.psv.container.removeEventListener("mousemove",this),this.psv.container.removeEventListener("touchmove",this),this.psv.container.removeEventListener("mouseup",this),this.psv.container.removeEventListener("touchend",this),delete this.prop,delete this.content,s.prototype.destroy.call(this)},l.prototype.handleEvent=function(t){switch(t.type){case"mousedown":this._onMouseDown(t);break;case"touchstart":this._onTouchStart(t);break;case"mousemove":this._onMouseMove(t);break;case"touchmove":this._onTouchMove(t);break;case"mouseup":case"touchend":this._onMouseUp(t)}},l.prototype.showPanel=function(t,e){this.content.innerHTML=t,this.content.scrollTop=0,this.container.classList.add("psv-panel--open"),M.toggleClass(this.content,"psv-panel-content--no-margin",!!e),this.prop.opened=!0,this.psv.trigger("open-panel")},l.prototype.hidePanel=function(){this.content.innerHTML=null,this.prop.opened=!1,this.container.classList.remove("psv-panel--open"),this.psv.trigger("close-panel")},l.prototype._onMouseDown=function(t){t.stopPropagation(),this._startResize(t)},l.prototype._onTouchStart=function(t){t.stopPropagation(),this._startResize(t.changedTouches[0])},l.prototype._onMouseUp=function(t){this.prop.mousedown&&(t.stopPropagation(),this.prop.mousedown=!1,this.content.classList.remove("psv-panel-content--no-interaction"))},l.prototype._onMouseMove=function(t){this.prop.mousedown&&(t.stopPropagation(),this._resize(t))},l.prototype._onTouchMove=function(t){this.prop.mousedown&&(t.stopPropagation(),this._resize(t.touches[0]))},l.prototype._startResize=function(t){this.prop.mouse_x=parseInt(t.clientX),this.prop.mouse_y=parseInt(t.clientY),this.prop.mousedown=!0,this.content.classList.add("psv-panel-content--no-interaction")},l.prototype._resize=function(t){var e=parseInt(t.clientX),i=parseInt(t.clientY);this.container.style.width=this.container.offsetWidth-(e-this.prop.mouse_x)+"px",this.prop.mouse_x=e,this.prop.mouse_y=i};function u(t){s.call(this,t),this.config=this.psv.config.tooltip,this.prop={timeout:null},this.create()}u.prototype=Object.create(s.prototype),u.prototype.constructor=u,u.className="psv-tooltip",u.publicMethods=["showTooltip","hideTooltip","isTooltipVisible"],u.leftMap={0:"left",.5:"center",1:"right"},u.topMap={0:"top",.5:"center",1:"bottom"},u.prototype.create=function(){s.prototype.create.call(this),this.container.innerHTML='
',this.container.style.top="-1000px",this.container.style.left="-1000px",this.content=this.container.querySelector(".psv-tooltip-content"),this.arrow=this.container.querySelector(".psv-tooltip-arrow"),this.psv.on("render",this)},u.prototype.destroy=function(){this.psv.off("render",this),delete this.config,delete this.prop,s.prototype.destroy.call(this)},u.prototype.handleEvent=function(t){switch(t.type){case"render":this.hideTooltip()}},u.prototype.isTooltipVisible=function(){return this.container.classList.contains("psv-tooltip--visible")},u.prototype.showTooltip=function(t){this.prop.timeout&&(window.clearTimeout(this.prop.timeout),this.prop.timeout=null);var e=this.isTooltipVisible(),i=this.container,o=this.content,n=this.arrow;if(t.position||(t.position=["top","center"]),t.box||(t.box={width:0,height:0}),"string"==typeof t.position){var s=M.parsePosition(t.position);if(!(s.left in u.leftMap&&s.top in u.topMap))throw new b('unable to parse tooltip position "'+tooltip.position+'"');t.position=[u.topMap[s.top],u.leftMap[s.left]]}if("center"==t.position[0]&&"center"==t.position[1])throw new b('unable to parse tooltip position "center center"');if(e)for(var r=i.classList.length-1;r>=0;r--){var a=i.classList.item(r);"psv-tooltip"!=a&&"psv-tooltip--visible"!=a&&i.classList.remove(a)}else i.className="psv-tooltip";t.className&&M.addClasses(i,t.className),o.innerHTML=t.content,i.style.top="0px",i.style.left="0px";var h=i.getBoundingClientRect(),p={posClass:t.position.slice(),width:h.right-h.left,height:h.bottom-h.top,top:0,left:0,arrow_top:0,arrow_left:0};this._computeTooltipPosition(p,t);var c=!1;if(p.topthis.psv.prop.size.height-this.config.offset&&(p.posClass[0]="top",c=!0),p.leftthis.psv.prop.size.width-this.config.offset&&(p.posClass[1]="left",c=!0),c&&this._computeTooltipPosition(p,t),i.style.top=p.top+"px",i.style.left=p.left+"px",n.style.top=p.arrow_top+"px",n.style.left=p.arrow_left+"px",i.classList.add("psv-tooltip--"+p.posClass.join("-")),!e){var l=this;this.prop.timeout=window.setTimeout(function(){i.classList.add("psv-tooltip--visible"),l.prop.timeout=null,l.psv.trigger("show-tooltip")},this.config.delay)}},u.prototype.hideTooltip=function(){if(this.prop.timeout&&(window.clearTimeout(this.prop.timeout),this.prop.timeout=null),this.isTooltipVisible()){this.container.classList.remove("psv-tooltip--visible");var t=this;this.prop.timeout=window.setTimeout(function(){t.content.innerHTML=null,t.container.style.top="-1000px",t.container.style.left="-1000px",t.prop.timeout=null},this.config.delay),this.psv.trigger("hide-tooltip")}},u.prototype._computeTooltipPosition=function(t,e){var i=!1;switch(t.posClass[0]){case"bottom":t.top=e.top+e.box.height+this.config.offset+this.config.arrow_size,t.arrow_top=2*-this.config.arrow_size,i=!0;break;case"center":t.top=e.top+e.box.height/2-t.height/2,t.arrow_top=t.height/2-this.config.arrow_size;break;case"top":t.top=e.top-t.height-this.config.offset-this.config.arrow_size,t.arrow_top=t.height,i=!0}switch(t.posClass[1]){case"right":i?(t.left=e.left+e.box.width/2-this.config.offset-this.config.arrow_size,t.arrow_left=this.config.offset):(t.left=e.left+e.box.width+this.config.offset+this.config.arrow_size,t.arrow_left=2*-this.config.arrow_size);break;case"center":t.left=e.left+e.box.width/2-t.width/2,t.arrow_left=t.width/2-this.config.arrow_size;break;case"left":i?(t.left=e.left-t.width+e.box.width/2+this.config.offset+this.config.arrow_size,t.arrow_left=t.width-this.config.offset-2*this.config.arrow_size):(t.left=e.left-t.width-this.config.offset-this.config.arrow_size,t.arrow_left=t.width)}};function d(t){s.call(this,t),this.id=void 0,this.constructor.id&&(this.id=this.constructor.id),this.enabled=!0}d.prototype=Object.create(s.prototype),d.prototype.constructor=d,d.id=null,d.icon=null,d.iconActive=null,d.prototype.create=function(){s.prototype.create.call(this),this.constructor.icon&&this._setIcon(this.constructor.icon),this.id&&this.psv.config.lang[this.id]&&(this.container.title=this.psv.config.lang[this.id]),this.container.addEventListener("click",function(t){this.enabled&&this._onClick(),t.stopPropagation()}.bind(this))},d.prototype.destroy=function(){s.prototype.destroy.call(this)},d.prototype.toggleActive=function(t){M.toggleClass(this.container,"psv-button--active",t),this.constructor.iconActive&&this._setIcon(t?this.constructor.iconActive:this.constructor.icon)},d.prototype.disable=function(){this.container.classList.add("psv-button--disabled"),this.enabled=!1},d.prototype.enable=function(){this.container.classList.remove("psv-button--disabled"),this.enabled=!0},d.prototype._setIcon=function(t,e){e||(e=this.container),t?(e.innerHTML=n.ICONS[t],e.querySelector("svg").setAttribute("class","psv-button-svg")):e.innerHTML=""},d.prototype._onClick=function(){};function g(t){d.call(this,t),this.create()}g.prototype=Object.create(d.prototype),g.prototype.constructor=g,g.id="autorotate",g.className="psv-button psv-button--hover-scale psv-autorotate-button",g.icon="play.svg",g.iconActive="play-active.svg",g.prototype.create=function(){d.prototype.create.call(this),this.psv.on("autorotate",this)},g.prototype.destroy=function(){this.psv.off("autorotate",this),d.prototype.destroy.call(this)},g.prototype.handleEvent=function(t){switch(t.type){case"autorotate":this.toggleActive(t.args[0])}},g.prototype._onClick=function(){this.psv.toggleAutorotate()};function f(t,e){d.call(this,t),this.config=e,this.config.id&&(this.id=this.config.id),this.create()}f.prototype=Object.create(d.prototype),f.prototype.constructor=f,f.className="psv-button psv-custom-button",f.prototype.create=function(){d.prototype.create.call(this),this.config.className&&M.addClasses(this.container,this.config.className),this.config.title&&(this.container.title=this.config.title),this.config.content&&(this.container.innerHTML=this.config.content),!1!==this.config.enabled&&!0!==this.config.disabled||this.disable(),!1!==this.config.visible&&!0!==this.config.hidden||this.hide()},f.prototype.destroy=function(){delete this.config,d.prototype.destroy.call(this)},f.prototype._onClick=function(){this.config.onClick&&this.config.onClick.apply(this.psv)};function m(t){d.call(this,t),this.create()}m.prototype=Object.create(d.prototype),m.prototype.constructor=m,m.id="download",m.className="psv-button psv-button--hover-scale psv-download-button",m.icon="download.svg",m.prototype._onClick=function(){var t=document.createElement("a");t.href=this.psv.config.panorama,t.download=this.psv.config.panorama,this.psv.container.appendChild(t),t.click()};function v(t){d.call(this,t),this.create()}v.prototype=Object.create(d.prototype),v.prototype.constructor=v,v.id="fullscreen",v.className="psv-button psv-button--hover-scale psv-fullscreen-button",v.icon="fullscreen-in.svg",v.iconActive="fullscreen-out.svg",v.prototype.create=function(){d.prototype.create.call(this),n.SYSTEM.fullscreenEvent||(this.hide(),console.warn("PhotoSphereViewer: fullscreen not supported.")),this.psv.on("fullscreen-updated",this)},v.prototype.destroy=function(){this.psv.off("fullscreen-updated",this),d.prototype.destroy.call(this)},v.prototype.handleEvent=function(t){switch(t.type){case"fullscreen-updated":this.toggleActive(t.args[0])}},v.prototype._onClick=function(){this.psv.toggleFullscreen()};function y(t){d.call(this,t),this.create()}y.prototype=Object.create(d.prototype),y.prototype.constructor=y,y.id="gyroscope",y.className="psv-button psv-button--hover-scale psv-gyroscope-button",y.icon="compass.svg",y.prototype.create=function(){d.prototype.create.call(this),n.SYSTEM.deviceOrientationSupported.promise.then(this._onAvailabilityChange.bind(this,!0),this._onAvailabilityChange.bind(this,!1)),this.hide(),this.psv.on("gyroscope-updated",this)},y.prototype.destroy=function(){this.psv.off("gyroscope-updated",this),d.prototype.destroy.call(this)},y.prototype.handleEvent=function(t){switch(t.type){case"gyroscope-updated":this.toggleActive(t.args[0])}},y.prototype._onClick=function(){this.psv.toggleGyroscopeControl()},y.prototype._onAvailabilityChange=function(t){if(t){if(!M.checkTHREE("DeviceOrientationControls"))throw new b("Missing Three.js components: DeviceOrientationControls. Get them from three.js-examples package.");this.show()}};function _(t){d.call(this,t),this.create()}_.prototype=Object.create(d.prototype),_.prototype.constructor=_,_.id="markers",_.className="psv-button psv-button--hover-scale psv-markers-button",_.icon="pin.svg",_.prototype._onClick=function(){this.psv.hud.toggleMarkersList()};function w(t){d.call(this,t),this.zoom_range=null,this.zoom_value=null,this.prop={mousedown:!1,buttondown:!1,longPressInterval:null,longPressTimeout:null},this.create()}w.prototype=Object.create(d.prototype),w.prototype.constructor=w,w.id="zoom",w.className="psv-button psv-zoom-button",w.prototype.create=function(){d.prototype.create.call(this);var t=document.createElement("div");t.className="psv-zoom-button-minus",t.title=this.psv.config.lang.zoomOut,this._setIcon("zoom-out.svg",t),this.container.appendChild(t);var e=document.createElement("div");e.className="psv-zoom-button-range",this.container.appendChild(e),this.zoom_range=document.createElement("div"),this.zoom_range.className="psv-zoom-button-line",e.appendChild(this.zoom_range),this.zoom_value=document.createElement("div"),this.zoom_value.className="psv-zoom-button-handle",this.zoom_range.appendChild(this.zoom_value);var i=document.createElement("div");i.className="psv-zoom-button-plus",i.title=this.psv.config.lang.zoomIn,this._setIcon("zoom-in.svg",i),this.container.appendChild(i),this.zoom_range.addEventListener("mousedown",this),this.zoom_range.addEventListener("touchstart",this),this.psv.container.addEventListener("mousemove",this),this.psv.container.addEventListener("touchmove",this),this.psv.container.addEventListener("mouseup",this),this.psv.container.addEventListener("touchend",this),t.addEventListener("mousedown",this._zoomOut.bind(this)),i.addEventListener("mousedown",this._zoomIn.bind(this)),this.psv.on("zoom-updated",this),this.psv.once("ready",function(){this._moveZoomValue(this.psv.prop.zoom_lvl)}.bind(this))},w.prototype.destroy=function(){this._stopZoomChange(),this.psv.container.removeEventListener("mousemove",this),this.psv.container.removeEventListener("touchmove",this),this.psv.container.removeEventListener("mouseup",this),this.psv.container.removeEventListener("touchend",this),delete this.zoom_range,delete this.zoom_value,this.psv.off("zoom-updated",this),d.prototype.destroy.call(this)},w.prototype.handleEvent=function(t){switch(t.type){case"mousedown":this._initZoomChangeWithMouse(t);break;case"touchstart":this._initZoomChangeByTouch(t);break;case"mousemove":this._changeZoomWithMouse(t);break;case"touchmove":this._changeZoomByTouch(t);break;case"mouseup":case"touchend":this._stopZoomChange(t);break;case"zoom-updated":this._moveZoomValue(t.args[0])}},w.prototype._moveZoomValue=function(t){this.zoom_value.style.left=t/100*this.zoom_range.offsetWidth-this.zoom_value.offsetWidth/2+"px"},w.prototype._initZoomChangeWithMouse=function(t){this.enabled&&(this.prop.mousedown=!0,this._changeZoom(t.clientX))},w.prototype._initZoomChangeByTouch=function(t){this.enabled&&(this.prop.mousedown=!0,this._changeZoom(t.changedTouches[0].clientX))},w.prototype._zoomIn=function(){this.enabled&&(this.prop.buttondown=!0,this.psv.zoomIn(),this.prop.longPressTimeout=window.setTimeout(this._startLongPressInterval.bind(this,1),200))},w.prototype._zoomOut=function(){this.enabled&&(this.prop.buttondown=!0,this.psv.zoomOut(),this.prop.longPressTimeout=window.setTimeout(this._startLongPressInterval.bind(this,-1),200))},w.prototype._startLongPressInterval=function(t){this.prop.buttondown&&(this.prop.longPressInterval=window.setInterval(function(){this.psv.zoom(this.psv.prop.zoom_lvl+t)}.bind(this),50))},w.prototype._stopZoomChange=function(){this.enabled&&(window.clearInterval(this.prop.longPressInterval),window.clearTimeout(this.prop.longPressTimeout),this.prop.longPressInterval=null,this.prop.mousedown=!1,this.prop.buttondown=!1)},w.prototype._changeZoomWithMouse=function(t){this.enabled&&(t.preventDefault(),this._changeZoom(t.clientX))},w.prototype._changeZoomByTouch=function(t){this.enabled&&(t.preventDefault(),this._changeZoom(t.changedTouches[0].clientX))},w.prototype._changeZoom=function(t){if(this.prop.mousedown){var e=(parseInt(t)-this.zoom_range.getBoundingClientRect().left)/this.zoom_range.offsetWidth*100;this.psv.zoom(e)}};function b(t){this.message=t,"captureStackTrace"in Error?Error.captureStackTrace(this,b):this.stack=(new Error).stack}b.prototype=Object.create(Error.prototype),b.prototype.name="PSVError",b.prototype.constructor=b,n.Error=b;function x(t,e){if(!t.id)throw new b("missing marker id");if(t.image&&(!t.width||!t.height))throw new b("missing marker width/height");if((t.image||t.html)&&!(t.hasOwnProperty("x")&&t.hasOwnProperty("y")||t.hasOwnProperty("latitude")&&t.hasOwnProperty("longitude")))throw new b("missing marker position, latitude/longitude or x/y");this.psv=e,this.visible=!0,this._dynamicSize=!1;var i,o=t.id,n=x.getType(t,!1);Object.defineProperties(this,{id:{configurable:!1,enumerable:!0,get:function(){return o},set:function(t){}},type:{configurable:!1,enumerable:!0,get:function(){return n},set:function(t){}},$el:{configurable:!1,enumerable:!0,get:function(){return i},set:function(t){}},_def:{configurable:!1,enumerable:!0,get:function(){return this[n]},set:function(t){this[n]=t}}}),(i=this.isNormal()?document.createElement("div"):this.isPolygon()?document.createElementNS(M.svgNS,"polygon"):this.isPolyline()?document.createElementNS(M.svgNS,"polyline"):document.createElementNS(M.svgNS,this.type)).id="psv-marker-"+this.id,i.psvMarker=this,this.update(t)}x.types=["image","html","polygon_px","polygon_rad","polyline_px","polyline_rad","rect","circle","ellipse","path"],x.getType=function(t,e){var i=[];if(x.types.forEach(function(e){t[e]&&i.push(e)}),0===i.length&&!e)throw new b("missing marker content, either "+x.types.join(", "));if(i.length>1)throw new b("multiple marker content, either "+x.types.join(", "));return i[0]},x.prototype.destroy=function(){delete this.$el.psvMarker},x.prototype.isNormal=function(){return"image"==this.type||"html"==this.type},x.prototype.isPoly=function(){return this.isPolygon()||this.isPolyline()},x.prototype.isPolygon=function(){return"polygon_px"==this.type||"polygon_rad"==this.type},x.prototype.isPolyline=function(){return"polyline_px"==this.type||"polyline_rad"==this.type},x.prototype.isSvg=function(){return"rect"==this.type||"circle"==this.type||"ellipse"==this.type||"path"==this.type},x.prototype.getScale=function(t){return Array.isArray(this.scale)?this.scale[0]+(this.scale[1]-this.scale[0])*M.animation.easings.inQuad(t/100):"function"==typeof this.scale?this.scale(t):"number"==typeof this.scale?this.scale*M.animation.easings.inQuad(t/100):1},x.prototype.update=function(t){if(t&&t!==this){var e=x.getType(t,!0);if(void 0!==e&&e!==this.type)throw new b("cannot change marker type");M.deepmerge(this,t)}this.isNormal()?this.$el.setAttribute("class","psv-marker psv-marker--normal"):this.$el.setAttribute("class","psv-marker psv-marker--svg"),this.className&&M.addClasses(this.$el,this.className),this.tooltip&&(M.addClasses(this.$el,"has-tooltip"),"string"==typeof this.tooltip&&(this.tooltip={content:this.tooltip})),this.style&&M.deepmerge(this.$el.style,this.style),this.anchor=M.parsePosition(this.anchor),this.isNormal()?this._updateNormal():this.isPolygon()?this._updatePoly("polygon_rad","polygon_px"):this.isPolyline()?this._updatePoly("polyline_rad","polyline_px"):this._updateSvg()},x.prototype._updateNormal=function(){this.width&&this.height?(this.$el.style.width=this.width+"px",this.$el.style.height=this.height+"px",this._dynamicSize=!1):this._dynamicSize=!0,this.image?this.$el.style.backgroundImage="url("+this.image+")":this.$el.innerHTML=this.html,this.$el.style.transformOrigin=100*this.anchor.left+"% "+100*this.anchor.top+"%",this.psv.cleanPosition(this),this.position3D=this.psv.sphericalCoordsToVector3(this)},x.prototype._updateSvg=function(){switch(this._dynamicSize=!0,this.type){case"rect":"number"==typeof this._def?this._def={x:0,y:0,width:this._def,height:this._def}:Array.isArray(this._def)?this._def={x:0,y:0,width:this._def[0],height:this._def[1]}:this._def.x=this._def.y=0;break;case"circle":"number"==typeof this._def?this._def={cx:this._def,cy:this._def,r:this._def}:Array.isArray(this._def)?this._def={cx:this._def[0],cy:this._def[0],r:this._def[0]}:this._def.cx=this._def.cy=this._def.r;break;case"ellipse":"number"==typeof this._def?this._def={cx:this._def,cy:this._def,rx:this._def,ry:this._def}:Array.isArray(this._def)?this._def={cx:this._def[0],cy:this._def[1],rx:this._def[0],ry:this._def[1]}:(this._def.cx=this._def.rx,this._def.cy=this._def.ry);break;case"path":"string"==typeof this._def&&(this._def={d:this._def})}Object.getOwnPropertyNames(this._def).forEach(function(t){this.$el.setAttributeNS(null,t,this._def[t])},this),this.svgStyle?Object.getOwnPropertyNames(this.svgStyle).forEach(function(t){this.$el.setAttributeNS(null,t,this.svgStyle[t])},this):this.$el.setAttributeNS(null,"fill","rgba(0,0,0,0.5)"),this.psv.cleanPosition(this),this.position3D=this.psv.sphericalCoordsToVector3(this)},x.prototype._updatePoly=function(t,e){this._dynamicSize=!0,this.svgStyle?(Object.getOwnPropertyNames(this.svgStyle).forEach(function(t){this.$el.setAttributeNS(null,t,this.svgStyle[t])},this),this.isPolyline()&&!this.svgStyle.fill&&this.$el.setAttributeNS(null,"fill","none")):this.isPolygon()?this.$el.setAttributeNS(null,"fill","rgba(0,0,0,0.5)"):this.isPolyline()&&(this.$el.setAttributeNS(null,"fill","none"),this.$el.setAttributeNS(null,"stroke","rgb(0,0,0)")),[this[t],this[e]].forEach(function(t){if(t&&"object"!=typeof t[0])for(var e=0;e0?" "+e:e,t.setAttribute("class",o)}},M.addClasses=function(t,e){e&&e.split(" ").forEach(function(e){M.toggleClass(t,e,!0)})},M.removeClasses=function(t,e){e&&e.split(" ").forEach(function(e){M.toggleClass(t,e,!1)})},M.hasParent=function(t,e){do{if(t===e)return!0}while(t=t.parentNode);return!1},M.getClosest=function(t,e){var i=t.matches||t.msMatchesSelector;do{if(i.bind(t)(e))return t}while(t=t.parentElement);return null},M.mouseWheelEvent=function(){return"onwheel"in document.createElement("div")?"wheel":void 0!==document.onmousewheel?"mousewheel":"DOMMouseScroll"},M.fullscreenEvent=function(){var t={exitFullscreen:"fullscreenchange",webkitExitFullscreen:"webkitfullscreenchange",mozCancelFullScreen:"mozfullscreenchange",msExitFullscreen:"MSFullscreenChange"};for(var e in t)if(e in document)return t[e]},M.bound=function(t,e,i){return Math.max(e,Math.min(i,t))},M.isInteger=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},M.sum=function(t){return t.reduce(function(t,e){return t+e},0)},M.getXMPValue=function(t,e){var i;return null!==(i=t.match("(.*)"))?i[1]:null!==(i=t.match("GPano:"+e+'="(.*?)"'))?i[1]:null},M.isFullscreenEnabled=function(t){return(document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement)===t},M.requestFullscreen=function(t){(t.requestFullscreen||t.mozRequestFullScreen||t.webkitRequestFullscreen||t.msRequestFullscreen).call(t)},M.exitFullscreen=function(){(document.exitFullscreen||document.mozCancelFullScreen||document.webkitExitFullscreen||document.msExitFullscreen).call(document)},M.getStyle=function(t,e){return window.getComputedStyle(t,null)[e]},M.getShortestArc=function(t,e){return[0,M.TwoPI,-M.TwoPI].reduce(function(i,o){return o=e-t+o,Math.abs(o)e?(s&&(clearTimeout(s),s=null),r=h,n=t.apply(i,o),s||(i=o=null)):s||(s=setTimeout(a,p)),n}},M.isPlainObject=function(t){if("object"==typeof t&&null!==t){if("function"==typeof Object.getPrototypeOf){var e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}return"[object Object]"==Object.prototype.toString.call(t)}return!1},M.deepmerge=function(t,e){var i=e;return function t(e,o){return Array.isArray(o)?(e&&Array.isArray(e)?e.length=0:e=[],o.forEach(function(i,o){e[o]=t(null,i)})):"object"==typeof o?(e&&!Array.isArray(e)||(e={}),Object.keys(o).forEach(function(n){"object"==typeof o[n]&&o[n]&&M.isPlainObject(o[n])?o[n]!=i&&(e[n]?t(e[n],o[n]):e[n]=t(null,o[n])):e[n]=o[n]})):e=o,e}(t,e)},M.clone=function(t){return M.deepmerge(null,t)},M.normalizeWheel=function(t){var e=0,i=0,o=0,n=0;return"detail"in t&&(i=t.detail),"wheelDelta"in t&&(i=-t.wheelDelta/120),"wheelDeltaY"in t&&(i=-t.wheelDeltaY/120),"wheelDeltaX"in t&&(e=-t.wheelDeltaX/120),"axis"in t&&t.axis===t.HORIZONTAL_AXIS&&(e=i,i=0),o=10*e,n=10*i,"deltaY"in t&&(n=t.deltaY),"deltaX"in t&&(o=t.deltaX),(o||n)&&t.deltaMode&&(1==t.deltaMode?(o*=40,n*=40):(o*=800,n*=800)),o&&!e&&(e=o<1?-1:1),n&&!i&&(i=n<1?-1:1),{spinX:e,spinY:i,pixelX:o,pixelY:n}},function(t){if(t.requestAnimationFrame=t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame,t.cancelAnimationFrame=t.cancelAnimationFrame||t.mozCancelAnimationFrame||t.webkitCancelAnimationFrame||t.msCancelAnimationFrame,!t.requestAnimationFrame){var e,i=[],o=[],n=0;t.requestAnimationFrame=function(t){return i.push([++n,t]),e||(e=setInterval(function(){if(i.length){var t=+new Date,n=o;for(o=i,i=n;o.length;)o.shift()[1](t)}else clearInterval(e),e=void 0},20)),n},t.cancelAnimationFrame=function(t){var e,n;for(e=0,n=i.length;e