Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lumiscaphe/viewer

Package Overview
Dependencies
Maintainers
1
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lumiscaphe/viewer - npm Package Compare versions

Comparing version 4.0.7 to 4.0.8

dist/index-full.js

2

dist/index.es.js

@@ -16,3 +16,3 @@ import t from"debounce-promise";import*as e from"twgl.js";import{v3 as i,m4 as s}from"twgl.js";import o from"regression";class n{constructor(t,e){this.width=t,this.height=e}get aspect(){return this.width/this.height}}class r{constructor(t,e,i,s){this.top=t,this.left=e,this.width=i,this.height=s}static fit(t,e,i){const s=t.aspect,o=e.aspect;let n=0,a=0;switch(i){case"contain":n=o<s?e.width:e.height*s,a=o<s?e.width/s:e.height;break;case"cover":default:n=o<s?e.height*s:e.width,a=o<s?e.height:e.width/s;break;case"fill":n=e.width,a=e.height}const h=(e.height-a)/2,c=(e.width-n)/2;return new r(h,c,n,a)}static getStandardAspectRatio(t,e){if(0===t||0===e)return 0;const i=t/e;if(t<e){return Math.abs(3/4-i)<Math.abs(9/16-i)?3/4:9/16}return Math.abs(4/3-i)<Math.abs(16/9-i)?4/3:16/9}static getStandardResolution(t,e){if(0===t||0===e)return new n(0,0);const i=r.getStandardAspectRatio(t,e);if(t<e){const s=r.getStandardQuality(Math.max(e*i,t));return new n(Math.round(s),Math.round(s/i))}const s=r.getStandardQuality(Math.max(t/i,e));return new n(Math.round(s*i),Math.round(s))}static getStandardQuality(t){return t<=240?240:t<=360?360:t<=480?480:t<=720?720:1080}}class a{constructor(t){this.element=document.createElement("canvas"),this.element.classList.add("ls-viewer-canvas"),this.element.style.opacity="0",this.context=this.element.getContext("2d"),this.backCanvas=document.createElement("canvas"),this.backContext=this.backCanvas.getContext("2d"),this.fit=t}destroy(){this.requestAnimationId&&(cancelAnimationFrame(this.requestAnimationId),this.requestAnimationId=void 0)}show(t){t?this.element.style.display="block":this.element.style.opacity="1"}hide(t){t?this.element.style.display="none":this.element.style.opacity="0"}resize(t,e,i){this.element.width=t*i,this.element.height=e*i,this.element.style.width=`${t}px`,this.element.style.height=`${e}px`,this.backCanvas.width=t*i,this.backCanvas.height=e*i}draw(t,e,i){if(!t)return;this.requestAnimationId&&(cancelAnimationFrame(this.requestAnimationId),this.requestAnimationId=void 0);const s=r.fit(new n(t.width,t.height),new n(this.element.width,this.element.height),this.fit);e?(this.backContext.drawImage(this.element,0,0),this.context.globalAlpha=0,this.fadeLoop(t,i||0)):(this.context.globalAlpha=1,this.context.drawImage(t,s.left,s.top,s.width,s.height)),this.image=t}fadeLoop(t,e){if(this.context.globalAlpha>=1)return cancelAnimationFrame(this.requestAnimationId),void(this.requestAnimationId=void 0);const i=Math.min(this.context.globalAlpha+e,1),s=r.fit(new n(t.width,t.height),new n(this.element.width,this.element.height),this.fit);this.context.clearRect(0,0,this.element.width,this.element.height),this.context.globalAlpha=1,this.context.drawImage(this.backCanvas,0,0),this.context.globalAlpha=i,this.context.drawImage(t,s.left,s.top,s.width,s.height),this.requestAnimationId=requestAnimationFrame((()=>{this.fadeLoop(t,e)}))}}class h{constructor(){this.element=document.createElement("canvas"),this.element.classList.add("ls-viewer-canvas"),this.element.style.opacity="0",this.context=e.getContext(this.element,{preserveDrawingBuffer:!0}),e.setDefaultTextureColor([1,1,1,1])}show(){this.element.style.opacity="1"}hide(){this.element.style.opacity="0"}resize(t,e,i){this.element.width=t*i,this.element.height=e*i,this.element.style.width=`${t}px`,this.element.style.height=`${e}px`}}class c{static accelerate(t,e){const i=e||1.5;return Math.abs(t)**i*(t>0?1:-1)}static degreesToRadians(t){return t*(Math.PI/180)}static radiansToDegrees(t){return t*(180/Math.PI)}static mod(t,e){return t-e*Math.floor(t/e)}static perspectiveWithFovX(t,e,i,s,o){const n=Math.tan(t/2),r=n/e;return this.perspectiveWithLeft(-n,n,-r,r,i,s,o)}static perspectiveWithFovY(t,e,i,s,o){const n=i*Math.tan(t/2),r=n*e;return this.perspectiveWithLeft(-r,r,-n,n,i,s,o)}static perspectiveWithLeft(t,e,i,s,o,n,r){const a=e+t,h=e-t,c=s+i,d=s-i,l=n-o;return(r=r||new Float32Array(16))[0]=2*o/h,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=2*o/d,r[6]=0,r[7]=0,r[8]=a/h,r[9]=c/d,r[10]=-n/l,r[11]=-1,r[12]=0,r[13]=0,r[14]=-n*o/l,r[15]=0,r}}class d{constructor(){}async animation(t){return t.scene}async image(t){return t.scene}async video(t){return t.scene}async vrCube(t){return t.scene}async vrObject(t){return t.scene}}class l{constructor(t){this.server=t}static buildQuery(t){return Object.entries(t).filter((([t,e])=>null!=e)).map((([t,e])=>`${t}=${e}`)).join("&")}static sceneParameters(t){var e,i;const s=t.scene,o=s.length>1?s.find((t=>t.accessory)):null,n=s.length>1?s.find((t=>t.decor)):null,r=s.find((t=>t!==o&&t!==n));return{databaseId:r.database,configuration:null==r?void 0:r.configuration,animations:null===(e=null==r?void 0:r.animations)||void 0===e?void 0:e.join("/"),accessoryDatabaseId:null==o?void 0:o.database,decorDatabaseId:null==n?void 0:n.database,decorDeltaAltitude:null===(i=null==n?void 0:n.translation)||void 0===i?void 0:i.y}}static renderParameters(t){const{parameters:e,view:i}=t;return{background:i.background,width:e.width,height:e.height,softwareAntialiasing:e.antialiasing,superSampling:e.superSampling}}static encoderParameters(t){const{encoder:e}=t;return{imageFormat:e.format,imageQuality:e.quality}}static async fetch(t){return fetch(t).then((t=>t.text())).then((t=>{const e=t.replace(/&amp;/g,"&").match(this.xmlRegex);return e?e.map((t=>t.replace(this.xmlRegex,"$1"))):Promise.reject()}))}async animation(t){const e=Object.assign(Object.assign(Object.assign(Object.assign({},l.sceneParameters(t)),{animation:t.view.animation,bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1],frames:t.view.frames,loop:!!t.view.loop}),l.renderParameters(t)),l.encoderParameters(t)),i=l.buildQuery(e);return l.fetch(`${this.server}/ImagesFromAnimation?${i}`)}async image(t){const e=Object.assign(Object.assign(Object.assign(Object.assign({},l.sceneParameters(t)),{bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1]}),l.renderParameters(t)),l.encoderParameters(t)),i=l.buildQuery(e);return Promise.resolve(`${this.server}/ImageFromBookmark?${i}`)}async video(t){const e=Object.assign(Object.assign(Object.assign(Object.assign({},l.sceneParameters(t)),{animation:t.view.animation,bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1],duration:t.view.duration,frames:t.view.frames,loop:!!t.view.loop,reverse:!!t.view.reverse}),l.renderParameters(t)),l.encoderParameters(t)),i=l.buildQuery(e);return Promise.resolve(`${this.server}/ImagesFromAnimation?${i}`)}async vrCube(t){const e=Object.assign(Object.assign(Object.assign(Object.assign({},l.sceneParameters(t)),{bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1]}),l.renderParameters(t)),l.encoderParameters(t));e.width=Math.max(e.width,e.height),e.height=Math.max(e.width,e.height);const i=l.buildQuery(e);return l.fetch(`${this.server}/CubeFromBookmark?${i}`)}async vrObject(t){const e=Object.assign(Object.assign(Object.assign(Object.assign({},l.sceneParameters(t)),{bookmarkSet:t.view.camera}),l.renderParameters(t)),l.encoderParameters(t)),i=l.buildQuery(e);return l.fetch(`${this.server}/ImagesFromBookmarkSet?${i}`)}}l.xmlRegex=/directUrl="([^"]*)"/g;class m{constructor(t){this.server=t}static scene(t){return t.scene.map((t=>{const e=

***************************************************************************** */
function(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(s=Object.getOwnPropertySymbols(t);o<s.length;o++)e.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(t,s[o])&&(i[s[o]]=t[s[o]])}return i}(t,["accessory","decor"]);return e}))}static renderParameters(t){return Object.assign(Object.assign({},t.parameters),{superSampling:t.parameters.superSampling.toString()})}static encoder(t){switch(t.encoder.format){case"jpeg":return{jpeg:{quality:t.encoder.quality}};case"png":return{png:{compression:t.encoder.compression}};case"webp":return{webp:{quality:t.encoder.quality}}}return{jpeg:{quality:80}}}static async fetchFrame(t,e){return fetch(t,{method:"POST",body:JSON.stringify(e)}).then((t=>t.json())).then((t=>t.url))}static async fetchFrameArray(t,e){return fetch(t,{method:"POST",body:JSON.stringify(e)}).then((t=>t.json())).then((t=>t.map((t=>t.url))))}static async fetchHotspots(t,e){return fetch(t,{method:"POST",body:JSON.stringify(e)}).then((t=>t.json())).then((t=>t))}static async fetchHotspotsArray(t,e){return fetch(t,{method:"POST",body:JSON.stringify(e)}).then((t=>t.json())).then((t=>t))}async image(t){const e={scene:m.scene(t),mode:{image:{camera:t.view.camera}},renderParameters:m.renderParameters(t),encoder:m.encoder(t)};return m.fetchFrame(`${this.server}/Snapshot`,e)}async vrCube(t){const e={scene:m.scene(t),mode:{vrCube:{camera:t.view.camera}},renderParameters:m.renderParameters(t),encoder:m.encoder(t)};return e.renderParameters.width=Math.max(e.renderParameters.width,e.renderParameters.height),e.renderParameters.height=Math.max(e.renderParameters.width,e.renderParameters.height),m.fetchFrameArray(`${this.server}/Snapshot`,e)}async vrObject(t){let e;e=t.view.cameraGroup?{images:{cameraGroup:t.view.cameraGroup}}:t.view.frames?{vrObject:{camera:t.view.camera,frames:t.view.frames}}:{vrObject:{camera:t.view.camera,panFrames:t.view.panFrames||1,panFrom:t.view.panFrom||0,panTo:t.view.panTo||0,panLoop:t.view.panLoop||!1,tiltFrames:t.view.tiltFrames||1,tiltFrom:t.view.tiltFrom||0,tiltTo:t.view.tiltTo||0,tiltLoop:t.view.tiltLoop||!1}};const i={scene:m.scene(t),mode:e,renderParameters:m.renderParameters(t),encoder:m.encoder(t)};return m.fetchFrameArray(`${this.server}/Snapshot`,i)}async animation(t){const e={scene:m.scene(t),mode:{animation:{id:t.view.animation,camera:t.view.camera,fps:t.view.fps}},renderParameters:m.renderParameters(t),encoder:m.encoder(t)};return m.fetchFrameArray(`${this.server}/Snapshot`,e)}async imageHotspots(t,e){const i={scene:m.scene(t),mode:{image:{camera:t.view.camera}},renderParameters:m.renderParameters(t),tags:e};return await m.fetchHotspots(`${this.server}/Hotspot`,i)}async vrCubeHotspots(t,e){const i={scene:m.scene(t),mode:{vrCube:{camera:t.view.camera}},renderParameters:m.renderParameters(t),tags:e};return i.renderParameters.width=Math.max(i.renderParameters.width,i.renderParameters.height),i.renderParameters.height=Math.max(i.renderParameters.width,i.renderParameters.height),await m.fetchHotspotsArray(`${this.server}/Hotspot`,i)}async vrObjectHotspots(t,e){let i;i=t.view.cameraGroup?{images:{cameraGroup:t.view.cameraGroup}}:t.view.frames?{vrObject:{camera:t.view.camera,frames:t.view.frames}}:{vrObject:{camera:t.view.camera,panFrames:t.view.panFrames||1,panFrom:t.view.panFrom||0,panTo:t.view.panTo||0,panLoop:t.view.panLoop||!1,tiltFrames:t.view.tiltFrames||1,tiltFrom:t.view.tiltFrom||0,tiltTo:t.view.tiltTo||0,tiltLoop:t.view.tiltLoop||!1}};const s={scene:m.scene(t),mode:i,renderParameters:m.renderParameters(t),tags:e};return await m.fetchHotspotsArray(`${this.server}/Hotspot`,s)}}class u{constructor(t,e,i){switch(e){case"static":this.webrender=new d;break;case"v1":default:this.webrender=new l(t);break;case"v2":this.webrender=new m(t)}this.delegate=i,this.loadingId=0,this.loaded=0,this.total=0,this.onLoadStart=i&&i.onLoadStart?i.onLoadStart:()=>{},this.onLoadProgress=i&&i.onLoadProgress?i.onLoadProgress:()=>{},this.onLoadEnd=i&&i.onLoadEnd?i.onLoadEnd:()=>{}}get progress(){return this.total?this.loaded/this.total:0}async loadImageSnapshot(t){this.loadingId+=1,this.loaded=0,this.total=1,this.onLoadStart(this.progress);const{loadingId:e}=this;return this.webrender.image(t).then((t=>this.loadImage(t,e))).then((t=>(this.onLoadEnd(this.progress),t)))}async loadVideoSnapshot(t,e){this.loadingId+=1,this.loaded=0,this.total=1,this.onLoadStart(this.progress);const{loadingId:i}=this;return this.webrender.video(e).then((s=>this.loadVideo(t,s,!!e.view.loop,i))).then((()=>(this.onLoadEnd(this.progress),t)))}async loadVRCubeSnapshot(t){this.loadingId+=1,this.loaded=0,this.total=0,this.onLoadStart(this.progress);const{loadingId:e}=this;return this.webrender.vrCube(t).then((t=>{this.total=t.length;const i=t.map((t=>this.loadImage(t,e)));return Promise.all(i)})).then((t=>(this.onLoadEnd(this.progress),t)))}async loadVRObjectSnapshot(t,e){var i;this.loadingId+=1,this.loaded=0,this.total=0,this.onLoadStart(this.progress);const{loadingId:s}=this;return t.view.animation?"mp4"===(null===(i=t.encoder)||void 0===i?void 0:i.format)?this.webrender.video(t).then((e=>this.loadVideoFrames(e,t.view.frames,30,s))):this.webrender.animation(t).then((i=>this.loadImageFrames(i,t.view.loop,e,s))):this.webrender.vrObject(t).then((i=>this.loadImageFrames(i,t.view.loop,e,s)))}async loadImage(t,e){const i=new Image;i.crossOrigin="file:"!==location.protocol||u.isValidHttpUrl(t)?"anonymous":null;const s=new Promise(((s,o)=>{i.addEventListener("load",(()=>{e===this.loadingId&&(this.loaded+=1,this.onLoadProgress(this.progress),s(i))}),{once:!0}),i.addEventListener("error",(i=>{e===this.loadingId&&o(`${i.type} : ${t}`)}),{once:!0})}));return i.src=t,s}loadImageFrames(t,e,i,s){this.total=t.length;const o=new Array(t.length),n=i||0;for(let i=0,r=t.length;i<r;i+=1){const a=Math.ceil(i/2)*(i%2==0?1:-1),h=e?c.mod(n+a,r):i;o[h]=this.loadImage(t[h],s)}return Promise.all(o).then((()=>this.onLoadEnd(this.progress))).catch((()=>{})),o}async loadVideo(t,e,i,s){t.loop=i;const o=new Promise(((i,o)=>{t.addEventListener("canplaythrough",(()=>{s===this.loadingId&&(this.loaded+=1,this.onLoadProgress(this.progress),i())}),{once:!0}),t.addEventListener("error",(t=>{s===this.loadingId&&o(`${t.type} : ${e}`)}),{once:!0})}));return t.src=e,t.load(),o}async loadVideoFrame(t,e,i,s,o){let n=0;return new Promise(((r,a)=>{const h=()=>{if(o!==this.loadingId)return;if(n!==s)return void(n+=1);t.removeEventListener("seeked",h);const a=document.createElement("canvas");a.width=t.videoWidth,a.height=t.videoHeight;a.getContext("2d").drawImage(t,0,0);const c=new Image;c.src=a.toDataURL(),r(c),this.loaded+=1,this.onLoadProgress(this.progress),s!==i-1&&(t.currentTime+=1/e)};t.addEventListener("seeked",h),t.addEventListener("error",(t=>{o===this.loadingId&&a(t)}),{once:!0})}))}loadVideoFrames(t,e,i,s){this.total=e;const o=new Array(e),n=document.createElement("video");for(let t=0,r=e;t<r;t+=1)o[t]=this.loadVideoFrame(n,i,e,t,s);return n.addEventListener("canplaythrough",(()=>{s===this.loadingId&&(n.currentTime=1/i/2)}),{once:!0}),n.src=t,n.load(),Promise.all(o).then((()=>this.onLoadEnd(this.progress))).catch((()=>{})),o}async loadImageHotspots(t,e){return this.webrender instanceof m?await this.webrender.imageHotspots(t,e):Promise.reject(new Error("Hotspots only available with api V2"))}async loadVRCubeHotspots(t,e){return this.webrender instanceof m?await this.webrender.vrCubeHotspots(t,e):Promise.reject(new Error("Hotspots only available with api V2"))}async loadVRObjectHotspots(t,e){return this.webrender instanceof m?await this.webrender.vrObjectHotspots(t,e):Promise.reject(new Error("Hotspots only available with api V2"))}onLoadStart(t){this.delegate&&this.delegate.onLoadStart(t)}onLoadProgress(t){this.delegate&&this.delegate.onLoadProgress(t)}onLoadEnd(t){this.delegate&&this.delegate.onLoadEnd(t)}static isValidHttpUrl(t){let e;try{e=new URL(t)}catch(t){return!1}return"http:"===e.protocol||"https:"===e.protocol}}class v{constructor(){this.element=document.createElement("video"),this.element.classList.add("ls-viewer-video"),this.element.style.opacity="0",this.element.setAttribute("muted",""),this.element.setAttribute("playsinline",""),this.element.setAttribute("preload","auto")}show(){this.element.style.opacity="1"}hide(){this.element.style.opacity="0"}resize(t,e,i,s){const o=r.fit(i,new n(t,e),s);this.element.style.top=`${o.top}px`,this.element.style.left=`${o.left}px`,this.element.style.width=`${o.width}px`,this.element.style.height=`${o.height}px`,i.width===this.element.width&&i.height===this.element.height||(this.element.width=i.width,this.element.height=i.height)}}class g{constructor(t,e,i){this.container=t,this.canvas=e,this.loader=i,this.hotspots=[]}destroy(){}show(){this.canvas.show(!1),this.container.classList.add("ls-viewer-container-image")}hide(){this.canvas.hide(!1),this.container.classList.remove("ls-viewer-container-image")}async load(t,e,i,s){let o=Promise.resolve();const n=JSON.stringify(t);o=n===this.snapshotHash&&this.image?o.then((()=>this.canvas.draw(this.image,s,.05))):o.then((()=>this.loader.loadImageSnapshot(t).then((t=>{this.canvas.draw(t,s,.05),this.image=t}))));const r=JSON.stringify(e);return!e.length||n===this.snapshotHash&&r===this.tagsHash||(o=o.then((()=>this.loader.loadImageHotspots(t,e).then((t=>{this.hotspots=t}))))),this.snapshotHash=n,this.tagsHash=r,o.then((()=>Promise.resolve(this.hotspots)))}snapshot(t,e){return this.canvas.element.toDataURL(t,e)}onMouseDown(t){}onMouseMove(t){}onMouseUp(t){}onMouseEnter(t){}onTouchStart(t){}onTouchMove(t){}onTouchEnd(t){}onDeviceOrientation(t){}}class p{constructor(t,e,i){this.container=t,this.loader=i,this.video=e}destroy(){}show(){this.video.show(),this.container.classList.add("ls-viewer-container-video")}hide(){this.video.hide(),this.container.classList.remove("ls-viewer-container-video")}async load(t){const e=JSON.stringify(t);return e===this.hash?(this.video.element.load(),Promise.resolve([])):(this.hash=e,this.loader.loadVideoSnapshot(this.video.element,t).then((()=>Promise.resolve([]))))}snapshot(t,e){return"data:image/gif;base64,R0lGODlhAQABAIAAAP7//wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=="}async play(){return new Promise(((t,e)=>{this.video.element.addEventListener("ended",(()=>{t()}),{once:!0}),this.video.element.play().catch(e),this.show()}))}onMouseDown(t){}onMouseMove(t){}onMouseUp(t){}onMouseEnter(t){}onTouchStart(t){}onTouchMove(t){}onTouchEnd(t){}onDeviceOrientation(t){}}class w{constructor(t,e){this.x=t,this.y=e}clone(){return new w(this.x,this.y)}}class b{static pointFromMouseEvent(t){return new w(t.screenX,t.screenY)}static pointFromTouchEvent(t){const e=t.targetTouches[0]||t.changedTouches[0];return new w(e.screenX,e.screenY)}}class y{constructor(...t){3===t.length?(({0:this.u,1:this.v,2:this.o}=t),this.w=i.cross(this.u,this.v)):4===t.length?({0:this.u,1:this.v,2:this.w,3:this.o}=t):(this.u=[1,0,0],this.v=[0,1,0],this.w=[0,0,1],this.o=[0,0,0])}get localToGlobalMatrix(){return[...[this.u[0],this.u[1],this.u[2],0],...[this.v[0],this.v[1],this.v[2],0],...[this.w[0],this.w[1],this.w[2],0],...[this.o[0],this.o[1],this.o[2],1]]}get globalToLocalMatrix(){return s.inverse(this.localToGlobalMatrix)}}class f{constructor(t,e,i){this.x=t,this.y=e,this.time=i}}class P{constructor(t){this.points=[],this.onMotion=t,this.lastPoint=new w(0,0),this.velocity=new w(0,0),this.loop=this.loop.bind(this)}destroy(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}track(t){const e=Date.now();this.points=this.points.filter((t=>e-t.time<=100)),this.points.push(new f(t.x,t.y,e)),this.lastPoint=t}start(){if(0===this.points.length)return;const t=this.points[0],e=this.points[this.points.length-1],i=e.x-t.x,s=e.y-t.y,o=e.time-t.time;this.velocity=new w(0===o?0:i/(o/15),0===o?0:s/(o/15)),this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0),this.animationFrameId=requestAnimationFrame(this.loop)}stop(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0),this.points=[]}loop(){if(Math.abs(this.velocity.x)<1&&Math.abs(this.velocity.y)<1)return this.animationFrameId=void 0,void(this.points=[]);this.lastPoint.x+=this.velocity.x,this.lastPoint.y+=this.velocity.y,this.velocity.x*=.9,this.velocity.y*=.9,this.onMotion(this.lastPoint.clone()),this.animationFrameId=requestAnimationFrame(this.loop)}}class M{constructor(t,e,s){this.target=i.copy(t),this.eye=i.copy(e),this.up=i.copy(s)}get viewVector(){return i.subtract(this.target,this.eye)}get rightVector(){return i.normalize(i.cross(this.viewVector,this.up))}get viewMatrix(){return s.inverse(s.lookAt(this.eye,this.target,this.up))}clone(){return new M(i.copy(this.target),i.copy(this.eye),i.copy(this.up))}}M.default=new M([0,0,0],[2,2,2],[0,1,0]);class x{constructor(t,e,i){this.isStarted=!1,this.pov=t,this.fov=c.degreesToRadians(e),this.orientationMatrix=s.identity(),this.inertia=new P(this.motion.bind(this)),this.onMotion=i,this.initPov=this.pov,this.initFov=this.fov,this.initOrientation=c.degreesToRadians(window.orientation)||0,this.startPov=new M([0,0,1],[0,0,0],[0,1,0]),this.startSize={width:0,height:0},this.previousPoint=new w(0,0)}destroy(){this.inertia.destroy()}get orientedPov(){const t=i.normalize(i.cross(this.pov.up,this.pov.target)),e=new y(t,[0,1,0],this.pov.eye),o=s.identity();s.multiply(o,e.localToGlobalMatrix,o),s.multiply(o,this.orientationMatrix,o),s.multiply(o,e.globalToLocalMatrix,o);const n=s.transformDirection(o,this.pov.target),r=this.pov.eye,a=s.transformDirection(o,this.pov.up);return new M(n,r,a)}reset(){this.pov=this.initPov.clone(),this.fov=this.initFov}start(t,e){this.isStarted=!0,this.startPov=this.pov,this.startSize=e,this.previousPoint=t,this.inertia.stop()}motion(t){this.isStarted&&this.inertia.track(t);const e={x:t.x-this.previousPoint.x,y:t.y-this.previousPoint.y},o=c.accelerate(e.x,1.3)/this.startSize.width*.2*Math.PI*1.5,n=c.accelerate(e.y,1.3)/this.startSize.height*.2*Math.PI,r=s.multiply(s.rotationY(-o),s.rotationX(-n)),a=i.normalize(i.cross(this.pov.up,this.pov.target)),h=new y(a,[0,1,0],this.pov.eye),d=s.identity();s.multiply(d,h.localToGlobalMatrix,d),s.multiply(d,r,d),s.multiply(d,h.globalToLocalMatrix,d);const l=s.transformPoint(d,this.pov.target),m=s.transformDirection(d,this.pov.up);i.cross(m,[0,0,1])[0]>=0&&(this.pov.target=l,this.pov.up=m),this.previousPoint=t,this.onMotion()}end(t,e){this.isStarted=!1,e&&(this.inertia.track(t),this.inertia.start())}orientation(t,e,i){const o=c.degreesToRadians(window.orientation)||0,n=c.degreesToRadians(t),r=c.degreesToRadians(-e),a=c.degreesToRadians(-i),h=s.rotationX(c.degreesToRadians(90));s.rotateZ(h,this.initOrientation,h),s.rotateZ(h,n,h),s.rotateX(h,r,h),s.rotateY(h,a,h),s.rotateZ(h,-o,h),this.orientationMatrix=h,this.onMotion()}}class E{constructor(t,i,o,n){this.container=t,this.canvas=i,this.loader=o,this.images=[],this.hotspotsList=[[]];const r=new M([0,0,1],[0,0,0],[0,1,0]),a=s.rotationX(c.degreesToRadians(15));s.transformDirection(a,r.target,r.target),s.transformDirection(a,r.up,r.up),this.interaction=new x(r,60,(()=>{this.animationFrameId=requestAnimationFrame(this.render),this.onInteraction({pov:this.interaction.pov.clone(),fov:this.interaction.fov})})),this.onInteraction=n,this.gl=this.canvas.context,this.programInfo=e.createProgramInfo(this.gl,["attribute vec4 position;uniform mat4 u_matrix;varying vec3 direction;void main(){direction=(u_matrix*position).xyz;gl_Position=position*vec4(-1,1,1,1);}\n","precision mediump float;uniform float u_mix;uniform samplerCube u_texture;uniform samplerCube u_texture_back;varying vec3 direction;void main(){vec4 backColor=textureCube(u_texture_back,direction);vec4 color=textureCube(u_texture,direction);gl_FragColor=mix(backColor,color,u_mix);}\n"]),this.quad=e.primitives.createXYQuadBufferInfo(this.gl),this.uniforms={u_matrix:s.identity(),u_mix:0,u_texture_back:e.createTexture(this.gl,{target:this.gl.TEXTURE_CUBE_MAP,minMag:this.gl.LINEAR,width:1,height:1}),u_texture:e.createTexture(this.gl,{target:this.gl.TEXTURE_CUBE_MAP,minMag:this.gl.LINEAR,width:1,height:1})},this.render=this.render.bind(this)}destroy(){this.interaction.destroy(),this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}show(){this.canvas.show(),this.container.classList.add("ls-viewer-container-vrcube")}hide(){this.canvas.hide(),this.container.classList.remove("ls-viewer-container-vrcube")}get pov(){return this.interaction.pov}set pov(t){this.interaction.pov.eye.every(((e,i)=>e===t.eye[i]))&&this.interaction.pov.target.every(((e,i)=>e===t.target[i]))&&this.interaction.pov.up.every(((e,i)=>e===t.up[i]))||(this.interaction.pov=t.clone(),this.animationFrameId=requestAnimationFrame(this.render))}get fov(){return c.radiansToDegrees(this.interaction.fov)}set fov(t){this.interaction.fov!==t&&(this.interaction.fov=c.degreesToRadians(t),this.animationFrameId=requestAnimationFrame(this.render))}get hotspots(){const t=[];this.hotspotsList.flat();const e=this.canvas.element.clientWidth,o=this.canvas.element.clientHeight,n=s.inverse(this.modelViewProjectionMatrix);return this.hotspotsList.forEach(((r,a)=>{r.forEach((r=>{const h=r.position2D.x/this.images[0].width,c=r.position2D.y/this.images[0].height;let d=0,l=0,m=0;switch(a){case 0:if(this.pov.target[2]<0)return;d=2*h-1,l=-1*(2*c-1),m=1;break;case 1:if(this.pov.target[0]<0)return;d=1,l=-1*(2*c-1),m=1-2*h;break;case 2:if(this.pov.target[2]>0)return;d=1-2*h,l=-1*(2*c-1),m=-1;break;case 3:if(this.pov.target[0]>0)return;d=-1,l=-1*(2*c-1),m=2*h-1;break;case 4:if(this.pov.target[1]<0)return;d=2*h-1,l=1,m=2*c-1;break;case 5:if(this.pov.target[1]>0)return;d=2*h-1,l=-1,m=-1*(2*c-1)}const u=i.normalize([d,l,m]),v=s.transformPoint(n,u),g={x:e-.5*e*(v[0]+1),y:o-.5*o*(v[1]+1)};t.push(Object.assign(Object.assign({},r),{position2D:g}))}))})),t}async load(t,i,s,o){let n=Promise.resolve();const r=JSON.stringify(t);r===this.snapshotHash?n=n.then((()=>(this.animationFrameId=requestAnimationFrame(this.render),Promise.resolve()))):(this.images=[],this.animationFrameId=requestAnimationFrame(this.render),n=n.then((()=>this.loader.loadVRCubeSnapshot(t).then((t=>{this.images=t,e.createTexture(this.gl,{target:this.gl.TEXTURE_CUBE_MAP,minMag:this.gl.LINEAR,auto:!1,cubeFaceOrder:[this.gl.TEXTURE_CUBE_MAP_POSITIVE_Z,this.gl.TEXTURE_CUBE_MAP_POSITIVE_X,this.gl.TEXTURE_CUBE_MAP_NEGATIVE_Z,this.gl.TEXTURE_CUBE_MAP_NEGATIVE_X,this.gl.TEXTURE_CUBE_MAP_POSITIVE_Y,this.gl.TEXTURE_CUBE_MAP_NEGATIVE_Y],src:t},((t,e)=>{t||(s&&this.interaction.reset(),this.uniforms.u_mix=o?0:1,this.uniforms.u_texture_back=this.uniforms.u_texture,this.uniforms.u_texture=e,this.animationFrameId=requestAnimationFrame(this.render))}))})))));const a=JSON.stringify(i);return!i.length||r===this.snapshotHash&&a===this.tagsHash||(n=n.then((()=>this.loader.loadVRCubeHotspots(t,i).then((t=>{this.hotspotsList=t}))))),this.snapshotHash=r,this.tagsHash=a,n.then((()=>Promise.resolve(this.hotspots)))}snapshot(t,e){return this.canvas.element.toDataURL(t,e)}get modelViewProjectionMatrix(){const t=this.canvas.element.clientWidth,e=this.canvas.element.clientHeight,i=t>e?t/e:e/t,o=r.getStandardAspectRatio(t,e),n=this.interaction.fov*(o/i),a=t>e?c.perspectiveWithFovY(n,t/e,.5,100):c.perspectiveWithFovX(n,t/e,.5,100),h=s.inverse(a),d=this.interaction.orientedPov,l=s.lookAt(d.eye,d.target,d.up);return s.multiply(l,h)}render(){this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height),this.uniforms.u_matrix=this.modelViewProjectionMatrix,this.gl.useProgram(this.programInfo.program),e.setBuffersAndAttributes(this.gl,this.programInfo,this.quad),e.setUniforms(this.programInfo,this.uniforms),e.drawBufferInfo(this.gl,this.quad),this.uniforms.u_mix<1&&(this.uniforms.u_mix=Math.min(this.uniforms.u_mix+.05,1),this.animationFrameId=requestAnimationFrame(this.render))}onMouseDown(t){this.container.classList.add("ls-viewer-container-vrcube-grabbing"),this.interaction.start(b.pointFromMouseEvent(t),{width:this.gl.canvas.width,height:this.gl.canvas.height})}onMouseMove(t){this.interaction.isStarted&&(this.interaction.motion(b.pointFromMouseEvent(t)),t.preventDefault())}onMouseUp(t){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrcube-grabbing"),this.interaction.end(b.pointFromMouseEvent(t),!0))}onMouseEnter(t){this.interaction.isStarted&&0===t.buttons&&(this.container.classList.remove("ls-viewer-container-vrcube-grabbing"),this.interaction.end(b.pointFromMouseEvent(t),!1))}onTouchStart(t){this.container.classList.add("ls-viewer-container-vrcube-grabbing"),this.interaction.start(b.pointFromTouchEvent(t),{width:this.gl.canvas.width,height:this.gl.canvas.height})}onTouchMove(t){this.interaction.isStarted&&(this.interaction.motion(b.pointFromTouchEvent(t)),t.preventDefault())}onTouchEnd(t){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrcube-grabbing"),this.interaction.end(b.pointFromTouchEvent(t),!0))}onDeviceOrientation(t){this.interaction.orientation(t.alpha,t.beta,t.gamma)}}class L{constructor(t,e,i,s,o){this.isStarted=!1,this.position=t,this.frames=e,this.rows=i,this.loop=s,this.onMotion=o,this.inertia=new P(this.motion.bind(this)),this.initPosition=this.position,this.startPosition={x:0,y:0},this.startPoint=new w(0,0),this.startSize={width:0,height:0},this.lastPoints=[],this.lastPointsNumber=20}destroy(){this.inertia.destroy()}reset(){this.position=this.initPosition}get positionIndex(){return this.frames*this.position.y+this.position.x}set positionIndex(t){if(this.positionIndex===t)return;const e=this.loop?c.mod(t,this.frames*this.rows):Math.max(0,Math.min(t,this.frames*this.rows));this.position.x=c.mod(e,this.frames),this.position.y=Math.floor(e/this.frames)}start(t,e){this.isStarted=!0,this.startPosition=Object.assign({},this.position),this.startPoint=t,this.startSize=e,this.lastPoints=[],this.inertia.stop()}motion(t){this.isStarted&&this.inertia.track(t),this.lastPoints.push({x:t.x,y:t.y}),this.lastPoints.splice(0,this.lastPoints.length-this.lastPointsNumber);const e=o.linear(this.lastPoints.map((t=>[t.x,t.y])));if(Math.abs(e.equation[0])<1){const e=c.accelerate(t.x-this.startPoint.x,1.3)/this.startSize.width*(this.frames/4);let i=this.startPosition.x-Math.round(e);i=this.loop?c.mod(i,this.frames):Math.max(0,Math.min(i,this.frames-1)),i!==this.position.x&&(this.position.x=i,this.onMotion());const s=Math.min(...this.lastPoints.map((t=>t.x)));Math.max(...this.lastPoints.map((t=>t.x)))-s>25&&(this.startPoint.y=t.y,this.startPosition.y=this.position.y)}else{const e=c.accelerate(t.y-this.startPoint.y,1.7)/this.startSize.height*(this.rows/4);let i=this.startPosition.y+Math.round(e);i=Math.max(0,Math.min(i,this.rows-1)),i!==this.position.y&&(this.position.y=i,this.onMotion());const s=Math.min(...this.lastPoints.map((t=>t.y)));Math.max(...this.lastPoints.map((t=>t.y)))-s>25&&(this.startPoint.x=t.x,this.startPosition.x=this.position.x)}}end(t,e){this.isStarted=!1,e&&(this.inertia.track(t),this.inertia.start())}}class I{constructor(t,e,i,s){this.container=t,this.canvas=e,this.loader=i,this.images=[],this.frames=24,this.hotspotsList=[[]],this.interaction=new L({x:0,y:0},1,1,!1,(()=>{this.canvas.draw(this.image,!0,.5),this.onInteraction({position:this.interaction.positionIndex})})),this.onInteraction=s}destroy(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}show(){this.canvas.show(!1),this.container.classList.add("ls-viewer-container-vrobject")}hide(){this.canvas.hide(!1),this.container.classList.remove("ls-viewer-container-vrobject")}async goto(t){return new Promise((e=>{let i=this.interaction.positionIndex;const s=()=>{if(this.interaction.positionIndex===t)e();else{let e=i>t?-1:1;this.interaction.loop&&this.interaction.frames-i+t<Math.abs(t-i)&&(e*=-1),i+=.5*e,this.position=Math.floor(i),this.animationFrameId=requestAnimationFrame(s)}};this.animationFrameId=requestAnimationFrame(s)}))}get position(){return this.interaction.positionIndex}set position(t){this.interaction.positionIndex=t,this.canvas.draw(this.image,!0,.5)}get image(){return this.images[this.interaction.positionIndex]}get hotspots(){return this.hotspotsList[this.interaction.positionIndex]||[]}async load(t,e,i,s){let o=Promise.resolve();i&&this.interaction.reset();const n=JSON.stringify(t);n===this.snapshotHash&&this.image?o=o.then((()=>this.canvas.draw(this.image,s,.05))):(this.images=[],o=o.then((()=>this.loader.loadVRObjectSnapshot(t,this.interaction.positionIndex).then((e=>{const o=e.length;return this.images=new Array(o),this.interaction.frames=t.view.frames||this.frames,this.interaction.rows=o/this.interaction.frames,this.interaction.loop=!!t.view.loop,i&&this.interaction.reset(),e.forEach(((t,e)=>{t.then((t=>{this.images[e]=t,t===this.image&&this.canvas.draw(this.image,s,.05)})).catch((()=>{}))})),e[this.interaction.positionIndex].then((()=>Promise.resolve()))})))));const r=JSON.stringify(e);return!e.length||n===this.snapshotHash&&r===this.tagsHash||(o=o.then((()=>this.loader.loadVRObjectHotspots(t,e).then((t=>{this.hotspotsList=t}))))),this.snapshotHash=n,this.tagsHash=r,o.then((()=>Promise.resolve(this.hotspots)))}snapshot(t,e){return this.canvas.element.toDataURL(t,e)}onMouseDown(t){this.container.classList.add("ls-viewer-container-vrobject-grabbing"),this.interaction.start(b.pointFromMouseEvent(t),{width:this.canvas.element.width,height:this.canvas.element.height})}onMouseMove(t){this.interaction.isStarted&&(this.interaction.motion(b.pointFromMouseEvent(t)),t.preventDefault())}onMouseUp(t){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrobject-grabbing"),this.interaction.end(b.pointFromMouseEvent(t),!0))}onMouseEnter(t){this.interaction.isStarted&&0===t.buttons&&(this.container.classList.remove("ls-viewer-container-vrobject-grabbing"),this.interaction.end(b.pointFromMouseEvent(t),!1))}onTouchStart(t){this.container.classList.add("ls-viewer-container-vrobject-grabbing"),this.interaction.start(b.pointFromTouchEvent(t),{width:this.canvas.element.width,height:this.canvas.element.height})}onTouchMove(t){this.interaction.isStarted&&(this.interaction.motion(b.pointFromTouchEvent(t)),t.preventDefault())}onTouchEnd(t){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrobject-grabbing"),this.interaction.end(b.pointFromTouchEvent(t),!0))}onDeviceOrientation(t){}}var S;!function(t,e){void 0===e&&(e={});var i=e.insertAt;if(t&&"undefined"!=typeof document){var s=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===i&&s.firstChild?s.insertBefore(o,s.firstChild):s.appendChild(o),o.styleSheet?o.styleSheet.cssText=t:o.appendChild(document.createTextNode(t))}}(".ls-viewer-container{display:block;height:100%;overflow:hidden;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:100%}.ls-viewer-container-image,.ls-viewer-container-video{cursor:default;pointer-events:none}.ls-viewer-container-vrcube{cursor:pointer;cursor:-webkit-grab;cursor:grab}.ls-viewer-container-vrcube-grabbing{cursor:move;cursor:-webkit-grabbing;cursor:grabbing}.ls-viewer-container-vrobject{cursor:move;cursor:-webkit-grab;cursor:grab}.ls-viewer-container-vrobject-grabbing{cursor:move;cursor:-webkit-grabbing;cursor:grabbing}.ls-viewer-container-loading{cursor:progress}.ls-viewer-canvas{opacity:0;position:absolute;-webkit-transition:opacity .5s;transition:opacity .5s}.ls-viewer-video{position:absolute}");class A{constructor(e,i){this.checkResize=this.checkResize.bind(this),this.onDeviceOrientation=this.onDeviceOrientation.bind(this),this.onResize=this.onResize.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onMouseEnter=this.onMouseEnter.bind(this),this.onTouchStart=this.onTouchStart.bind(this),this.onTouchMove=this.onTouchMove.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this),this.onLoadStart=this.onLoadStart.bind(this),this.onLoadProgress=this.onLoadProgress.bind(this),this.onLoadEnd=this.onLoadEnd.bind(this),this.onLoadError=this.onLoadError.bind(this),this.onHotspotsChange=this.onHotspotsChange.bind(this),this.onVrcubeInteraction=this.onVrcubeInteraction.bind(this),this.onVrobjectInteraction=this.onVrobjectInteraction.bind(this),this.options=Object.assign({server:"localhost",api:"v1",fit:"cover",image:{},video:{},vrcube:{},vrobject:{},events:{}},i),this.options.events=Object.assign({onLoadStart:()=>{},onLoadProgress:()=>{},onLoadEnd:()=>{},onLoadError:()=>{},onInteraction:()=>{},onVrcubeInteraction:()=>{},onVrobjectInteraction:()=>{},onHotspotsChange:()=>{}},i.events),this.options.events.onLoadError=t(this.options.events.onLoadError,10),this.container=e,this.container.classList.add("ls-viewer-container"),this.containerWidth=0,this.containerHeight=0,this.canvas2D=new a(this.options.fit),this.container.appendChild(this.canvas2D.element),this.canvas3D=new h,this.container.appendChild(this.canvas3D.element),this.video=new v,this.container.appendChild(this.video.element),this.loader=new u(this.options.server,this.options.api,this),this.resolution=new n(0,0),this.parameters={width:0,height:0,antialiasing:!1,superSampling:2},this.encoder={format:"jpeg",quality:80},this.widgetImage=new g(e,this.canvas2D,this.loader),this.widgetVideo=new p(e,this.video,this.loader),this.widgetVRCube=new E(e,this.canvas3D,this.loader,this.onVrcubeInteraction),this.widgetVRObject=new I(e,this.canvas2D,this.loader,this.onVrobjectInteraction),this.widget=this.widgetImage,this.isDestroyed=!1,this.container.addEventListener("mousedown",this.onMouseDown),this.container.addEventListener("mouseenter",this.onMouseEnter),this.container.addEventListener("touchstart",this.onTouchStart),document.addEventListener("mousemove",this.onMouseMove,{passive:!1}),document.addEventListener("mouseup",this.onMouseUp),document.addEventListener("touchmove",this.onTouchMove,{passive:!1}),document.addEventListener("touchend",this.onTouchEnd),this.checkResize(),this.loadWidget=t(this.loadWidget,10),this.onResize=t(this.onResize,250)}destroy(){this.canvas2D.destroy(),this.container.removeEventListener("mousedown",this.onMouseDown),this.container.removeEventListener("mouseenter",this.onMouseEnter),this.container.removeEventListener("touchstart",this.onTouchStart),document.removeEventListener("mousemove",this.onMouseMove),document.removeEventListener("mouseup",this.onMouseUp),document.removeEventListener("touchmove",this.onTouchMove),document.removeEventListener("touchend",this.onTouchEnd),this.isDestroyed=!0}async load(t,e){let i=Promise.resolve();return(null==e?void 0:e.animation)&&(i=i.then((()=>this.loadAnimation(e.animation)))),this.view&&void 0!==(null==e?void 0:e.fromPosition)&&this.viewWidget instanceof I&&(this.view.mode,i=i.then((()=>this.viewWidget.goto(e.fromPosition)))),(null==e?void 0:e.animation)&&(i=i.then((()=>this.widgetVideo.play()))),i=i.then((()=>(this.scene=Array.isArray(t)?[...t]:[t],this.loadWidget(!1,!(e&&e.animation))))),i.catch((t=>{this.onLoadError(t)})),i}async setEncoder(t){this.encoder=Object.assign({},t);let e=Promise.resolve();return e=e.then((()=>this.loadWidget(!1,!0))),e.catch((t=>{this.onLoadError(t)})),e}setParameters(t){this.parameters=Object.assign({},t),this.parameters.width=this.resolution.width,this.parameters.height=this.resolution.height;let e=Promise.resolve();return e=e.then((()=>this.loadWidget(!1,!0))),e.catch((t=>{this.onLoadError(t)})),e}setTags(t){this.tags=t,this.loadWidget(!1,!1)}async setView(t,e){let i=Promise.resolve();return(null==e?void 0:e.animation)&&(i=i.then((()=>this.loadAnimation(e.animation)))),this.view&&void 0!==(null==e?void 0:e.fromPosition)&&this.viewWidget instanceof I&&(i=i.then((()=>this.viewWidget.goto(e.fromPosition)))),(null==e?void 0:e.animation)&&(i=i.then((()=>this.widgetVideo.play()))),i=i.then((()=>{let i=!0;return this.view=Object.assign({},t),this.view&&this.viewWidget instanceof I&&void 0!==(null==e?void 0:e.toPosition)&&(i=!1,this.viewWidget.position=e.toPosition),this.loadWidget(i,!(e&&e.animation))})),i.catch((t=>{this.onLoadError(t)})),i}setVrcube(t){Object.assign(this.widgetVRCube,t)}setVrobject(t){Object.assign(this.widgetVRObject,t)}async loadAnimation(t){var e;const i={scene:this.scene,view:{animation:t.name,camera:t.camera,duration:t.duration,loop:t.loop,reverse:t.reverse},parameters:this.parameters,encoder:{format:"mp4"}};return(null===(e=i.view)||void 0===e?void 0:e.background)||(i.view.background="product"),this.widgetVideo.load(i).then((()=>Promise.resolve()))}async playAnimation(t){return this.loadAnimation(t).then((()=>this.widgetVideo.play())).catch((t=>{this.onLoadError(t)}))}stopAnimation(){this.widgetVideo.hide()}snapshot(t,e){return this.viewWidget.snapshot(t,e)}async loadWidget(t,e){if(!this.scene||!this.view)return Promise.resolve();if(!this.parameters.width||!this.parameters.height)return Promise.resolve();const i=this.viewWidget;if(!i)return Promise.reject(new Error("Unknown view mode"));const s={scene:this.scene,view:this.view,parameters:this.parameters,encoder:this.encoder};return s.view.background||(s.view.background="product"),i.load(s,this.tags||[],t,e).then((t=>{this.widget.hide(),this.widget=i,this.widget.show(),this.widgetVideo.hide(),this.onHotspotsChange(t)}))}get viewWidget(){var t;switch(null===(t=this.view)||void 0===t?void 0:t.mode){case"image":default:return this.widgetImage;case"video":return this.widgetVideo;case"vrcube":return this.widgetVRCube;case"vrobject":return this.widgetVRObject}}checkResize(){if(this.isDestroyed)return;const t=this.container.clientWidth,e=this.container.clientHeight;t===this.containerWidth&&e===this.containerHeight||(this.containerWidth=t,this.containerHeight=e,this.onResize()),this.isDestroyed||requestAnimationFrame(this.checkResize)}onMouseDown(t){this.widget.onMouseDown(t)}onMouseEnter(t){this.widget.onMouseEnter(t)}onMouseMove(t){this.widget.onMouseMove(t)}onMouseUp(t){this.widget.onMouseUp(t)}onTouchStart(t){this.widget.onTouchStart(t)}onTouchMove(t){this.widget.onTouchMove(t)}onTouchEnd(t){this.widget.onTouchEnd(t)}onDeviceOrientation(t){this.widget.onDeviceOrientation(t)}onResize(){const t=this.container.clientWidth,e=this.container.clientHeight;this.resolution=r.getStandardResolution(t*window.devicePixelRatio,e*window.devicePixelRatio),this.parameters.width=this.resolution.width,this.parameters.height=this.resolution.height,this.canvas2D.resize(t,e,window.devicePixelRatio),this.canvas3D.resize(t,e,window.devicePixelRatio),this.video.resize(t,e,this.resolution,this.options.fit),this.loadWidget(!1,!1).catch((t=>{this.onLoadError(t)}))}onVrcubeInteraction(...t){this.options.events.onHotspotsChange(this.widgetVRCube.hotspots),this.options.events.onInteraction(...t),this.options.events.onVrcubeInteraction(...t)}onVrobjectInteraction(...t){this.options.events.onHotspotsChange(this.widgetVRObject.hotspots),this.options.events.onInteraction(...t),this.options.events.onVrobjectInteraction(...t)}onHotspotsChange(...t){this.options.events.onHotspotsChange(...t)}onLoadStart(...t){this.container.classList.add("ls-viewer-container-loading"),this.options.events.onLoadStart(...t)}onLoadProgress(...t){this.options.events.onLoadProgress(...t)}onLoadEnd(...t){this.container.classList.remove("ls-viewer-container-loading"),this.options.events.onLoadEnd(...t)}onLoadError(...t){this.container.classList.remove("ls-viewer-container-loading"),this.options.events.onLoadError(...t)}}!function(t){var e,i,s;(e=t.SunShadowQualityMode||(t.SunShadowQualityMode={})).VeryLow="veryLow",e.Low="low",e.Medium="medium",e.Fine="fine",e.Ultra="ultra",(i=t.SunShadowSmoothnessMode||(t.SunShadowSmoothnessMode={})).None="none",i.Weak="weak",i.Normal="normal",i.Fine="fine",i.UltraFine="ultraFine",i.Max="max",(s=t.SunUseCaseMode||(t.SunUseCaseMode={})).Manual="manual",s.ExtractedFromEnv="extractedFromEnv"}(S||(S={}));export{A as Viewer,S as WRAPIv2,g as WidgetImage,E as WidgetVRCube,I as WidgetVRObject,p as WidgetVideo};
function(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(s=Object.getOwnPropertySymbols(t);o<s.length;o++)e.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(t,s[o])&&(i[s[o]]=t[s[o]])}return i}(t,["accessory","decor"]);return e}))}static renderParameters(t){return Object.assign(Object.assign({},t.parameters),{superSampling:t.parameters.superSampling.toString()})}static encoder(t){switch(t.encoder.format){case"jpeg":return{jpeg:{quality:t.encoder.quality}};case"png":return{png:{compression:t.encoder.compression}};case"webp":return{webp:{quality:t.encoder.quality}}}return{jpeg:{quality:80}}}static async fetchFrame(t,e){return fetch(t,{method:"POST",body:JSON.stringify(e)}).then((t=>t.json())).then((t=>t.url))}static async fetchFrameArray(t,e){return fetch(t,{method:"POST",body:JSON.stringify(e)}).then((t=>t.json())).then((t=>t.map((t=>t.url))))}static async fetchHotspots(t,e){return fetch(t,{method:"POST",body:JSON.stringify(e)}).then((t=>t.json())).then((t=>t))}static async fetchHotspotsArray(t,e){return fetch(t,{method:"POST",body:JSON.stringify(e)}).then((t=>t.json())).then((t=>t))}async image(t){const e={scene:m.scene(t),mode:{image:{camera:t.view.camera}},renderParameters:m.renderParameters(t),encoder:m.encoder(t)};return m.fetchFrame(`${this.server}/Snapshot`,e)}async vrCube(t){const e={scene:m.scene(t),mode:{vrCube:{camera:t.view.camera}},renderParameters:m.renderParameters(t),encoder:m.encoder(t)};return e.renderParameters.width=Math.max(e.renderParameters.width,e.renderParameters.height),e.renderParameters.height=Math.max(e.renderParameters.width,e.renderParameters.height),m.fetchFrameArray(`${this.server}/Snapshot`,e)}async vrObject(t){let e;e=t.view.cameraGroup?{images:{cameraGroup:t.view.cameraGroup}}:t.view.frames?{vrObject:{camera:t.view.camera,frames:t.view.frames}}:{vrObject:{camera:t.view.camera,panFrames:t.view.panFrames||1,panFrom:t.view.panFrom||0,panTo:t.view.panTo||0,panLoop:t.view.panLoop||!1,tiltFrames:t.view.tiltFrames||1,tiltFrom:t.view.tiltFrom||0,tiltTo:t.view.tiltTo||0,tiltLoop:t.view.tiltLoop||!1}};const i={scene:m.scene(t),mode:e,renderParameters:m.renderParameters(t),encoder:m.encoder(t)};return m.fetchFrameArray(`${this.server}/Snapshot`,i)}async animation(t){const e={scene:m.scene(t),mode:{animation:{id:t.view.animation,camera:t.view.camera,fps:t.view.fps}},renderParameters:m.renderParameters(t),encoder:m.encoder(t)};return m.fetchFrameArray(`${this.server}/Snapshot`,e)}async imageHotspots(t,e){const i={scene:m.scene(t),mode:{image:{camera:t.view.camera}},renderParameters:m.renderParameters(t),tags:e};return await m.fetchHotspots(`${this.server}/Hotspot`,i)}async vrCubeHotspots(t,e){const i={scene:m.scene(t),mode:{vrCube:{camera:t.view.camera}},renderParameters:m.renderParameters(t),tags:e};return i.renderParameters.width=Math.max(i.renderParameters.width,i.renderParameters.height),i.renderParameters.height=Math.max(i.renderParameters.width,i.renderParameters.height),await m.fetchHotspotsArray(`${this.server}/Hotspot`,i)}async vrObjectHotspots(t,e){let i;i=t.view.cameraGroup?{images:{cameraGroup:t.view.cameraGroup}}:t.view.frames?{vrObject:{camera:t.view.camera,frames:t.view.frames}}:{vrObject:{camera:t.view.camera,panFrames:t.view.panFrames||1,panFrom:t.view.panFrom||0,panTo:t.view.panTo||0,panLoop:t.view.panLoop||!1,tiltFrames:t.view.tiltFrames||1,tiltFrom:t.view.tiltFrom||0,tiltTo:t.view.tiltTo||0,tiltLoop:t.view.tiltLoop||!1}};const s={scene:m.scene(t),mode:i,renderParameters:m.renderParameters(t),tags:e};return await m.fetchHotspotsArray(`${this.server}/Hotspot`,s)}}class u{constructor(t,e,i){switch(e){case"static":this.webrender=new d;break;case"v1":default:this.webrender=new l(t);break;case"v2":this.webrender=new m(t)}this.delegate=i,this.loadingId=0,this.loaded=0,this.total=0,this.onLoadStart=i&&i.onLoadStart?i.onLoadStart:()=>{},this.onLoadProgress=i&&i.onLoadProgress?i.onLoadProgress:()=>{},this.onLoadEnd=i&&i.onLoadEnd?i.onLoadEnd:()=>{}}get progress(){return this.total?this.loaded/this.total:0}async loadImageSnapshot(t){this.loadingId+=1,this.loaded=0,this.total=1,this.onLoadStart(this.progress);const{loadingId:e}=this;return this.webrender.image(t).then((t=>this.loadImage(t,e))).then((t=>(this.onLoadEnd(this.progress),t)))}async loadVideoSnapshot(t,e){this.loadingId+=1,this.loaded=0,this.total=1,this.onLoadStart(this.progress);const{loadingId:i}=this;return this.webrender.video(e).then((s=>this.loadVideo(t,s,!!e.view.loop,i))).then((()=>(this.onLoadEnd(this.progress),t)))}async loadVRCubeSnapshot(t){this.loadingId+=1,this.loaded=0,this.total=0,this.onLoadStart(this.progress);const{loadingId:e}=this;return this.webrender.vrCube(t).then((t=>{this.total=t.length;const i=t.map((t=>this.loadImage(t,e)));return Promise.all(i)})).then((t=>(this.onLoadEnd(this.progress),t)))}async loadVRObjectSnapshot(t,e){var i;this.loadingId+=1,this.loaded=0,this.total=0,this.onLoadStart(this.progress);const{loadingId:s}=this;return t.view.animation?"mp4"===(null===(i=t.encoder)||void 0===i?void 0:i.format)?this.webrender.video(t).then((e=>this.loadVideoFrames(e,t.view.frames,30,s))):this.webrender.animation(t).then((i=>this.loadImageFrames(i,t.view.loop,e,s))):this.webrender.vrObject(t).then((i=>this.loadImageFrames(i,t.view.loop,e,s)))}async loadImage(t,e){const i=new Image;i.crossOrigin="file:"!==location.protocol||u.isValidHttpUrl(t)?"anonymous":null;const s=new Promise(((s,o)=>{i.addEventListener("load",(()=>{e===this.loadingId&&(this.loaded+=1,this.onLoadProgress(this.progress),s(i))}),{once:!0}),i.addEventListener("error",(i=>{e===this.loadingId&&o(`${i.type} : ${t}`)}),{once:!0})}));return i.src=t,s}loadImageFrames(t,e,i,s){this.total=t.length;const o=new Array(t.length),n=i||0;for(let i=0,r=t.length;i<r;i+=1){const a=Math.ceil(i/2)*(i%2==0?1:-1),h=e?c.mod(n+a,r):i;o[h]=this.loadImage(t[h],s)}return Promise.all(o).then((()=>this.onLoadEnd(this.progress))).catch((()=>{})),o}async loadVideo(t,e,i,s){t.loop=i;const o=new Promise(((i,o)=>{t.addEventListener("canplaythrough",(()=>{s===this.loadingId&&(this.loaded+=1,this.onLoadProgress(this.progress),i())}),{once:!0}),t.addEventListener("error",(t=>{s===this.loadingId&&o(`${t.type} : ${e}`)}),{once:!0})}));return t.src=e,t.load(),o}async loadVideoFrame(t,e,i,s,o){let n=0;return new Promise(((r,a)=>{const h=()=>{if(o!==this.loadingId)return;if(n!==s)return void(n+=1);t.removeEventListener("seeked",h);const a=document.createElement("canvas");a.width=t.videoWidth,a.height=t.videoHeight;a.getContext("2d").drawImage(t,0,0);const c=new Image;c.src=a.toDataURL(),r(c),this.loaded+=1,this.onLoadProgress(this.progress),s!==i-1&&(t.currentTime+=1/e)};t.addEventListener("seeked",h),t.addEventListener("error",(t=>{o===this.loadingId&&a(t)}),{once:!0})}))}loadVideoFrames(t,e,i,s){this.total=e;const o=new Array(e),n=document.createElement("video");for(let t=0,r=e;t<r;t+=1)o[t]=this.loadVideoFrame(n,i,e,t,s);return n.addEventListener("canplaythrough",(()=>{s===this.loadingId&&(n.currentTime=1/i/2)}),{once:!0}),n.src=t,n.load(),Promise.all(o).then((()=>this.onLoadEnd(this.progress))).catch((()=>{})),o}async loadImageHotspots(t,e){return this.webrender instanceof m?await this.webrender.imageHotspots(t,e):Promise.reject(new Error("Hotspots only available with api V2"))}async loadVRCubeHotspots(t,e){return this.webrender instanceof m?await this.webrender.vrCubeHotspots(t,e):Promise.reject(new Error("Hotspots only available with api V2"))}async loadVRObjectHotspots(t,e){return this.webrender instanceof m?await this.webrender.vrObjectHotspots(t,e):Promise.reject(new Error("Hotspots only available with api V2"))}onLoadStart(t){this.delegate&&this.delegate.onLoadStart(t)}onLoadProgress(t){this.delegate&&this.delegate.onLoadProgress(t)}onLoadEnd(t){this.delegate&&this.delegate.onLoadEnd(t)}static isValidHttpUrl(t){let e;try{e=new URL(t)}catch(t){return!1}return"http:"===e.protocol||"https:"===e.protocol}}class v{constructor(){this.element=document.createElement("video"),this.element.classList.add("ls-viewer-video"),this.element.style.opacity="0",this.element.setAttribute("muted",""),this.element.setAttribute("playsinline",""),this.element.setAttribute("preload","auto")}show(){this.element.style.opacity="1"}hide(){this.element.style.opacity="0"}resize(t,e,i,s){const o=r.fit(i,new n(t,e),s);this.element.style.top=`${o.top}px`,this.element.style.left=`${o.left}px`,this.element.style.width=`${o.width}px`,this.element.style.height=`${o.height}px`,i.width===this.element.width&&i.height===this.element.height||(this.element.width=i.width,this.element.height=i.height)}}class g{constructor(t,e,i){this.container=t,this.canvas=e,this.loader=i,this.hotspots=[]}destroy(){}show(){this.canvas.show(!1),this.container.classList.add("ls-viewer-container-image")}hide(){this.canvas.hide(!1),this.container.classList.remove("ls-viewer-container-image")}async load(t,e,i,s){let o=Promise.resolve();const n=JSON.stringify(t);o=n===this.snapshotHash&&this.image?o.then((()=>this.canvas.draw(this.image,s,.05))):o.then((()=>this.loader.loadImageSnapshot(t).then((t=>{this.canvas.draw(t,s,.05),this.image=t}))));const r=JSON.stringify(e);return!e.length||n===this.snapshotHash&&r===this.tagsHash||(o=o.then((()=>this.loader.loadImageHotspots(t,e).then((t=>{this.hotspots=t}))))),this.snapshotHash=n,this.tagsHash=r,o.then((()=>Promise.resolve(this.hotspots)))}snapshot(t,e){return this.canvas.element.toDataURL(t,e)}onMouseDown(t){}onMouseMove(t){}onMouseUp(t){}onMouseEnter(t){}onTouchStart(t){}onTouchMove(t){}onTouchEnd(t){}onDeviceOrientation(t){}}class p{constructor(t,e,i){this.container=t,this.loader=i,this.video=e}destroy(){}show(){this.video.show(),this.container.classList.add("ls-viewer-container-video")}hide(){this.video.hide(),this.container.classList.remove("ls-viewer-container-video")}async load(t){const e=JSON.stringify(t);return e===this.hash?(this.video.element.load(),Promise.resolve([])):(this.hash=e,this.loader.loadVideoSnapshot(this.video.element,t).then((()=>Promise.resolve([]))))}snapshot(t,e){return"data:image/gif;base64,R0lGODlhAQABAIAAAP7//wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=="}async play(){return new Promise(((t,e)=>{this.video.element.addEventListener("ended",(()=>{t()}),{once:!0}),this.video.element.play().catch(e),this.show()}))}onMouseDown(t){}onMouseMove(t){}onMouseUp(t){}onMouseEnter(t){}onTouchStart(t){}onTouchMove(t){}onTouchEnd(t){}onDeviceOrientation(t){}}class w{constructor(t,e){this.x=t,this.y=e}clone(){return new w(this.x,this.y)}}class b{static pointFromMouseEvent(t){return new w(t.screenX,t.screenY)}static pointFromTouchEvent(t){const e=t.targetTouches[0]||t.changedTouches[0];return new w(e.screenX,e.screenY)}}class y{constructor(...t){3===t.length?(({0:this.u,1:this.v,2:this.o}=t),this.w=i.cross(this.u,this.v)):4===t.length?({0:this.u,1:this.v,2:this.w,3:this.o}=t):(this.u=[1,0,0],this.v=[0,1,0],this.w=[0,0,1],this.o=[0,0,0])}get localToGlobalMatrix(){return[...[this.u[0],this.u[1],this.u[2],0],...[this.v[0],this.v[1],this.v[2],0],...[this.w[0],this.w[1],this.w[2],0],...[this.o[0],this.o[1],this.o[2],1]]}get globalToLocalMatrix(){return s.inverse(this.localToGlobalMatrix)}}class f{constructor(t,e,i){this.x=t,this.y=e,this.time=i}}class P{constructor(t){this.points=[],this.onMotion=t,this.lastPoint=new w(0,0),this.velocity=new w(0,0),this.loop=this.loop.bind(this)}destroy(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}track(t){const e=Date.now();this.points=this.points.filter((t=>e-t.time<=100)),this.points.push(new f(t.x,t.y,e)),this.lastPoint=t}start(){if(0===this.points.length)return;const t=this.points[0],e=this.points[this.points.length-1],i=e.x-t.x,s=e.y-t.y,o=e.time-t.time;this.velocity=new w(0===o?0:i/(o/15),0===o?0:s/(o/15)),this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0),this.animationFrameId=requestAnimationFrame(this.loop)}stop(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0),this.points=[]}loop(){if(Math.abs(this.velocity.x)<1&&Math.abs(this.velocity.y)<1)return this.animationFrameId=void 0,void(this.points=[]);this.lastPoint.x+=this.velocity.x,this.lastPoint.y+=this.velocity.y,this.velocity.x*=.9,this.velocity.y*=.9,this.onMotion(this.lastPoint.clone()),this.animationFrameId=requestAnimationFrame(this.loop)}}class M{constructor(t,e,s){this.target=i.copy(t),this.eye=i.copy(e),this.up=i.copy(s)}get viewVector(){return i.subtract(this.target,this.eye)}get rightVector(){return i.normalize(i.cross(this.viewVector,this.up))}get viewMatrix(){return s.inverse(s.lookAt(this.eye,this.target,this.up))}clone(){return new M(i.copy(this.target),i.copy(this.eye),i.copy(this.up))}}M.default=new M([0,0,0],[2,2,2],[0,1,0]);class x{constructor(t,e,i){this.isStarted=!1,this.pov=t,this.fov=c.degreesToRadians(e),this.orientationMatrix=s.identity(),this.inertia=new P(this.motion.bind(this)),this.onMotion=i,this.initPov=this.pov,this.initFov=this.fov,this.initOrientation=c.degreesToRadians(window.orientation)||0,this.startPov=new M([0,0,1],[0,0,0],[0,1,0]),this.startSize={width:0,height:0},this.previousPoint=new w(0,0)}destroy(){this.inertia.destroy()}get orientedPov(){const t=i.normalize(i.cross(this.pov.up,this.pov.target)),e=new y(t,[0,1,0],this.pov.eye),o=s.identity();s.multiply(o,e.localToGlobalMatrix,o),s.multiply(o,this.orientationMatrix,o),s.multiply(o,e.globalToLocalMatrix,o);const n=s.transformDirection(o,this.pov.target),r=this.pov.eye,a=s.transformDirection(o,this.pov.up);return new M(n,r,a)}reset(){this.pov=this.initPov.clone(),this.fov=this.initFov}start(t,e){this.isStarted=!0,this.startPov=this.pov,this.startSize=e,this.previousPoint=t,this.inertia.stop()}motion(t){this.isStarted&&this.inertia.track(t);const e={x:t.x-this.previousPoint.x,y:t.y-this.previousPoint.y},o=c.accelerate(e.x,1.3)/this.startSize.width*.2*Math.PI*1.5,n=c.accelerate(e.y,1.3)/this.startSize.height*.2*Math.PI,r=s.multiply(s.rotationY(-o),s.rotationX(-n)),a=i.normalize(i.cross(this.pov.up,this.pov.target)),h=new y(a,[0,1,0],this.pov.eye),d=s.identity();s.multiply(d,h.localToGlobalMatrix,d),s.multiply(d,r,d),s.multiply(d,h.globalToLocalMatrix,d);const l=s.transformPoint(d,this.pov.target),m=s.transformDirection(d,this.pov.up);i.cross(m,[0,0,1])[0]>=0&&(this.pov.target=l,this.pov.up=m),this.previousPoint=t,this.onMotion()}end(t,e){this.isStarted=!1,e&&(this.inertia.track(t),this.inertia.start())}orientation(t,e,i){const o=c.degreesToRadians(window.orientation)||0,n=c.degreesToRadians(t),r=c.degreesToRadians(-e),a=c.degreesToRadians(-i),h=s.rotationX(c.degreesToRadians(90));s.rotateZ(h,this.initOrientation,h),s.rotateZ(h,n,h),s.rotateX(h,r,h),s.rotateY(h,a,h),s.rotateZ(h,-o,h),this.orientationMatrix=h,this.onMotion()}}class E{constructor(t,i,o,n){this.container=t,this.canvas=i,this.loader=o,this.images=[],this.hotspotsList=[[]];const r=new M([0,0,1],[0,0,0],[0,1,0]),a=s.rotationX(c.degreesToRadians(15));s.transformDirection(a,r.target,r.target),s.transformDirection(a,r.up,r.up),this.interaction=new x(r,60,(()=>{this.animationFrameId=requestAnimationFrame(this.render),this.onInteraction({pov:this.interaction.pov.clone(),fov:this.interaction.fov})})),this.onInteraction=n,this.gl=this.canvas.context,this.programInfo=e.createProgramInfo(this.gl,["attribute vec4 position;uniform mat4 u_matrix;varying vec3 direction;void main(){direction=(u_matrix*position).xyz;gl_Position=position*vec4(-1,1,1,1);}\n","precision mediump float;uniform float u_mix;uniform samplerCube u_texture;uniform samplerCube u_texture_back;varying vec3 direction;void main(){vec4 backColor=textureCube(u_texture_back,direction);vec4 color=textureCube(u_texture,direction);gl_FragColor=mix(backColor,color,u_mix);}\n"]),this.quad=e.primitives.createXYQuadBufferInfo(this.gl),this.uniforms={u_matrix:s.identity(),u_mix:0,u_texture_back:e.createTexture(this.gl,{target:this.gl.TEXTURE_CUBE_MAP,minMag:this.gl.LINEAR,width:1,height:1}),u_texture:e.createTexture(this.gl,{target:this.gl.TEXTURE_CUBE_MAP,minMag:this.gl.LINEAR,width:1,height:1})},this.render=this.render.bind(this)}destroy(){this.interaction.destroy(),this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}show(){this.canvas.show(),this.container.classList.add("ls-viewer-container-vrcube")}hide(){this.canvas.hide(),this.container.classList.remove("ls-viewer-container-vrcube")}get pov(){return this.interaction.pov}set pov(t){this.interaction.pov.eye.every(((e,i)=>e===t.eye[i]))&&this.interaction.pov.target.every(((e,i)=>e===t.target[i]))&&this.interaction.pov.up.every(((e,i)=>e===t.up[i]))||(this.interaction.pov=t.clone(),this.animationFrameId=requestAnimationFrame(this.render))}get fov(){return c.radiansToDegrees(this.interaction.fov)}set fov(t){this.interaction.fov!==t&&(this.interaction.fov=c.degreesToRadians(t),this.animationFrameId=requestAnimationFrame(this.render))}get hotspots(){const t=[];this.hotspotsList.flat();const e=this.canvas.element.clientWidth,o=this.canvas.element.clientHeight,n=s.inverse(this.modelViewProjectionMatrix);return this.hotspotsList.forEach(((r,a)=>{r.forEach((r=>{const h=r.position2D.x/this.images[0].width,c=r.position2D.y/this.images[0].height;let d=0,l=0,m=0;switch(a){case 0:if(this.pov.target[2]<0)return;d=2*h-1,l=-1*(2*c-1),m=1;break;case 1:if(this.pov.target[0]<0)return;d=1,l=-1*(2*c-1),m=1-2*h;break;case 2:if(this.pov.target[2]>0)return;d=1-2*h,l=-1*(2*c-1),m=-1;break;case 3:if(this.pov.target[0]>0)return;d=-1,l=-1*(2*c-1),m=2*h-1;break;case 4:if(this.pov.target[1]<0)return;d=2*h-1,l=1,m=2*c-1;break;case 5:if(this.pov.target[1]>0)return;d=2*h-1,l=-1,m=-1*(2*c-1)}const u=i.normalize([d,l,m]),v=s.transformPoint(n,u),g={x:e-.5*e*(v[0]+1),y:o-.5*o*(v[1]+1)};t.push(Object.assign(Object.assign({},r),{position2D:g}))}))})),t}async load(t,i,s,o){let n=Promise.resolve();const r=JSON.stringify(t);r===this.snapshotHash?n=n.then((()=>(this.animationFrameId=requestAnimationFrame(this.render),Promise.resolve()))):(this.images=[],this.animationFrameId=requestAnimationFrame(this.render),n=n.then((()=>this.loader.loadVRCubeSnapshot(t).then((t=>{this.images=t,e.createTexture(this.gl,{target:this.gl.TEXTURE_CUBE_MAP,minMag:this.gl.LINEAR,auto:!1,cubeFaceOrder:[this.gl.TEXTURE_CUBE_MAP_POSITIVE_Z,this.gl.TEXTURE_CUBE_MAP_POSITIVE_X,this.gl.TEXTURE_CUBE_MAP_NEGATIVE_Z,this.gl.TEXTURE_CUBE_MAP_NEGATIVE_X,this.gl.TEXTURE_CUBE_MAP_POSITIVE_Y,this.gl.TEXTURE_CUBE_MAP_NEGATIVE_Y],src:t},((t,e)=>{t||(s&&this.interaction.reset(),this.uniforms.u_mix=o?0:1,this.uniforms.u_texture_back=this.uniforms.u_texture,this.uniforms.u_texture=e,this.animationFrameId=requestAnimationFrame(this.render))}))})))));const a=JSON.stringify(i);return!i.length||r===this.snapshotHash&&a===this.tagsHash||(n=n.then((()=>this.loader.loadVRCubeHotspots(t,i).then((t=>{this.hotspotsList=t}))))),this.snapshotHash=r,this.tagsHash=a,n.then((()=>Promise.resolve(this.hotspots)))}snapshot(t,e){return this.canvas.element.toDataURL(t,e)}get modelViewProjectionMatrix(){const t=this.canvas.element.clientWidth,e=this.canvas.element.clientHeight,i=t>e?t/e:e/t,o=r.getStandardAspectRatio(t,e),n=this.interaction.fov*(o/i),a=t>e?c.perspectiveWithFovY(n,t/e,.5,100):c.perspectiveWithFovX(n,t/e,.5,100),h=s.inverse(a),d=this.interaction.orientedPov,l=s.lookAt(d.eye,d.target,d.up);return s.multiply(l,h)}render(){this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height),this.uniforms.u_matrix=this.modelViewProjectionMatrix,this.gl.useProgram(this.programInfo.program),e.setBuffersAndAttributes(this.gl,this.programInfo,this.quad),e.setUniforms(this.programInfo,this.uniforms),e.drawBufferInfo(this.gl,this.quad),this.uniforms.u_mix<1&&(this.uniforms.u_mix=Math.min(this.uniforms.u_mix+.05,1),this.animationFrameId=requestAnimationFrame(this.render))}onMouseDown(t){this.container.classList.add("ls-viewer-container-vrcube-grabbing"),this.interaction.start(b.pointFromMouseEvent(t),{width:this.gl.canvas.width,height:this.gl.canvas.height})}onMouseMove(t){this.interaction.isStarted&&(this.interaction.motion(b.pointFromMouseEvent(t)),t.preventDefault())}onMouseUp(t){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrcube-grabbing"),this.interaction.end(b.pointFromMouseEvent(t),!0))}onMouseEnter(t){this.interaction.isStarted&&0===t.buttons&&(this.container.classList.remove("ls-viewer-container-vrcube-grabbing"),this.interaction.end(b.pointFromMouseEvent(t),!1))}onTouchStart(t){this.container.classList.add("ls-viewer-container-vrcube-grabbing"),this.interaction.start(b.pointFromTouchEvent(t),{width:this.gl.canvas.width,height:this.gl.canvas.height})}onTouchMove(t){this.interaction.isStarted&&(this.interaction.motion(b.pointFromTouchEvent(t)),t.preventDefault())}onTouchEnd(t){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrcube-grabbing"),this.interaction.end(b.pointFromTouchEvent(t),!0))}onDeviceOrientation(t){this.interaction.orientation(t.alpha,t.beta,t.gamma)}}class L{constructor(t,e,i,s,o){this.isStarted=!1,this.position=t,this.frames=e,this.rows=i,this.loop=s,this.onMotion=o,this.inertia=new P(this.motion.bind(this)),this.initPosition=this.position,this.startPosition={x:0,y:0},this.startPoint=new w(0,0),this.startSize={width:0,height:0},this.lastPoints=[],this.lastPointsNumber=20}destroy(){this.inertia.destroy()}reset(){this.position=this.initPosition}get positionIndex(){return this.frames*this.position.y+this.position.x}set positionIndex(t){if(this.positionIndex===t)return;const e=this.loop?c.mod(t,this.frames*this.rows):Math.max(0,Math.min(t,this.frames*this.rows));this.position.x=c.mod(e,this.frames),this.position.y=Math.floor(e/this.frames)}start(t,e){this.isStarted=!0,this.startPosition=Object.assign({},this.position),this.startPoint=t,this.startSize=e,this.lastPoints=[],this.inertia.stop()}motion(t){this.isStarted&&this.inertia.track(t),this.lastPoints.push({x:t.x,y:t.y}),this.lastPoints.splice(0,this.lastPoints.length-this.lastPointsNumber);const e=o.linear(this.lastPoints.map((t=>[t.x,t.y])));if(Math.abs(e.equation[0])<1){const e=c.accelerate(t.x-this.startPoint.x,1.3)/this.startSize.width*(this.frames/4);let i=this.startPosition.x-Math.round(e);i=this.loop?c.mod(i,this.frames):Math.max(0,Math.min(i,this.frames-1)),i!==this.position.x&&(this.position.x=i,this.onMotion());const s=Math.min(...this.lastPoints.map((t=>t.x)));Math.max(...this.lastPoints.map((t=>t.x)))-s>25&&(this.startPoint.y=t.y,this.startPosition.y=this.position.y)}else{const e=c.accelerate(t.y-this.startPoint.y,1.7)/this.startSize.height*(this.rows/4);let i=this.startPosition.y+Math.round(e);i=Math.max(0,Math.min(i,this.rows-1)),i!==this.position.y&&(this.position.y=i,this.onMotion());const s=Math.min(...this.lastPoints.map((t=>t.y)));Math.max(...this.lastPoints.map((t=>t.y)))-s>25&&(this.startPoint.x=t.x,this.startPosition.x=this.position.x)}}end(t,e){this.isStarted=!1,e&&(this.inertia.track(t),this.inertia.start())}}class I{constructor(t,e,i,s){this.container=t,this.canvas=e,this.loader=i,this.images=[],this.frames=24,this.hotspotsList=[[]],this.interaction=new L({x:0,y:0},1,1,!1,(()=>{this.canvas.draw(this.image,!0,.5),this.onInteraction({position:this.interaction.positionIndex})})),this.onInteraction=s}destroy(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}show(){this.canvas.show(!1),this.container.classList.add("ls-viewer-container-vrobject")}hide(){this.canvas.hide(!1),this.container.classList.remove("ls-viewer-container-vrobject")}async goto(t){return new Promise((e=>{let i=this.interaction.positionIndex;const s=()=>{if(this.interaction.positionIndex===t)e();else{let e=i>t?-1:1;this.interaction.loop&&this.interaction.frames-i+t<Math.abs(t-i)&&(e*=-1),i+=.5*e,this.position=Math.floor(i),this.animationFrameId=requestAnimationFrame(s)}};this.animationFrameId=requestAnimationFrame(s)}))}get position(){return this.interaction.positionIndex}set position(t){this.interaction.positionIndex=t,this.canvas.draw(this.image,!0,.5)}get image(){return this.images[this.interaction.positionIndex]}get hotspots(){return this.hotspotsList[this.interaction.positionIndex]||[]}async load(t,e,i,s){let o=Promise.resolve();i&&this.interaction.reset();const n=JSON.stringify(t);n===this.snapshotHash&&this.image?o=o.then((()=>this.canvas.draw(this.image,s,.05))):(this.images=[],o=o.then((()=>this.loader.loadVRObjectSnapshot(t,this.interaction.positionIndex).then((e=>{const o=e.length;return this.images=new Array(o),this.interaction.frames=t.view.frames||this.frames,this.interaction.rows=o/this.interaction.frames,this.interaction.loop=!!t.view.loop,i&&this.interaction.reset(),e.forEach(((t,e)=>{t.then((t=>{this.images[e]=t,t===this.image&&this.canvas.draw(this.image,s,.05)})).catch((()=>{}))})),e[this.interaction.positionIndex].then((()=>Promise.resolve()))})))));const r=JSON.stringify(e);return!e.length||n===this.snapshotHash&&r===this.tagsHash||(o=o.then((()=>this.loader.loadVRObjectHotspots(t,e).then((t=>{this.hotspotsList=t}))))),this.snapshotHash=n,this.tagsHash=r,o.then((()=>Promise.resolve(this.hotspots)))}snapshot(t,e){return this.canvas.element.toDataURL(t,e)}onMouseDown(t){this.container.classList.add("ls-viewer-container-vrobject-grabbing"),this.interaction.start(b.pointFromMouseEvent(t),{width:this.canvas.element.width,height:this.canvas.element.height})}onMouseMove(t){this.interaction.isStarted&&(this.interaction.motion(b.pointFromMouseEvent(t)),t.preventDefault())}onMouseUp(t){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrobject-grabbing"),this.interaction.end(b.pointFromMouseEvent(t),!0))}onMouseEnter(t){this.interaction.isStarted&&0===t.buttons&&(this.container.classList.remove("ls-viewer-container-vrobject-grabbing"),this.interaction.end(b.pointFromMouseEvent(t),!1))}onTouchStart(t){this.container.classList.add("ls-viewer-container-vrobject-grabbing"),this.interaction.start(b.pointFromTouchEvent(t),{width:this.canvas.element.width,height:this.canvas.element.height})}onTouchMove(t){this.interaction.isStarted&&(this.interaction.motion(b.pointFromTouchEvent(t)),t.preventDefault())}onTouchEnd(t){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrobject-grabbing"),this.interaction.end(b.pointFromTouchEvent(t),!0))}onDeviceOrientation(t){}}var S;!function(t,e){void 0===e&&(e={});var i=e.insertAt;if(t&&"undefined"!=typeof document){var s=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===i&&s.firstChild?s.insertBefore(o,s.firstChild):s.appendChild(o),o.styleSheet?o.styleSheet.cssText=t:o.appendChild(document.createTextNode(t))}}(".ls-viewer-container{display:block;height:100%;overflow:hidden;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:100%}.ls-viewer-container-image,.ls-viewer-container-video{cursor:default;pointer-events:none}.ls-viewer-container-vrcube{cursor:pointer;cursor:-webkit-grab;cursor:grab}.ls-viewer-container-vrcube-grabbing{cursor:move;cursor:-webkit-grabbing;cursor:grabbing}.ls-viewer-container-vrobject{cursor:move;cursor:-webkit-grab;cursor:grab}.ls-viewer-container-vrobject-grabbing{cursor:move;cursor:-webkit-grabbing;cursor:grabbing}.ls-viewer-container-loading{cursor:progress}.ls-viewer-canvas{opacity:0;position:absolute;-webkit-transition:opacity .5s;transition:opacity .5s}.ls-viewer-video{position:absolute}");class A{constructor(e,i){this.checkResize=this.checkResize.bind(this),this.onDeviceOrientation=this.onDeviceOrientation.bind(this),this.onResize=this.onResize.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onMouseEnter=this.onMouseEnter.bind(this),this.onTouchStart=this.onTouchStart.bind(this),this.onTouchMove=this.onTouchMove.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this),this.onLoadStart=this.onLoadStart.bind(this),this.onLoadProgress=this.onLoadProgress.bind(this),this.onLoadEnd=this.onLoadEnd.bind(this),this.onLoadError=this.onLoadError.bind(this),this.onHotspotsChange=this.onHotspotsChange.bind(this),this.onVrcubeInteraction=this.onVrcubeInteraction.bind(this),this.onVrobjectInteraction=this.onVrobjectInteraction.bind(this),this.options=Object.assign({server:"localhost",api:"v1",fit:"cover",image:{},video:{},vrcube:{},vrobject:{},events:{}},i),this.options.events=Object.assign({onLoadStart:()=>{},onLoadProgress:()=>{},onLoadEnd:()=>{},onLoadError:()=>{},onInteraction:()=>{},onVrcubeInteraction:()=>{},onVrobjectInteraction:()=>{},onHotspotsChange:()=>{}},i.events),this.options.events.onLoadError=t(this.options.events.onLoadError,10),this.container=e,this.container.classList.add("ls-viewer-container"),this.containerWidth=0,this.containerHeight=0,this.canvas2D=new a(this.options.fit),this.container.appendChild(this.canvas2D.element),this.canvas3D=new h,this.container.appendChild(this.canvas3D.element),this.video=new v,this.container.appendChild(this.video.element),this.loader=new u(this.options.server,this.options.api,this),this.resolution=new n(0,0),this.parameters={width:0,height:0,antialiasing:!1,superSampling:2},this.encoder={format:"jpeg",quality:80},this.widgetImage=new g(e,this.canvas2D,this.loader),this.widgetVideo=new p(e,this.video,this.loader),this.widgetVRCube=new E(e,this.canvas3D,this.loader,this.onVrcubeInteraction),this.widgetVRObject=new I(e,this.canvas2D,this.loader,this.onVrobjectInteraction),this.widget=this.widgetImage,this.isDestroyed=!1,this.container.addEventListener("mousedown",this.onMouseDown),this.container.addEventListener("mouseenter",this.onMouseEnter),this.container.addEventListener("touchstart",this.onTouchStart),document.addEventListener("mousemove",this.onMouseMove,{passive:!1}),document.addEventListener("mouseup",this.onMouseUp),document.addEventListener("touchmove",this.onTouchMove,{passive:!1}),document.addEventListener("touchend",this.onTouchEnd),this.loadWidget=t(this.loadWidget,10),this.onResize=t(this.onResize,250),requestAnimationFrame(this.checkResize)}destroy(){this.canvas2D.destroy(),this.container.removeEventListener("mousedown",this.onMouseDown),this.container.removeEventListener("mouseenter",this.onMouseEnter),this.container.removeEventListener("touchstart",this.onTouchStart),document.removeEventListener("mousemove",this.onMouseMove),document.removeEventListener("mouseup",this.onMouseUp),document.removeEventListener("touchmove",this.onTouchMove),document.removeEventListener("touchend",this.onTouchEnd),this.isDestroyed=!0}async load(t,e){let i=Promise.resolve();return(null==e?void 0:e.animation)&&(i=i.then((()=>this.loadAnimation(e.animation)))),this.view&&void 0!==(null==e?void 0:e.fromPosition)&&this.viewWidget instanceof I&&(this.view.mode,i=i.then((()=>this.viewWidget.goto(e.fromPosition)))),(null==e?void 0:e.animation)&&(i=i.then((()=>this.widgetVideo.play()))),i=i.then((()=>(this.scene=Array.isArray(t)?[...t]:[t],this.loadWidget(!1,!(e&&e.animation))))),i.catch((t=>{this.onLoadError(t)})),i}async setEncoder(t){this.encoder=Object.assign({},t);let e=Promise.resolve();return e=e.then((()=>this.loadWidget(!1,!0))),e.catch((t=>{this.onLoadError(t)})),e}setParameters(t){this.parameters=Object.assign({},t),this.parameters.width=this.resolution.width,this.parameters.height=this.resolution.height;let e=Promise.resolve();return e=e.then((()=>this.loadWidget(!1,!0))),e.catch((t=>{this.onLoadError(t)})),e}setTags(t){this.tags=t,this.loadWidget(!1,!1)}async setView(t,e){let i=Promise.resolve();return(null==e?void 0:e.animation)&&(i=i.then((()=>this.loadAnimation(e.animation)))),this.view&&void 0!==(null==e?void 0:e.fromPosition)&&this.viewWidget instanceof I&&(i=i.then((()=>this.viewWidget.goto(e.fromPosition)))),(null==e?void 0:e.animation)&&(i=i.then((()=>this.widgetVideo.play()))),i=i.then((()=>{let i=!0;return this.view=Object.assign({},t),this.view&&this.viewWidget instanceof I&&void 0!==(null==e?void 0:e.toPosition)&&(i=!1,this.viewWidget.position=e.toPosition),this.loadWidget(i,!(e&&e.animation))})),i.catch((t=>{this.onLoadError(t)})),i}setVrcube(t){Object.assign(this.widgetVRCube,t)}setVrobject(t){Object.assign(this.widgetVRObject,t)}async loadAnimation(t){var e;const i={scene:this.scene,view:{animation:t.name,camera:t.camera,duration:t.duration,loop:t.loop,reverse:t.reverse},parameters:this.parameters,encoder:{format:"mp4"}};return(null===(e=i.view)||void 0===e?void 0:e.background)||(i.view.background="product"),this.widgetVideo.load(i).then((()=>Promise.resolve()))}async playAnimation(t){return this.loadAnimation(t).then((()=>this.widgetVideo.play())).catch((t=>{this.onLoadError(t)}))}stopAnimation(){this.widgetVideo.hide()}snapshot(t,e){return this.viewWidget.snapshot(t,e)}async loadWidget(t,e){if(!this.scene||!this.view)return Promise.resolve();if(!this.parameters.width||!this.parameters.height)return Promise.resolve();const i=this.viewWidget;if(!i)return Promise.reject(new Error("Unknown view mode"));const s={scene:this.scene,view:this.view,parameters:this.parameters,encoder:this.encoder};return s.view.background||(s.view.background="product"),i.load(s,this.tags||[],t,e).then((t=>{this.widget.hide(),this.widget=i,this.widget.show(),this.widgetVideo.hide(),this.onHotspotsChange(t)}))}get viewWidget(){var t;switch(null===(t=this.view)||void 0===t?void 0:t.mode){case"image":default:return this.widgetImage;case"video":return this.widgetVideo;case"vrcube":return this.widgetVRCube;case"vrobject":return this.widgetVRObject}}checkResize(){if(this.isDestroyed)return;const t=this.container.clientWidth,e=this.container.clientHeight;t===this.containerWidth&&e===this.containerHeight||(this.containerWidth=t,this.containerHeight=e,this.onResize()),this.isDestroyed||requestAnimationFrame(this.checkResize)}onMouseDown(t){this.widget.onMouseDown(t)}onMouseEnter(t){this.widget.onMouseEnter(t)}onMouseMove(t){this.widget.onMouseMove(t)}onMouseUp(t){this.widget.onMouseUp(t)}onTouchStart(t){this.widget.onTouchStart(t)}onTouchMove(t){this.widget.onTouchMove(t)}onTouchEnd(t){this.widget.onTouchEnd(t)}onDeviceOrientation(t){this.widget.onDeviceOrientation(t)}onResize(){const t=this.container.clientWidth,e=this.container.clientHeight;this.resolution=r.getStandardResolution(t*window.devicePixelRatio,e*window.devicePixelRatio),this.parameters.width=this.resolution.width,this.parameters.height=this.resolution.height,this.canvas2D.resize(t,e,window.devicePixelRatio),this.canvas3D.resize(t,e,window.devicePixelRatio),this.video.resize(t,e,this.resolution,this.options.fit),this.loadWidget(!1,!1).catch((t=>{this.onLoadError(t)}))}onVrcubeInteraction(...t){this.options.events.onHotspotsChange(this.widgetVRCube.hotspots),this.options.events.onInteraction(...t),this.options.events.onVrcubeInteraction(...t)}onVrobjectInteraction(...t){this.options.events.onHotspotsChange(this.widgetVRObject.hotspots),this.options.events.onInteraction(...t),this.options.events.onVrobjectInteraction(...t)}onHotspotsChange(...t){this.options.events.onHotspotsChange(...t)}onLoadStart(...t){this.container.classList.add("ls-viewer-container-loading"),this.options.events.onLoadStart(...t)}onLoadProgress(...t){this.options.events.onLoadProgress(...t)}onLoadEnd(...t){this.container.classList.remove("ls-viewer-container-loading"),this.options.events.onLoadEnd(...t)}onLoadError(...t){this.container.classList.remove("ls-viewer-container-loading"),this.options.events.onLoadError(...t)}}!function(t){var e,i,s;(e=t.SunShadowQualityMode||(t.SunShadowQualityMode={})).VeryLow="veryLow",e.Low="low",e.Medium="medium",e.Fine="fine",e.Ultra="ultra",(i=t.SunShadowSmoothnessMode||(t.SunShadowSmoothnessMode={})).None="none",i.Weak="weak",i.Normal="normal",i.Fine="fine",i.UltraFine="ultraFine",i.Max="max",(s=t.SunUseCaseMode||(t.SunUseCaseMode={})).Manual="manual",s.ExtractedFromEnv="extractedFromEnv"}(S||(S={}));export{A as Viewer,S as WRAPIv2,g as WidgetImage,E as WidgetVRCube,I as WidgetVRObject,p as WidgetVideo};
//# sourceMappingURL=index.es.js.map

@@ -16,3 +16,3 @@ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("debounce-promise"),e=require("twgl.js"),i=require("regression");function s(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}function o(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return t[i]}})}})),e.default=t,Object.freeze(e)}var n=s(t),r=o(e),a=s(i);class h{constructor(t,e){this.width=t,this.height=e}get aspect(){return this.width/this.height}}class c{constructor(t,e,i,s){this.top=t,this.left=e,this.width=i,this.height=s}static fit(t,e,i){const s=t.aspect,o=e.aspect;let n=0,r=0;switch(i){case"contain":n=o<s?e.width:e.height*s,r=o<s?e.width/s:e.height;break;case"cover":default:n=o<s?e.height*s:e.width,r=o<s?e.height:e.width/s;break;case"fill":n=e.width,r=e.height}const a=(e.height-r)/2,h=(e.width-n)/2;return new c(a,h,n,r)}static getStandardAspectRatio(t,e){if(0===t||0===e)return 0;const i=t/e;if(t<e){return Math.abs(3/4-i)<Math.abs(9/16-i)?3/4:9/16}return Math.abs(4/3-i)<Math.abs(16/9-i)?4/3:16/9}static getStandardResolution(t,e){if(0===t||0===e)return new h(0,0);const i=c.getStandardAspectRatio(t,e);if(t<e){const s=c.getStandardQuality(Math.max(e*i,t));return new h(Math.round(s),Math.round(s/i))}const s=c.getStandardQuality(Math.max(t/i,e));return new h(Math.round(s*i),Math.round(s))}static getStandardQuality(t){return t<=240?240:t<=360?360:t<=480?480:t<=720?720:1080}}class d{constructor(t){this.element=document.createElement("canvas"),this.element.classList.add("ls-viewer-canvas"),this.element.style.opacity="0",this.context=this.element.getContext("2d"),this.backCanvas=document.createElement("canvas"),this.backContext=this.backCanvas.getContext("2d"),this.fit=t}destroy(){this.requestAnimationId&&(cancelAnimationFrame(this.requestAnimationId),this.requestAnimationId=void 0)}show(t){t?this.element.style.display="block":this.element.style.opacity="1"}hide(t){t?this.element.style.display="none":this.element.style.opacity="0"}resize(t,e,i){this.element.width=t*i,this.element.height=e*i,this.element.style.width=`${t}px`,this.element.style.height=`${e}px`,this.backCanvas.width=t*i,this.backCanvas.height=e*i}draw(t,e,i){if(!t)return;this.requestAnimationId&&(cancelAnimationFrame(this.requestAnimationId),this.requestAnimationId=void 0);const s=c.fit(new h(t.width,t.height),new h(this.element.width,this.element.height),this.fit);e?(this.backContext.drawImage(this.element,0,0),this.context.globalAlpha=0,this.fadeLoop(t,i||0)):(this.context.globalAlpha=1,this.context.drawImage(t,s.left,s.top,s.width,s.height)),this.image=t}fadeLoop(t,e){if(this.context.globalAlpha>=1)return cancelAnimationFrame(this.requestAnimationId),void(this.requestAnimationId=void 0);const i=Math.min(this.context.globalAlpha+e,1),s=c.fit(new h(t.width,t.height),new h(this.element.width,this.element.height),this.fit);this.context.clearRect(0,0,this.element.width,this.element.height),this.context.globalAlpha=1,this.context.drawImage(this.backCanvas,0,0),this.context.globalAlpha=i,this.context.drawImage(t,s.left,s.top,s.width,s.height),this.requestAnimationId=requestAnimationFrame((()=>{this.fadeLoop(t,e)}))}}class l{constructor(){this.element=document.createElement("canvas"),this.element.classList.add("ls-viewer-canvas"),this.element.style.opacity="0",this.context=r.getContext(this.element,{preserveDrawingBuffer:!0}),r.setDefaultTextureColor([1,1,1,1])}show(){this.element.style.opacity="1"}hide(){this.element.style.opacity="0"}resize(t,e,i){this.element.width=t*i,this.element.height=e*i,this.element.style.width=`${t}px`,this.element.style.height=`${e}px`}}class m{static accelerate(t,e){const i=e||1.5;return Math.abs(t)**i*(t>0?1:-1)}static degreesToRadians(t){return t*(Math.PI/180)}static radiansToDegrees(t){return t*(180/Math.PI)}static mod(t,e){return t-e*Math.floor(t/e)}static perspectiveWithFovX(t,e,i,s,o){const n=Math.tan(t/2),r=n/e;return this.perspectiveWithLeft(-n,n,-r,r,i,s,o)}static perspectiveWithFovY(t,e,i,s,o){const n=i*Math.tan(t/2),r=n*e;return this.perspectiveWithLeft(-r,r,-n,n,i,s,o)}static perspectiveWithLeft(t,e,i,s,o,n,r){const a=e+t,h=e-t,c=s+i,d=s-i,l=n-o;return(r=r||new Float32Array(16))[0]=2*o/h,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=2*o/d,r[6]=0,r[7]=0,r[8]=a/h,r[9]=c/d,r[10]=-n/l,r[11]=-1,r[12]=0,r[13]=0,r[14]=-n*o/l,r[15]=0,r}}class u{constructor(){}async animation(t){return t.scene}async image(t){return t.scene}async video(t){return t.scene}async vrCube(t){return t.scene}async vrObject(t){return t.scene}}class v{constructor(t){this.server=t}static buildQuery(t){return Object.entries(t).filter((([t,e])=>null!=e)).map((([t,e])=>`${t}=${e}`)).join("&")}static sceneParameters(t){var e,i;const s=t.scene,o=s.length>1?s.find((t=>t.accessory)):null,n=s.length>1?s.find((t=>t.decor)):null,r=s.find((t=>t!==o&&t!==n));return{databaseId:r.database,configuration:null==r?void 0:r.configuration,animations:null===(e=null==r?void 0:r.animations)||void 0===e?void 0:e.join("/"),accessoryDatabaseId:null==o?void 0:o.database,decorDatabaseId:null==n?void 0:n.database,decorDeltaAltitude:null===(i=null==n?void 0:n.translation)||void 0===i?void 0:i.y}}static renderParameters(t){const{parameters:e,view:i}=t;return{background:i.background,width:e.width,height:e.height,softwareAntialiasing:e.antialiasing,superSampling:e.superSampling}}static encoderParameters(t){const{encoder:e}=t;return{imageFormat:e.format,imageQuality:e.quality}}static async fetch(t){return fetch(t).then((t=>t.text())).then((t=>{const e=t.replace(/&amp;/g,"&").match(this.xmlRegex);return e?e.map((t=>t.replace(this.xmlRegex,"$1"))):Promise.reject()}))}async animation(t){const e=Object.assign(Object.assign(Object.assign(Object.assign({},v.sceneParameters(t)),{animation:t.view.animation,bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1],frames:t.view.frames,loop:!!t.view.loop}),v.renderParameters(t)),v.encoderParameters(t)),i=v.buildQuery(e);return v.fetch(`${this.server}/ImagesFromAnimation?${i}`)}async image(t){const e=Object.assign(Object.assign(Object.assign(Object.assign({},v.sceneParameters(t)),{bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1]}),v.renderParameters(t)),v.encoderParameters(t)),i=v.buildQuery(e);return Promise.resolve(`${this.server}/ImageFromBookmark?${i}`)}async video(t){const e=Object.assign(Object.assign(Object.assign(Object.assign({},v.sceneParameters(t)),{animation:t.view.animation,bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1],duration:t.view.duration,frames:t.view.frames,loop:!!t.view.loop,reverse:!!t.view.reverse}),v.renderParameters(t)),v.encoderParameters(t)),i=v.buildQuery(e);return Promise.resolve(`${this.server}/ImagesFromAnimation?${i}`)}async vrCube(t){const e=Object.assign(Object.assign(Object.assign(Object.assign({},v.sceneParameters(t)),{bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1]}),v.renderParameters(t)),v.encoderParameters(t));e.width=Math.max(e.width,e.height),e.height=Math.max(e.width,e.height);const i=v.buildQuery(e);return v.fetch(`${this.server}/CubeFromBookmark?${i}`)}async vrObject(t){const e=Object.assign(Object.assign(Object.assign(Object.assign({},v.sceneParameters(t)),{bookmarkSet:t.view.camera}),v.renderParameters(t)),v.encoderParameters(t)),i=v.buildQuery(e);return v.fetch(`${this.server}/ImagesFromBookmarkSet?${i}`)}}v.xmlRegex=/directUrl="([^"]*)"/g;class g{constructor(t){this.server=t}static scene(t){return t.scene.map((t=>{const e=

***************************************************************************** */
function(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(s=Object.getOwnPropertySymbols(t);o<s.length;o++)e.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(t,s[o])&&(i[s[o]]=t[s[o]])}return i}(t,["accessory","decor"]);return e}))}static renderParameters(t){return Object.assign(Object.assign({},t.parameters),{superSampling:t.parameters.superSampling.toString()})}static encoder(t){switch(t.encoder.format){case"jpeg":return{jpeg:{quality:t.encoder.quality}};case"png":return{png:{compression:t.encoder.compression}};case"webp":return{webp:{quality:t.encoder.quality}}}return{jpeg:{quality:80}}}static async fetchFrame(t,e){return fetch(t,{method:"POST",body:JSON.stringify(e)}).then((t=>t.json())).then((t=>t.url))}static async fetchFrameArray(t,e){return fetch(t,{method:"POST",body:JSON.stringify(e)}).then((t=>t.json())).then((t=>t.map((t=>t.url))))}static async fetchHotspots(t,e){return fetch(t,{method:"POST",body:JSON.stringify(e)}).then((t=>t.json())).then((t=>t))}static async fetchHotspotsArray(t,e){return fetch(t,{method:"POST",body:JSON.stringify(e)}).then((t=>t.json())).then((t=>t))}async image(t){const e={scene:g.scene(t),mode:{image:{camera:t.view.camera}},renderParameters:g.renderParameters(t),encoder:g.encoder(t)};return g.fetchFrame(`${this.server}/Snapshot`,e)}async vrCube(t){const e={scene:g.scene(t),mode:{vrCube:{camera:t.view.camera}},renderParameters:g.renderParameters(t),encoder:g.encoder(t)};return e.renderParameters.width=Math.max(e.renderParameters.width,e.renderParameters.height),e.renderParameters.height=Math.max(e.renderParameters.width,e.renderParameters.height),g.fetchFrameArray(`${this.server}/Snapshot`,e)}async vrObject(t){let e;e=t.view.cameraGroup?{images:{cameraGroup:t.view.cameraGroup}}:t.view.frames?{vrObject:{camera:t.view.camera,frames:t.view.frames}}:{vrObject:{camera:t.view.camera,panFrames:t.view.panFrames||1,panFrom:t.view.panFrom||0,panTo:t.view.panTo||0,panLoop:t.view.panLoop||!1,tiltFrames:t.view.tiltFrames||1,tiltFrom:t.view.tiltFrom||0,tiltTo:t.view.tiltTo||0,tiltLoop:t.view.tiltLoop||!1}};const i={scene:g.scene(t),mode:e,renderParameters:g.renderParameters(t),encoder:g.encoder(t)};return g.fetchFrameArray(`${this.server}/Snapshot`,i)}async animation(t){const e={scene:g.scene(t),mode:{animation:{id:t.view.animation,camera:t.view.camera,fps:t.view.fps}},renderParameters:g.renderParameters(t),encoder:g.encoder(t)};return g.fetchFrameArray(`${this.server}/Snapshot`,e)}async imageHotspots(t,e){const i={scene:g.scene(t),mode:{image:{camera:t.view.camera}},renderParameters:g.renderParameters(t),tags:e};return await g.fetchHotspots(`${this.server}/Hotspot`,i)}async vrCubeHotspots(t,e){const i={scene:g.scene(t),mode:{vrCube:{camera:t.view.camera}},renderParameters:g.renderParameters(t),tags:e};return i.renderParameters.width=Math.max(i.renderParameters.width,i.renderParameters.height),i.renderParameters.height=Math.max(i.renderParameters.width,i.renderParameters.height),await g.fetchHotspotsArray(`${this.server}/Hotspot`,i)}async vrObjectHotspots(t,e){let i;i=t.view.cameraGroup?{images:{cameraGroup:t.view.cameraGroup}}:t.view.frames?{vrObject:{camera:t.view.camera,frames:t.view.frames}}:{vrObject:{camera:t.view.camera,panFrames:t.view.panFrames||1,panFrom:t.view.panFrom||0,panTo:t.view.panTo||0,panLoop:t.view.panLoop||!1,tiltFrames:t.view.tiltFrames||1,tiltFrom:t.view.tiltFrom||0,tiltTo:t.view.tiltTo||0,tiltLoop:t.view.tiltLoop||!1}};const s={scene:g.scene(t),mode:i,renderParameters:g.renderParameters(t),tags:e};return await g.fetchHotspotsArray(`${this.server}/Hotspot`,s)}}class p{constructor(t,e,i){switch(e){case"static":this.webrender=new u;break;case"v1":default:this.webrender=new v(t);break;case"v2":this.webrender=new g(t)}this.delegate=i,this.loadingId=0,this.loaded=0,this.total=0,this.onLoadStart=i&&i.onLoadStart?i.onLoadStart:()=>{},this.onLoadProgress=i&&i.onLoadProgress?i.onLoadProgress:()=>{},this.onLoadEnd=i&&i.onLoadEnd?i.onLoadEnd:()=>{}}get progress(){return this.total?this.loaded/this.total:0}async loadImageSnapshot(t){this.loadingId+=1,this.loaded=0,this.total=1,this.onLoadStart(this.progress);const{loadingId:e}=this;return this.webrender.image(t).then((t=>this.loadImage(t,e))).then((t=>(this.onLoadEnd(this.progress),t)))}async loadVideoSnapshot(t,e){this.loadingId+=1,this.loaded=0,this.total=1,this.onLoadStart(this.progress);const{loadingId:i}=this;return this.webrender.video(e).then((s=>this.loadVideo(t,s,!!e.view.loop,i))).then((()=>(this.onLoadEnd(this.progress),t)))}async loadVRCubeSnapshot(t){this.loadingId+=1,this.loaded=0,this.total=0,this.onLoadStart(this.progress);const{loadingId:e}=this;return this.webrender.vrCube(t).then((t=>{this.total=t.length;const i=t.map((t=>this.loadImage(t,e)));return Promise.all(i)})).then((t=>(this.onLoadEnd(this.progress),t)))}async loadVRObjectSnapshot(t,e){var i;this.loadingId+=1,this.loaded=0,this.total=0,this.onLoadStart(this.progress);const{loadingId:s}=this;return t.view.animation?"mp4"===(null===(i=t.encoder)||void 0===i?void 0:i.format)?this.webrender.video(t).then((e=>this.loadVideoFrames(e,t.view.frames,30,s))):this.webrender.animation(t).then((i=>this.loadImageFrames(i,t.view.loop,e,s))):this.webrender.vrObject(t).then((i=>this.loadImageFrames(i,t.view.loop,e,s)))}async loadImage(t,e){const i=new Image;i.crossOrigin="file:"!==location.protocol||p.isValidHttpUrl(t)?"anonymous":null;const s=new Promise(((s,o)=>{i.addEventListener("load",(()=>{e===this.loadingId&&(this.loaded+=1,this.onLoadProgress(this.progress),s(i))}),{once:!0}),i.addEventListener("error",(i=>{e===this.loadingId&&o(`${i.type} : ${t}`)}),{once:!0})}));return i.src=t,s}loadImageFrames(t,e,i,s){this.total=t.length;const o=new Array(t.length),n=i||0;for(let i=0,r=t.length;i<r;i+=1){const a=Math.ceil(i/2)*(i%2==0?1:-1),h=e?m.mod(n+a,r):i;o[h]=this.loadImage(t[h],s)}return Promise.all(o).then((()=>this.onLoadEnd(this.progress))).catch((()=>{})),o}async loadVideo(t,e,i,s){t.loop=i;const o=new Promise(((i,o)=>{t.addEventListener("canplaythrough",(()=>{s===this.loadingId&&(this.loaded+=1,this.onLoadProgress(this.progress),i())}),{once:!0}),t.addEventListener("error",(t=>{s===this.loadingId&&o(`${t.type} : ${e}`)}),{once:!0})}));return t.src=e,t.load(),o}async loadVideoFrame(t,e,i,s,o){let n=0;return new Promise(((r,a)=>{const h=()=>{if(o!==this.loadingId)return;if(n!==s)return void(n+=1);t.removeEventListener("seeked",h);const a=document.createElement("canvas");a.width=t.videoWidth,a.height=t.videoHeight;a.getContext("2d").drawImage(t,0,0);const c=new Image;c.src=a.toDataURL(),r(c),this.loaded+=1,this.onLoadProgress(this.progress),s!==i-1&&(t.currentTime+=1/e)};t.addEventListener("seeked",h),t.addEventListener("error",(t=>{o===this.loadingId&&a(t)}),{once:!0})}))}loadVideoFrames(t,e,i,s){this.total=e;const o=new Array(e),n=document.createElement("video");for(let t=0,r=e;t<r;t+=1)o[t]=this.loadVideoFrame(n,i,e,t,s);return n.addEventListener("canplaythrough",(()=>{s===this.loadingId&&(n.currentTime=1/i/2)}),{once:!0}),n.src=t,n.load(),Promise.all(o).then((()=>this.onLoadEnd(this.progress))).catch((()=>{})),o}async loadImageHotspots(t,e){return this.webrender instanceof g?await this.webrender.imageHotspots(t,e):Promise.reject(new Error("Hotspots only available with api V2"))}async loadVRCubeHotspots(t,e){return this.webrender instanceof g?await this.webrender.vrCubeHotspots(t,e):Promise.reject(new Error("Hotspots only available with api V2"))}async loadVRObjectHotspots(t,e){return this.webrender instanceof g?await this.webrender.vrObjectHotspots(t,e):Promise.reject(new Error("Hotspots only available with api V2"))}onLoadStart(t){this.delegate&&this.delegate.onLoadStart(t)}onLoadProgress(t){this.delegate&&this.delegate.onLoadProgress(t)}onLoadEnd(t){this.delegate&&this.delegate.onLoadEnd(t)}static isValidHttpUrl(t){let e;try{e=new URL(t)}catch(t){return!1}return"http:"===e.protocol||"https:"===e.protocol}}class w{constructor(){this.element=document.createElement("video"),this.element.classList.add("ls-viewer-video"),this.element.style.opacity="0",this.element.setAttribute("muted",""),this.element.setAttribute("playsinline",""),this.element.setAttribute("preload","auto")}show(){this.element.style.opacity="1"}hide(){this.element.style.opacity="0"}resize(t,e,i,s){const o=c.fit(i,new h(t,e),s);this.element.style.top=`${o.top}px`,this.element.style.left=`${o.left}px`,this.element.style.width=`${o.width}px`,this.element.style.height=`${o.height}px`,i.width===this.element.width&&i.height===this.element.height||(this.element.width=i.width,this.element.height=i.height)}}class b{constructor(t,e,i){this.container=t,this.canvas=e,this.loader=i,this.hotspots=[]}destroy(){}show(){this.canvas.show(!1),this.container.classList.add("ls-viewer-container-image")}hide(){this.canvas.hide(!1),this.container.classList.remove("ls-viewer-container-image")}async load(t,e,i,s){let o=Promise.resolve();const n=JSON.stringify(t);o=n===this.snapshotHash&&this.image?o.then((()=>this.canvas.draw(this.image,s,.05))):o.then((()=>this.loader.loadImageSnapshot(t).then((t=>{this.canvas.draw(t,s,.05),this.image=t}))));const r=JSON.stringify(e);return!e.length||n===this.snapshotHash&&r===this.tagsHash||(o=o.then((()=>this.loader.loadImageHotspots(t,e).then((t=>{this.hotspots=t}))))),this.snapshotHash=n,this.tagsHash=r,o.then((()=>Promise.resolve(this.hotspots)))}snapshot(t,e){return this.canvas.element.toDataURL(t,e)}onMouseDown(t){}onMouseMove(t){}onMouseUp(t){}onMouseEnter(t){}onTouchStart(t){}onTouchMove(t){}onTouchEnd(t){}onDeviceOrientation(t){}}class y{constructor(t,e,i){this.container=t,this.loader=i,this.video=e}destroy(){}show(){this.video.show(),this.container.classList.add("ls-viewer-container-video")}hide(){this.video.hide(),this.container.classList.remove("ls-viewer-container-video")}async load(t){const e=JSON.stringify(t);return e===this.hash?(this.video.element.load(),Promise.resolve([])):(this.hash=e,this.loader.loadVideoSnapshot(this.video.element,t).then((()=>Promise.resolve([]))))}snapshot(t,e){return"data:image/gif;base64,R0lGODlhAQABAIAAAP7//wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=="}async play(){return new Promise(((t,e)=>{this.video.element.addEventListener("ended",(()=>{t()}),{once:!0}),this.video.element.play().catch(e),this.show()}))}onMouseDown(t){}onMouseMove(t){}onMouseUp(t){}onMouseEnter(t){}onTouchStart(t){}onTouchMove(t){}onTouchEnd(t){}onDeviceOrientation(t){}}class f{constructor(t,e){this.x=t,this.y=e}clone(){return new f(this.x,this.y)}}class P{static pointFromMouseEvent(t){return new f(t.screenX,t.screenY)}static pointFromTouchEvent(t){const e=t.targetTouches[0]||t.changedTouches[0];return new f(e.screenX,e.screenY)}}class M{constructor(...t){3===t.length?(({0:this.u,1:this.v,2:this.o}=t),this.w=e.v3.cross(this.u,this.v)):4===t.length?({0:this.u,1:this.v,2:this.w,3:this.o}=t):(this.u=[1,0,0],this.v=[0,1,0],this.w=[0,0,1],this.o=[0,0,0])}get localToGlobalMatrix(){return[...[this.u[0],this.u[1],this.u[2],0],...[this.v[0],this.v[1],this.v[2],0],...[this.w[0],this.w[1],this.w[2],0],...[this.o[0],this.o[1],this.o[2],1]]}get globalToLocalMatrix(){return e.m4.inverse(this.localToGlobalMatrix)}}class x{constructor(t,e,i){this.x=t,this.y=e,this.time=i}}class E{constructor(t){this.points=[],this.onMotion=t,this.lastPoint=new f(0,0),this.velocity=new f(0,0),this.loop=this.loop.bind(this)}destroy(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}track(t){const e=Date.now();this.points=this.points.filter((t=>e-t.time<=100)),this.points.push(new x(t.x,t.y,e)),this.lastPoint=t}start(){if(0===this.points.length)return;const t=this.points[0],e=this.points[this.points.length-1],i=e.x-t.x,s=e.y-t.y,o=e.time-t.time;this.velocity=new f(0===o?0:i/(o/15),0===o?0:s/(o/15)),this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0),this.animationFrameId=requestAnimationFrame(this.loop)}stop(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0),this.points=[]}loop(){if(Math.abs(this.velocity.x)<1&&Math.abs(this.velocity.y)<1)return this.animationFrameId=void 0,void(this.points=[]);this.lastPoint.x+=this.velocity.x,this.lastPoint.y+=this.velocity.y,this.velocity.x*=.9,this.velocity.y*=.9,this.onMotion(this.lastPoint.clone()),this.animationFrameId=requestAnimationFrame(this.loop)}}class I{constructor(t,i,s){this.target=e.v3.copy(t),this.eye=e.v3.copy(i),this.up=e.v3.copy(s)}get viewVector(){return e.v3.subtract(this.target,this.eye)}get rightVector(){return e.v3.normalize(e.v3.cross(this.viewVector,this.up))}get viewMatrix(){return e.m4.inverse(e.m4.lookAt(this.eye,this.target,this.up))}clone(){return new I(e.v3.copy(this.target),e.v3.copy(this.eye),e.v3.copy(this.up))}}I.default=new I([0,0,0],[2,2,2],[0,1,0]);class L{constructor(t,i,s){this.isStarted=!1,this.pov=t,this.fov=m.degreesToRadians(i),this.orientationMatrix=e.m4.identity(),this.inertia=new E(this.motion.bind(this)),this.onMotion=s,this.initPov=this.pov,this.initFov=this.fov,this.initOrientation=m.degreesToRadians(window.orientation)||0,this.startPov=new I([0,0,1],[0,0,0],[0,1,0]),this.startSize={width:0,height:0},this.previousPoint=new f(0,0)}destroy(){this.inertia.destroy()}get orientedPov(){const t=e.v3.normalize(e.v3.cross(this.pov.up,this.pov.target)),i=new M(t,[0,1,0],this.pov.eye),s=e.m4.identity();e.m4.multiply(s,i.localToGlobalMatrix,s),e.m4.multiply(s,this.orientationMatrix,s),e.m4.multiply(s,i.globalToLocalMatrix,s);const o=e.m4.transformDirection(s,this.pov.target),n=this.pov.eye,r=e.m4.transformDirection(s,this.pov.up);return new I(o,n,r)}reset(){this.pov=this.initPov.clone(),this.fov=this.initFov}start(t,e){this.isStarted=!0,this.startPov=this.pov,this.startSize=e,this.previousPoint=t,this.inertia.stop()}motion(t){this.isStarted&&this.inertia.track(t);const i={x:t.x-this.previousPoint.x,y:t.y-this.previousPoint.y},s=m.accelerate(i.x,1.3)/this.startSize.width*.2*Math.PI*1.5,o=m.accelerate(i.y,1.3)/this.startSize.height*.2*Math.PI,n=e.m4.multiply(e.m4.rotationY(-s),e.m4.rotationX(-o)),r=e.v3.normalize(e.v3.cross(this.pov.up,this.pov.target)),a=new M(r,[0,1,0],this.pov.eye),h=e.m4.identity();e.m4.multiply(h,a.localToGlobalMatrix,h),e.m4.multiply(h,n,h),e.m4.multiply(h,a.globalToLocalMatrix,h);const c=e.m4.transformPoint(h,this.pov.target),d=e.m4.transformDirection(h,this.pov.up);e.v3.cross(d,[0,0,1])[0]>=0&&(this.pov.target=c,this.pov.up=d),this.previousPoint=t,this.onMotion()}end(t,e){this.isStarted=!1,e&&(this.inertia.track(t),this.inertia.start())}orientation(t,i,s){const o=m.degreesToRadians(window.orientation)||0,n=m.degreesToRadians(t),r=m.degreesToRadians(-i),a=m.degreesToRadians(-s),h=e.m4.rotationX(m.degreesToRadians(90));e.m4.rotateZ(h,this.initOrientation,h),e.m4.rotateZ(h,n,h),e.m4.rotateX(h,r,h),e.m4.rotateY(h,a,h),e.m4.rotateZ(h,-o,h),this.orientationMatrix=h,this.onMotion()}}class A{constructor(t,i,s,o){this.container=t,this.canvas=i,this.loader=s,this.images=[],this.hotspotsList=[[]];const n=new I([0,0,1],[0,0,0],[0,1,0]),a=e.m4.rotationX(m.degreesToRadians(15));e.m4.transformDirection(a,n.target,n.target),e.m4.transformDirection(a,n.up,n.up),this.interaction=new L(n,60,(()=>{this.animationFrameId=requestAnimationFrame(this.render),this.onInteraction({pov:this.interaction.pov.clone(),fov:this.interaction.fov})})),this.onInteraction=o,this.gl=this.canvas.context,this.programInfo=r.createProgramInfo(this.gl,["attribute vec4 position;uniform mat4 u_matrix;varying vec3 direction;void main(){direction=(u_matrix*position).xyz;gl_Position=position*vec4(-1,1,1,1);}\n","precision mediump float;uniform float u_mix;uniform samplerCube u_texture;uniform samplerCube u_texture_back;varying vec3 direction;void main(){vec4 backColor=textureCube(u_texture_back,direction);vec4 color=textureCube(u_texture,direction);gl_FragColor=mix(backColor,color,u_mix);}\n"]),this.quad=r.primitives.createXYQuadBufferInfo(this.gl),this.uniforms={u_matrix:e.m4.identity(),u_mix:0,u_texture_back:r.createTexture(this.gl,{target:this.gl.TEXTURE_CUBE_MAP,minMag:this.gl.LINEAR,width:1,height:1}),u_texture:r.createTexture(this.gl,{target:this.gl.TEXTURE_CUBE_MAP,minMag:this.gl.LINEAR,width:1,height:1})},this.render=this.render.bind(this)}destroy(){this.interaction.destroy(),this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}show(){this.canvas.show(),this.container.classList.add("ls-viewer-container-vrcube")}hide(){this.canvas.hide(),this.container.classList.remove("ls-viewer-container-vrcube")}get pov(){return this.interaction.pov}set pov(t){this.interaction.pov.eye.every(((e,i)=>e===t.eye[i]))&&this.interaction.pov.target.every(((e,i)=>e===t.target[i]))&&this.interaction.pov.up.every(((e,i)=>e===t.up[i]))||(this.interaction.pov=t.clone(),this.animationFrameId=requestAnimationFrame(this.render))}get fov(){return m.radiansToDegrees(this.interaction.fov)}set fov(t){this.interaction.fov!==t&&(this.interaction.fov=m.degreesToRadians(t),this.animationFrameId=requestAnimationFrame(this.render))}get hotspots(){const t=[];this.hotspotsList.flat();const i=this.canvas.element.clientWidth,s=this.canvas.element.clientHeight,o=e.m4.inverse(this.modelViewProjectionMatrix);return this.hotspotsList.forEach(((n,r)=>{n.forEach((n=>{const a=n.position2D.x/this.images[0].width,h=n.position2D.y/this.images[0].height;let c=0,d=0,l=0;switch(r){case 0:if(this.pov.target[2]<0)return;c=2*a-1,d=-1*(2*h-1),l=1;break;case 1:if(this.pov.target[0]<0)return;c=1,d=-1*(2*h-1),l=1-2*a;break;case 2:if(this.pov.target[2]>0)return;c=1-2*a,d=-1*(2*h-1),l=-1;break;case 3:if(this.pov.target[0]>0)return;c=-1,d=-1*(2*h-1),l=2*a-1;break;case 4:if(this.pov.target[1]<0)return;c=2*a-1,d=1,l=2*h-1;break;case 5:if(this.pov.target[1]>0)return;c=2*a-1,d=-1,l=-1*(2*h-1)}const m=e.v3.normalize([c,d,l]),u=e.m4.transformPoint(o,m),v={x:i-.5*i*(u[0]+1),y:s-.5*s*(u[1]+1)};t.push(Object.assign(Object.assign({},n),{position2D:v}))}))})),t}async load(t,e,i,s){let o=Promise.resolve();const n=JSON.stringify(t);n===this.snapshotHash?o=o.then((()=>(this.animationFrameId=requestAnimationFrame(this.render),Promise.resolve()))):(this.images=[],this.animationFrameId=requestAnimationFrame(this.render),o=o.then((()=>this.loader.loadVRCubeSnapshot(t).then((t=>{this.images=t,r.createTexture(this.gl,{target:this.gl.TEXTURE_CUBE_MAP,minMag:this.gl.LINEAR,auto:!1,cubeFaceOrder:[this.gl.TEXTURE_CUBE_MAP_POSITIVE_Z,this.gl.TEXTURE_CUBE_MAP_POSITIVE_X,this.gl.TEXTURE_CUBE_MAP_NEGATIVE_Z,this.gl.TEXTURE_CUBE_MAP_NEGATIVE_X,this.gl.TEXTURE_CUBE_MAP_POSITIVE_Y,this.gl.TEXTURE_CUBE_MAP_NEGATIVE_Y],src:t},((t,e)=>{t||(i&&this.interaction.reset(),this.uniforms.u_mix=s?0:1,this.uniforms.u_texture_back=this.uniforms.u_texture,this.uniforms.u_texture=e,this.animationFrameId=requestAnimationFrame(this.render))}))})))));const a=JSON.stringify(e);return!e.length||n===this.snapshotHash&&a===this.tagsHash||(o=o.then((()=>this.loader.loadVRCubeHotspots(t,e).then((t=>{this.hotspotsList=t}))))),this.snapshotHash=n,this.tagsHash=a,o.then((()=>Promise.resolve(this.hotspots)))}snapshot(t,e){return this.canvas.element.toDataURL(t,e)}get modelViewProjectionMatrix(){const t=this.canvas.element.clientWidth,i=this.canvas.element.clientHeight,s=t>i?t/i:i/t,o=c.getStandardAspectRatio(t,i),n=this.interaction.fov*(o/s),r=t>i?m.perspectiveWithFovY(n,t/i,.5,100):m.perspectiveWithFovX(n,t/i,.5,100),a=e.m4.inverse(r),h=this.interaction.orientedPov,d=e.m4.lookAt(h.eye,h.target,h.up);return e.m4.multiply(d,a)}render(){this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height),this.uniforms.u_matrix=this.modelViewProjectionMatrix,this.gl.useProgram(this.programInfo.program),r.setBuffersAndAttributes(this.gl,this.programInfo,this.quad),r.setUniforms(this.programInfo,this.uniforms),r.drawBufferInfo(this.gl,this.quad),this.uniforms.u_mix<1&&(this.uniforms.u_mix=Math.min(this.uniforms.u_mix+.05,1),this.animationFrameId=requestAnimationFrame(this.render))}onMouseDown(t){this.container.classList.add("ls-viewer-container-vrcube-grabbing"),this.interaction.start(P.pointFromMouseEvent(t),{width:this.gl.canvas.width,height:this.gl.canvas.height})}onMouseMove(t){this.interaction.isStarted&&(this.interaction.motion(P.pointFromMouseEvent(t)),t.preventDefault())}onMouseUp(t){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrcube-grabbing"),this.interaction.end(P.pointFromMouseEvent(t),!0))}onMouseEnter(t){this.interaction.isStarted&&0===t.buttons&&(this.container.classList.remove("ls-viewer-container-vrcube-grabbing"),this.interaction.end(P.pointFromMouseEvent(t),!1))}onTouchStart(t){this.container.classList.add("ls-viewer-container-vrcube-grabbing"),this.interaction.start(P.pointFromTouchEvent(t),{width:this.gl.canvas.width,height:this.gl.canvas.height})}onTouchMove(t){this.interaction.isStarted&&(this.interaction.motion(P.pointFromTouchEvent(t)),t.preventDefault())}onTouchEnd(t){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrcube-grabbing"),this.interaction.end(P.pointFromTouchEvent(t),!0))}onDeviceOrientation(t){this.interaction.orientation(t.alpha,t.beta,t.gamma)}}class S{constructor(t,e,i,s,o){this.isStarted=!1,this.position=t,this.frames=e,this.rows=i,this.loop=s,this.onMotion=o,this.inertia=new E(this.motion.bind(this)),this.initPosition=this.position,this.startPosition={x:0,y:0},this.startPoint=new f(0,0),this.startSize={width:0,height:0},this.lastPoints=[],this.lastPointsNumber=20}destroy(){this.inertia.destroy()}reset(){this.position=this.initPosition}get positionIndex(){return this.frames*this.position.y+this.position.x}set positionIndex(t){if(this.positionIndex===t)return;const e=this.loop?m.mod(t,this.frames*this.rows):Math.max(0,Math.min(t,this.frames*this.rows));this.position.x=m.mod(e,this.frames),this.position.y=Math.floor(e/this.frames)}start(t,e){this.isStarted=!0,this.startPosition=Object.assign({},this.position),this.startPoint=t,this.startSize=e,this.lastPoints=[],this.inertia.stop()}motion(t){this.isStarted&&this.inertia.track(t),this.lastPoints.push({x:t.x,y:t.y}),this.lastPoints.splice(0,this.lastPoints.length-this.lastPointsNumber);const e=a.default.linear(this.lastPoints.map((t=>[t.x,t.y])));if(Math.abs(e.equation[0])<1){const e=m.accelerate(t.x-this.startPoint.x,1.3)/this.startSize.width*(this.frames/4);let i=this.startPosition.x-Math.round(e);i=this.loop?m.mod(i,this.frames):Math.max(0,Math.min(i,this.frames-1)),i!==this.position.x&&(this.position.x=i,this.onMotion());const s=Math.min(...this.lastPoints.map((t=>t.x)));Math.max(...this.lastPoints.map((t=>t.x)))-s>25&&(this.startPoint.y=t.y,this.startPosition.y=this.position.y)}else{const e=m.accelerate(t.y-this.startPoint.y,1.7)/this.startSize.height*(this.rows/4);let i=this.startPosition.y+Math.round(e);i=Math.max(0,Math.min(i,this.rows-1)),i!==this.position.y&&(this.position.y=i,this.onMotion());const s=Math.min(...this.lastPoints.map((t=>t.y)));Math.max(...this.lastPoints.map((t=>t.y)))-s>25&&(this.startPoint.x=t.x,this.startPosition.x=this.position.x)}}end(t,e){this.isStarted=!1,e&&(this.inertia.track(t),this.inertia.start())}}class F{constructor(t,e,i,s){this.container=t,this.canvas=e,this.loader=i,this.images=[],this.frames=24,this.hotspotsList=[[]],this.interaction=new S({x:0,y:0},1,1,!1,(()=>{this.canvas.draw(this.image,!0,.5),this.onInteraction({position:this.interaction.positionIndex})})),this.onInteraction=s}destroy(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}show(){this.canvas.show(!1),this.container.classList.add("ls-viewer-container-vrobject")}hide(){this.canvas.hide(!1),this.container.classList.remove("ls-viewer-container-vrobject")}async goto(t){return new Promise((e=>{let i=this.interaction.positionIndex;const s=()=>{if(this.interaction.positionIndex===t)e();else{let e=i>t?-1:1;this.interaction.loop&&this.interaction.frames-i+t<Math.abs(t-i)&&(e*=-1),i+=.5*e,this.position=Math.floor(i),this.animationFrameId=requestAnimationFrame(s)}};this.animationFrameId=requestAnimationFrame(s)}))}get position(){return this.interaction.positionIndex}set position(t){this.interaction.positionIndex=t,this.canvas.draw(this.image,!0,.5)}get image(){return this.images[this.interaction.positionIndex]}get hotspots(){return this.hotspotsList[this.interaction.positionIndex]||[]}async load(t,e,i,s){let o=Promise.resolve();i&&this.interaction.reset();const n=JSON.stringify(t);n===this.snapshotHash&&this.image?o=o.then((()=>this.canvas.draw(this.image,s,.05))):(this.images=[],o=o.then((()=>this.loader.loadVRObjectSnapshot(t,this.interaction.positionIndex).then((e=>{const o=e.length;return this.images=new Array(o),this.interaction.frames=t.view.frames||this.frames,this.interaction.rows=o/this.interaction.frames,this.interaction.loop=!!t.view.loop,i&&this.interaction.reset(),e.forEach(((t,e)=>{t.then((t=>{this.images[e]=t,t===this.image&&this.canvas.draw(this.image,s,.05)})).catch((()=>{}))})),e[this.interaction.positionIndex].then((()=>Promise.resolve()))})))));const r=JSON.stringify(e);return!e.length||n===this.snapshotHash&&r===this.tagsHash||(o=o.then((()=>this.loader.loadVRObjectHotspots(t,e).then((t=>{this.hotspotsList=t}))))),this.snapshotHash=n,this.tagsHash=r,o.then((()=>Promise.resolve(this.hotspots)))}snapshot(t,e){return this.canvas.element.toDataURL(t,e)}onMouseDown(t){this.container.classList.add("ls-viewer-container-vrobject-grabbing"),this.interaction.start(P.pointFromMouseEvent(t),{width:this.canvas.element.width,height:this.canvas.element.height})}onMouseMove(t){this.interaction.isStarted&&(this.interaction.motion(P.pointFromMouseEvent(t)),t.preventDefault())}onMouseUp(t){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrobject-grabbing"),this.interaction.end(P.pointFromMouseEvent(t),!0))}onMouseEnter(t){this.interaction.isStarted&&0===t.buttons&&(this.container.classList.remove("ls-viewer-container-vrobject-grabbing"),this.interaction.end(P.pointFromMouseEvent(t),!1))}onTouchStart(t){this.container.classList.add("ls-viewer-container-vrobject-grabbing"),this.interaction.start(P.pointFromTouchEvent(t),{width:this.canvas.element.width,height:this.canvas.element.height})}onTouchMove(t){this.interaction.isStarted&&(this.interaction.motion(P.pointFromTouchEvent(t)),t.preventDefault())}onTouchEnd(t){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrobject-grabbing"),this.interaction.end(P.pointFromTouchEvent(t),!0))}onDeviceOrientation(t){}}var T,j,O,k;!function(t,e){void 0===e&&(e={});var i=e.insertAt;if(t&&"undefined"!=typeof document){var s=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===i&&s.firstChild?s.insertBefore(o,s.firstChild):s.appendChild(o),o.styleSheet?o.styleSheet.cssText=t:o.appendChild(document.createTextNode(t))}}(".ls-viewer-container{display:block;height:100%;overflow:hidden;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:100%}.ls-viewer-container-image,.ls-viewer-container-video{cursor:default;pointer-events:none}.ls-viewer-container-vrcube{cursor:pointer;cursor:-webkit-grab;cursor:grab}.ls-viewer-container-vrcube-grabbing{cursor:move;cursor:-webkit-grabbing;cursor:grabbing}.ls-viewer-container-vrobject{cursor:move;cursor:-webkit-grab;cursor:grab}.ls-viewer-container-vrobject-grabbing{cursor:move;cursor:-webkit-grabbing;cursor:grabbing}.ls-viewer-container-loading{cursor:progress}.ls-viewer-canvas{opacity:0;position:absolute;-webkit-transition:opacity .5s;transition:opacity .5s}.ls-viewer-video{position:absolute}");exports.WRAPIv2=void 0,T=exports.WRAPIv2||(exports.WRAPIv2={}),(j=T.SunShadowQualityMode||(T.SunShadowQualityMode={})).VeryLow="veryLow",j.Low="low",j.Medium="medium",j.Fine="fine",j.Ultra="ultra",(O=T.SunShadowSmoothnessMode||(T.SunShadowSmoothnessMode={})).None="none",O.Weak="weak",O.Normal="normal",O.Fine="fine",O.UltraFine="ultraFine",O.Max="max",(k=T.SunUseCaseMode||(T.SunUseCaseMode={})).Manual="manual",k.ExtractedFromEnv="extractedFromEnv",exports.Viewer=class{constructor(t,e){this.checkResize=this.checkResize.bind(this),this.onDeviceOrientation=this.onDeviceOrientation.bind(this),this.onResize=this.onResize.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onMouseEnter=this.onMouseEnter.bind(this),this.onTouchStart=this.onTouchStart.bind(this),this.onTouchMove=this.onTouchMove.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this),this.onLoadStart=this.onLoadStart.bind(this),this.onLoadProgress=this.onLoadProgress.bind(this),this.onLoadEnd=this.onLoadEnd.bind(this),this.onLoadError=this.onLoadError.bind(this),this.onHotspotsChange=this.onHotspotsChange.bind(this),this.onVrcubeInteraction=this.onVrcubeInteraction.bind(this),this.onVrobjectInteraction=this.onVrobjectInteraction.bind(this),this.options=Object.assign({server:"localhost",api:"v1",fit:"cover",image:{},video:{},vrcube:{},vrobject:{},events:{}},e),this.options.events=Object.assign({onLoadStart:()=>{},onLoadProgress:()=>{},onLoadEnd:()=>{},onLoadError:()=>{},onInteraction:()=>{},onVrcubeInteraction:()=>{},onVrobjectInteraction:()=>{},onHotspotsChange:()=>{}},e.events),this.options.events.onLoadError=n.default(this.options.events.onLoadError,10),this.container=t,this.container.classList.add("ls-viewer-container"),this.containerWidth=0,this.containerHeight=0,this.canvas2D=new d(this.options.fit),this.container.appendChild(this.canvas2D.element),this.canvas3D=new l,this.container.appendChild(this.canvas3D.element),this.video=new w,this.container.appendChild(this.video.element),this.loader=new p(this.options.server,this.options.api,this),this.resolution=new h(0,0),this.parameters={width:0,height:0,antialiasing:!1,superSampling:2},this.encoder={format:"jpeg",quality:80},this.widgetImage=new b(t,this.canvas2D,this.loader),this.widgetVideo=new y(t,this.video,this.loader),this.widgetVRCube=new A(t,this.canvas3D,this.loader,this.onVrcubeInteraction),this.widgetVRObject=new F(t,this.canvas2D,this.loader,this.onVrobjectInteraction),this.widget=this.widgetImage,this.isDestroyed=!1,this.container.addEventListener("mousedown",this.onMouseDown),this.container.addEventListener("mouseenter",this.onMouseEnter),this.container.addEventListener("touchstart",this.onTouchStart),document.addEventListener("mousemove",this.onMouseMove,{passive:!1}),document.addEventListener("mouseup",this.onMouseUp),document.addEventListener("touchmove",this.onTouchMove,{passive:!1}),document.addEventListener("touchend",this.onTouchEnd),this.checkResize(),this.loadWidget=n.default(this.loadWidget,10),this.onResize=n.default(this.onResize,250)}destroy(){this.canvas2D.destroy(),this.container.removeEventListener("mousedown",this.onMouseDown),this.container.removeEventListener("mouseenter",this.onMouseEnter),this.container.removeEventListener("touchstart",this.onTouchStart),document.removeEventListener("mousemove",this.onMouseMove),document.removeEventListener("mouseup",this.onMouseUp),document.removeEventListener("touchmove",this.onTouchMove),document.removeEventListener("touchend",this.onTouchEnd),this.isDestroyed=!0}async load(t,e){let i=Promise.resolve();return(null==e?void 0:e.animation)&&(i=i.then((()=>this.loadAnimation(e.animation)))),this.view&&void 0!==(null==e?void 0:e.fromPosition)&&this.viewWidget instanceof F&&(this.view.mode,i=i.then((()=>this.viewWidget.goto(e.fromPosition)))),(null==e?void 0:e.animation)&&(i=i.then((()=>this.widgetVideo.play()))),i=i.then((()=>(this.scene=Array.isArray(t)?[...t]:[t],this.loadWidget(!1,!(e&&e.animation))))),i.catch((t=>{this.onLoadError(t)})),i}async setEncoder(t){this.encoder=Object.assign({},t);let e=Promise.resolve();return e=e.then((()=>this.loadWidget(!1,!0))),e.catch((t=>{this.onLoadError(t)})),e}setParameters(t){this.parameters=Object.assign({},t),this.parameters.width=this.resolution.width,this.parameters.height=this.resolution.height;let e=Promise.resolve();return e=e.then((()=>this.loadWidget(!1,!0))),e.catch((t=>{this.onLoadError(t)})),e}setTags(t){this.tags=t,this.loadWidget(!1,!1)}async setView(t,e){let i=Promise.resolve();return(null==e?void 0:e.animation)&&(i=i.then((()=>this.loadAnimation(e.animation)))),this.view&&void 0!==(null==e?void 0:e.fromPosition)&&this.viewWidget instanceof F&&(i=i.then((()=>this.viewWidget.goto(e.fromPosition)))),(null==e?void 0:e.animation)&&(i=i.then((()=>this.widgetVideo.play()))),i=i.then((()=>{let i=!0;return this.view=Object.assign({},t),this.view&&this.viewWidget instanceof F&&void 0!==(null==e?void 0:e.toPosition)&&(i=!1,this.viewWidget.position=e.toPosition),this.loadWidget(i,!(e&&e.animation))})),i.catch((t=>{this.onLoadError(t)})),i}setVrcube(t){Object.assign(this.widgetVRCube,t)}setVrobject(t){Object.assign(this.widgetVRObject,t)}async loadAnimation(t){var e;const i={scene:this.scene,view:{animation:t.name,camera:t.camera,duration:t.duration,loop:t.loop,reverse:t.reverse},parameters:this.parameters,encoder:{format:"mp4"}};return(null===(e=i.view)||void 0===e?void 0:e.background)||(i.view.background="product"),this.widgetVideo.load(i).then((()=>Promise.resolve()))}async playAnimation(t){return this.loadAnimation(t).then((()=>this.widgetVideo.play())).catch((t=>{this.onLoadError(t)}))}stopAnimation(){this.widgetVideo.hide()}snapshot(t,e){return this.viewWidget.snapshot(t,e)}async loadWidget(t,e){if(!this.scene||!this.view)return Promise.resolve();if(!this.parameters.width||!this.parameters.height)return Promise.resolve();const i=this.viewWidget;if(!i)return Promise.reject(new Error("Unknown view mode"));const s={scene:this.scene,view:this.view,parameters:this.parameters,encoder:this.encoder};return s.view.background||(s.view.background="product"),i.load(s,this.tags||[],t,e).then((t=>{this.widget.hide(),this.widget=i,this.widget.show(),this.widgetVideo.hide(),this.onHotspotsChange(t)}))}get viewWidget(){var t;switch(null===(t=this.view)||void 0===t?void 0:t.mode){case"image":default:return this.widgetImage;case"video":return this.widgetVideo;case"vrcube":return this.widgetVRCube;case"vrobject":return this.widgetVRObject}}checkResize(){if(this.isDestroyed)return;const t=this.container.clientWidth,e=this.container.clientHeight;t===this.containerWidth&&e===this.containerHeight||(this.containerWidth=t,this.containerHeight=e,this.onResize()),this.isDestroyed||requestAnimationFrame(this.checkResize)}onMouseDown(t){this.widget.onMouseDown(t)}onMouseEnter(t){this.widget.onMouseEnter(t)}onMouseMove(t){this.widget.onMouseMove(t)}onMouseUp(t){this.widget.onMouseUp(t)}onTouchStart(t){this.widget.onTouchStart(t)}onTouchMove(t){this.widget.onTouchMove(t)}onTouchEnd(t){this.widget.onTouchEnd(t)}onDeviceOrientation(t){this.widget.onDeviceOrientation(t)}onResize(){const t=this.container.clientWidth,e=this.container.clientHeight;this.resolution=c.getStandardResolution(t*window.devicePixelRatio,e*window.devicePixelRatio),this.parameters.width=this.resolution.width,this.parameters.height=this.resolution.height,this.canvas2D.resize(t,e,window.devicePixelRatio),this.canvas3D.resize(t,e,window.devicePixelRatio),this.video.resize(t,e,this.resolution,this.options.fit),this.loadWidget(!1,!1).catch((t=>{this.onLoadError(t)}))}onVrcubeInteraction(...t){this.options.events.onHotspotsChange(this.widgetVRCube.hotspots),this.options.events.onInteraction(...t),this.options.events.onVrcubeInteraction(...t)}onVrobjectInteraction(...t){this.options.events.onHotspotsChange(this.widgetVRObject.hotspots),this.options.events.onInteraction(...t),this.options.events.onVrobjectInteraction(...t)}onHotspotsChange(...t){this.options.events.onHotspotsChange(...t)}onLoadStart(...t){this.container.classList.add("ls-viewer-container-loading"),this.options.events.onLoadStart(...t)}onLoadProgress(...t){this.options.events.onLoadProgress(...t)}onLoadEnd(...t){this.container.classList.remove("ls-viewer-container-loading"),this.options.events.onLoadEnd(...t)}onLoadError(...t){this.container.classList.remove("ls-viewer-container-loading"),this.options.events.onLoadError(...t)}},exports.WidgetImage=b,exports.WidgetVRCube=A,exports.WidgetVRObject=F,exports.WidgetVideo=y;
function(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(s=Object.getOwnPropertySymbols(t);o<s.length;o++)e.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(t,s[o])&&(i[s[o]]=t[s[o]])}return i}(t,["accessory","decor"]);return e}))}static renderParameters(t){return Object.assign(Object.assign({},t.parameters),{superSampling:t.parameters.superSampling.toString()})}static encoder(t){switch(t.encoder.format){case"jpeg":return{jpeg:{quality:t.encoder.quality}};case"png":return{png:{compression:t.encoder.compression}};case"webp":return{webp:{quality:t.encoder.quality}}}return{jpeg:{quality:80}}}static async fetchFrame(t,e){return fetch(t,{method:"POST",body:JSON.stringify(e)}).then((t=>t.json())).then((t=>t.url))}static async fetchFrameArray(t,e){return fetch(t,{method:"POST",body:JSON.stringify(e)}).then((t=>t.json())).then((t=>t.map((t=>t.url))))}static async fetchHotspots(t,e){return fetch(t,{method:"POST",body:JSON.stringify(e)}).then((t=>t.json())).then((t=>t))}static async fetchHotspotsArray(t,e){return fetch(t,{method:"POST",body:JSON.stringify(e)}).then((t=>t.json())).then((t=>t))}async image(t){const e={scene:g.scene(t),mode:{image:{camera:t.view.camera}},renderParameters:g.renderParameters(t),encoder:g.encoder(t)};return g.fetchFrame(`${this.server}/Snapshot`,e)}async vrCube(t){const e={scene:g.scene(t),mode:{vrCube:{camera:t.view.camera}},renderParameters:g.renderParameters(t),encoder:g.encoder(t)};return e.renderParameters.width=Math.max(e.renderParameters.width,e.renderParameters.height),e.renderParameters.height=Math.max(e.renderParameters.width,e.renderParameters.height),g.fetchFrameArray(`${this.server}/Snapshot`,e)}async vrObject(t){let e;e=t.view.cameraGroup?{images:{cameraGroup:t.view.cameraGroup}}:t.view.frames?{vrObject:{camera:t.view.camera,frames:t.view.frames}}:{vrObject:{camera:t.view.camera,panFrames:t.view.panFrames||1,panFrom:t.view.panFrom||0,panTo:t.view.panTo||0,panLoop:t.view.panLoop||!1,tiltFrames:t.view.tiltFrames||1,tiltFrom:t.view.tiltFrom||0,tiltTo:t.view.tiltTo||0,tiltLoop:t.view.tiltLoop||!1}};const i={scene:g.scene(t),mode:e,renderParameters:g.renderParameters(t),encoder:g.encoder(t)};return g.fetchFrameArray(`${this.server}/Snapshot`,i)}async animation(t){const e={scene:g.scene(t),mode:{animation:{id:t.view.animation,camera:t.view.camera,fps:t.view.fps}},renderParameters:g.renderParameters(t),encoder:g.encoder(t)};return g.fetchFrameArray(`${this.server}/Snapshot`,e)}async imageHotspots(t,e){const i={scene:g.scene(t),mode:{image:{camera:t.view.camera}},renderParameters:g.renderParameters(t),tags:e};return await g.fetchHotspots(`${this.server}/Hotspot`,i)}async vrCubeHotspots(t,e){const i={scene:g.scene(t),mode:{vrCube:{camera:t.view.camera}},renderParameters:g.renderParameters(t),tags:e};return i.renderParameters.width=Math.max(i.renderParameters.width,i.renderParameters.height),i.renderParameters.height=Math.max(i.renderParameters.width,i.renderParameters.height),await g.fetchHotspotsArray(`${this.server}/Hotspot`,i)}async vrObjectHotspots(t,e){let i;i=t.view.cameraGroup?{images:{cameraGroup:t.view.cameraGroup}}:t.view.frames?{vrObject:{camera:t.view.camera,frames:t.view.frames}}:{vrObject:{camera:t.view.camera,panFrames:t.view.panFrames||1,panFrom:t.view.panFrom||0,panTo:t.view.panTo||0,panLoop:t.view.panLoop||!1,tiltFrames:t.view.tiltFrames||1,tiltFrom:t.view.tiltFrom||0,tiltTo:t.view.tiltTo||0,tiltLoop:t.view.tiltLoop||!1}};const s={scene:g.scene(t),mode:i,renderParameters:g.renderParameters(t),tags:e};return await g.fetchHotspotsArray(`${this.server}/Hotspot`,s)}}class p{constructor(t,e,i){switch(e){case"static":this.webrender=new u;break;case"v1":default:this.webrender=new v(t);break;case"v2":this.webrender=new g(t)}this.delegate=i,this.loadingId=0,this.loaded=0,this.total=0,this.onLoadStart=i&&i.onLoadStart?i.onLoadStart:()=>{},this.onLoadProgress=i&&i.onLoadProgress?i.onLoadProgress:()=>{},this.onLoadEnd=i&&i.onLoadEnd?i.onLoadEnd:()=>{}}get progress(){return this.total?this.loaded/this.total:0}async loadImageSnapshot(t){this.loadingId+=1,this.loaded=0,this.total=1,this.onLoadStart(this.progress);const{loadingId:e}=this;return this.webrender.image(t).then((t=>this.loadImage(t,e))).then((t=>(this.onLoadEnd(this.progress),t)))}async loadVideoSnapshot(t,e){this.loadingId+=1,this.loaded=0,this.total=1,this.onLoadStart(this.progress);const{loadingId:i}=this;return this.webrender.video(e).then((s=>this.loadVideo(t,s,!!e.view.loop,i))).then((()=>(this.onLoadEnd(this.progress),t)))}async loadVRCubeSnapshot(t){this.loadingId+=1,this.loaded=0,this.total=0,this.onLoadStart(this.progress);const{loadingId:e}=this;return this.webrender.vrCube(t).then((t=>{this.total=t.length;const i=t.map((t=>this.loadImage(t,e)));return Promise.all(i)})).then((t=>(this.onLoadEnd(this.progress),t)))}async loadVRObjectSnapshot(t,e){var i;this.loadingId+=1,this.loaded=0,this.total=0,this.onLoadStart(this.progress);const{loadingId:s}=this;return t.view.animation?"mp4"===(null===(i=t.encoder)||void 0===i?void 0:i.format)?this.webrender.video(t).then((e=>this.loadVideoFrames(e,t.view.frames,30,s))):this.webrender.animation(t).then((i=>this.loadImageFrames(i,t.view.loop,e,s))):this.webrender.vrObject(t).then((i=>this.loadImageFrames(i,t.view.loop,e,s)))}async loadImage(t,e){const i=new Image;i.crossOrigin="file:"!==location.protocol||p.isValidHttpUrl(t)?"anonymous":null;const s=new Promise(((s,o)=>{i.addEventListener("load",(()=>{e===this.loadingId&&(this.loaded+=1,this.onLoadProgress(this.progress),s(i))}),{once:!0}),i.addEventListener("error",(i=>{e===this.loadingId&&o(`${i.type} : ${t}`)}),{once:!0})}));return i.src=t,s}loadImageFrames(t,e,i,s){this.total=t.length;const o=new Array(t.length),n=i||0;for(let i=0,r=t.length;i<r;i+=1){const a=Math.ceil(i/2)*(i%2==0?1:-1),h=e?m.mod(n+a,r):i;o[h]=this.loadImage(t[h],s)}return Promise.all(o).then((()=>this.onLoadEnd(this.progress))).catch((()=>{})),o}async loadVideo(t,e,i,s){t.loop=i;const o=new Promise(((i,o)=>{t.addEventListener("canplaythrough",(()=>{s===this.loadingId&&(this.loaded+=1,this.onLoadProgress(this.progress),i())}),{once:!0}),t.addEventListener("error",(t=>{s===this.loadingId&&o(`${t.type} : ${e}`)}),{once:!0})}));return t.src=e,t.load(),o}async loadVideoFrame(t,e,i,s,o){let n=0;return new Promise(((r,a)=>{const h=()=>{if(o!==this.loadingId)return;if(n!==s)return void(n+=1);t.removeEventListener("seeked",h);const a=document.createElement("canvas");a.width=t.videoWidth,a.height=t.videoHeight;a.getContext("2d").drawImage(t,0,0);const c=new Image;c.src=a.toDataURL(),r(c),this.loaded+=1,this.onLoadProgress(this.progress),s!==i-1&&(t.currentTime+=1/e)};t.addEventListener("seeked",h),t.addEventListener("error",(t=>{o===this.loadingId&&a(t)}),{once:!0})}))}loadVideoFrames(t,e,i,s){this.total=e;const o=new Array(e),n=document.createElement("video");for(let t=0,r=e;t<r;t+=1)o[t]=this.loadVideoFrame(n,i,e,t,s);return n.addEventListener("canplaythrough",(()=>{s===this.loadingId&&(n.currentTime=1/i/2)}),{once:!0}),n.src=t,n.load(),Promise.all(o).then((()=>this.onLoadEnd(this.progress))).catch((()=>{})),o}async loadImageHotspots(t,e){return this.webrender instanceof g?await this.webrender.imageHotspots(t,e):Promise.reject(new Error("Hotspots only available with api V2"))}async loadVRCubeHotspots(t,e){return this.webrender instanceof g?await this.webrender.vrCubeHotspots(t,e):Promise.reject(new Error("Hotspots only available with api V2"))}async loadVRObjectHotspots(t,e){return this.webrender instanceof g?await this.webrender.vrObjectHotspots(t,e):Promise.reject(new Error("Hotspots only available with api V2"))}onLoadStart(t){this.delegate&&this.delegate.onLoadStart(t)}onLoadProgress(t){this.delegate&&this.delegate.onLoadProgress(t)}onLoadEnd(t){this.delegate&&this.delegate.onLoadEnd(t)}static isValidHttpUrl(t){let e;try{e=new URL(t)}catch(t){return!1}return"http:"===e.protocol||"https:"===e.protocol}}class w{constructor(){this.element=document.createElement("video"),this.element.classList.add("ls-viewer-video"),this.element.style.opacity="0",this.element.setAttribute("muted",""),this.element.setAttribute("playsinline",""),this.element.setAttribute("preload","auto")}show(){this.element.style.opacity="1"}hide(){this.element.style.opacity="0"}resize(t,e,i,s){const o=c.fit(i,new h(t,e),s);this.element.style.top=`${o.top}px`,this.element.style.left=`${o.left}px`,this.element.style.width=`${o.width}px`,this.element.style.height=`${o.height}px`,i.width===this.element.width&&i.height===this.element.height||(this.element.width=i.width,this.element.height=i.height)}}class b{constructor(t,e,i){this.container=t,this.canvas=e,this.loader=i,this.hotspots=[]}destroy(){}show(){this.canvas.show(!1),this.container.classList.add("ls-viewer-container-image")}hide(){this.canvas.hide(!1),this.container.classList.remove("ls-viewer-container-image")}async load(t,e,i,s){let o=Promise.resolve();const n=JSON.stringify(t);o=n===this.snapshotHash&&this.image?o.then((()=>this.canvas.draw(this.image,s,.05))):o.then((()=>this.loader.loadImageSnapshot(t).then((t=>{this.canvas.draw(t,s,.05),this.image=t}))));const r=JSON.stringify(e);return!e.length||n===this.snapshotHash&&r===this.tagsHash||(o=o.then((()=>this.loader.loadImageHotspots(t,e).then((t=>{this.hotspots=t}))))),this.snapshotHash=n,this.tagsHash=r,o.then((()=>Promise.resolve(this.hotspots)))}snapshot(t,e){return this.canvas.element.toDataURL(t,e)}onMouseDown(t){}onMouseMove(t){}onMouseUp(t){}onMouseEnter(t){}onTouchStart(t){}onTouchMove(t){}onTouchEnd(t){}onDeviceOrientation(t){}}class y{constructor(t,e,i){this.container=t,this.loader=i,this.video=e}destroy(){}show(){this.video.show(),this.container.classList.add("ls-viewer-container-video")}hide(){this.video.hide(),this.container.classList.remove("ls-viewer-container-video")}async load(t){const e=JSON.stringify(t);return e===this.hash?(this.video.element.load(),Promise.resolve([])):(this.hash=e,this.loader.loadVideoSnapshot(this.video.element,t).then((()=>Promise.resolve([]))))}snapshot(t,e){return"data:image/gif;base64,R0lGODlhAQABAIAAAP7//wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=="}async play(){return new Promise(((t,e)=>{this.video.element.addEventListener("ended",(()=>{t()}),{once:!0}),this.video.element.play().catch(e),this.show()}))}onMouseDown(t){}onMouseMove(t){}onMouseUp(t){}onMouseEnter(t){}onTouchStart(t){}onTouchMove(t){}onTouchEnd(t){}onDeviceOrientation(t){}}class f{constructor(t,e){this.x=t,this.y=e}clone(){return new f(this.x,this.y)}}class P{static pointFromMouseEvent(t){return new f(t.screenX,t.screenY)}static pointFromTouchEvent(t){const e=t.targetTouches[0]||t.changedTouches[0];return new f(e.screenX,e.screenY)}}class M{constructor(...t){3===t.length?(({0:this.u,1:this.v,2:this.o}=t),this.w=e.v3.cross(this.u,this.v)):4===t.length?({0:this.u,1:this.v,2:this.w,3:this.o}=t):(this.u=[1,0,0],this.v=[0,1,0],this.w=[0,0,1],this.o=[0,0,0])}get localToGlobalMatrix(){return[...[this.u[0],this.u[1],this.u[2],0],...[this.v[0],this.v[1],this.v[2],0],...[this.w[0],this.w[1],this.w[2],0],...[this.o[0],this.o[1],this.o[2],1]]}get globalToLocalMatrix(){return e.m4.inverse(this.localToGlobalMatrix)}}class x{constructor(t,e,i){this.x=t,this.y=e,this.time=i}}class E{constructor(t){this.points=[],this.onMotion=t,this.lastPoint=new f(0,0),this.velocity=new f(0,0),this.loop=this.loop.bind(this)}destroy(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}track(t){const e=Date.now();this.points=this.points.filter((t=>e-t.time<=100)),this.points.push(new x(t.x,t.y,e)),this.lastPoint=t}start(){if(0===this.points.length)return;const t=this.points[0],e=this.points[this.points.length-1],i=e.x-t.x,s=e.y-t.y,o=e.time-t.time;this.velocity=new f(0===o?0:i/(o/15),0===o?0:s/(o/15)),this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0),this.animationFrameId=requestAnimationFrame(this.loop)}stop(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0),this.points=[]}loop(){if(Math.abs(this.velocity.x)<1&&Math.abs(this.velocity.y)<1)return this.animationFrameId=void 0,void(this.points=[]);this.lastPoint.x+=this.velocity.x,this.lastPoint.y+=this.velocity.y,this.velocity.x*=.9,this.velocity.y*=.9,this.onMotion(this.lastPoint.clone()),this.animationFrameId=requestAnimationFrame(this.loop)}}class I{constructor(t,i,s){this.target=e.v3.copy(t),this.eye=e.v3.copy(i),this.up=e.v3.copy(s)}get viewVector(){return e.v3.subtract(this.target,this.eye)}get rightVector(){return e.v3.normalize(e.v3.cross(this.viewVector,this.up))}get viewMatrix(){return e.m4.inverse(e.m4.lookAt(this.eye,this.target,this.up))}clone(){return new I(e.v3.copy(this.target),e.v3.copy(this.eye),e.v3.copy(this.up))}}I.default=new I([0,0,0],[2,2,2],[0,1,0]);class L{constructor(t,i,s){this.isStarted=!1,this.pov=t,this.fov=m.degreesToRadians(i),this.orientationMatrix=e.m4.identity(),this.inertia=new E(this.motion.bind(this)),this.onMotion=s,this.initPov=this.pov,this.initFov=this.fov,this.initOrientation=m.degreesToRadians(window.orientation)||0,this.startPov=new I([0,0,1],[0,0,0],[0,1,0]),this.startSize={width:0,height:0},this.previousPoint=new f(0,0)}destroy(){this.inertia.destroy()}get orientedPov(){const t=e.v3.normalize(e.v3.cross(this.pov.up,this.pov.target)),i=new M(t,[0,1,0],this.pov.eye),s=e.m4.identity();e.m4.multiply(s,i.localToGlobalMatrix,s),e.m4.multiply(s,this.orientationMatrix,s),e.m4.multiply(s,i.globalToLocalMatrix,s);const o=e.m4.transformDirection(s,this.pov.target),n=this.pov.eye,r=e.m4.transformDirection(s,this.pov.up);return new I(o,n,r)}reset(){this.pov=this.initPov.clone(),this.fov=this.initFov}start(t,e){this.isStarted=!0,this.startPov=this.pov,this.startSize=e,this.previousPoint=t,this.inertia.stop()}motion(t){this.isStarted&&this.inertia.track(t);const i={x:t.x-this.previousPoint.x,y:t.y-this.previousPoint.y},s=m.accelerate(i.x,1.3)/this.startSize.width*.2*Math.PI*1.5,o=m.accelerate(i.y,1.3)/this.startSize.height*.2*Math.PI,n=e.m4.multiply(e.m4.rotationY(-s),e.m4.rotationX(-o)),r=e.v3.normalize(e.v3.cross(this.pov.up,this.pov.target)),a=new M(r,[0,1,0],this.pov.eye),h=e.m4.identity();e.m4.multiply(h,a.localToGlobalMatrix,h),e.m4.multiply(h,n,h),e.m4.multiply(h,a.globalToLocalMatrix,h);const c=e.m4.transformPoint(h,this.pov.target),d=e.m4.transformDirection(h,this.pov.up);e.v3.cross(d,[0,0,1])[0]>=0&&(this.pov.target=c,this.pov.up=d),this.previousPoint=t,this.onMotion()}end(t,e){this.isStarted=!1,e&&(this.inertia.track(t),this.inertia.start())}orientation(t,i,s){const o=m.degreesToRadians(window.orientation)||0,n=m.degreesToRadians(t),r=m.degreesToRadians(-i),a=m.degreesToRadians(-s),h=e.m4.rotationX(m.degreesToRadians(90));e.m4.rotateZ(h,this.initOrientation,h),e.m4.rotateZ(h,n,h),e.m4.rotateX(h,r,h),e.m4.rotateY(h,a,h),e.m4.rotateZ(h,-o,h),this.orientationMatrix=h,this.onMotion()}}class A{constructor(t,i,s,o){this.container=t,this.canvas=i,this.loader=s,this.images=[],this.hotspotsList=[[]];const n=new I([0,0,1],[0,0,0],[0,1,0]),a=e.m4.rotationX(m.degreesToRadians(15));e.m4.transformDirection(a,n.target,n.target),e.m4.transformDirection(a,n.up,n.up),this.interaction=new L(n,60,(()=>{this.animationFrameId=requestAnimationFrame(this.render),this.onInteraction({pov:this.interaction.pov.clone(),fov:this.interaction.fov})})),this.onInteraction=o,this.gl=this.canvas.context,this.programInfo=r.createProgramInfo(this.gl,["attribute vec4 position;uniform mat4 u_matrix;varying vec3 direction;void main(){direction=(u_matrix*position).xyz;gl_Position=position*vec4(-1,1,1,1);}\n","precision mediump float;uniform float u_mix;uniform samplerCube u_texture;uniform samplerCube u_texture_back;varying vec3 direction;void main(){vec4 backColor=textureCube(u_texture_back,direction);vec4 color=textureCube(u_texture,direction);gl_FragColor=mix(backColor,color,u_mix);}\n"]),this.quad=r.primitives.createXYQuadBufferInfo(this.gl),this.uniforms={u_matrix:e.m4.identity(),u_mix:0,u_texture_back:r.createTexture(this.gl,{target:this.gl.TEXTURE_CUBE_MAP,minMag:this.gl.LINEAR,width:1,height:1}),u_texture:r.createTexture(this.gl,{target:this.gl.TEXTURE_CUBE_MAP,minMag:this.gl.LINEAR,width:1,height:1})},this.render=this.render.bind(this)}destroy(){this.interaction.destroy(),this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}show(){this.canvas.show(),this.container.classList.add("ls-viewer-container-vrcube")}hide(){this.canvas.hide(),this.container.classList.remove("ls-viewer-container-vrcube")}get pov(){return this.interaction.pov}set pov(t){this.interaction.pov.eye.every(((e,i)=>e===t.eye[i]))&&this.interaction.pov.target.every(((e,i)=>e===t.target[i]))&&this.interaction.pov.up.every(((e,i)=>e===t.up[i]))||(this.interaction.pov=t.clone(),this.animationFrameId=requestAnimationFrame(this.render))}get fov(){return m.radiansToDegrees(this.interaction.fov)}set fov(t){this.interaction.fov!==t&&(this.interaction.fov=m.degreesToRadians(t),this.animationFrameId=requestAnimationFrame(this.render))}get hotspots(){const t=[];this.hotspotsList.flat();const i=this.canvas.element.clientWidth,s=this.canvas.element.clientHeight,o=e.m4.inverse(this.modelViewProjectionMatrix);return this.hotspotsList.forEach(((n,r)=>{n.forEach((n=>{const a=n.position2D.x/this.images[0].width,h=n.position2D.y/this.images[0].height;let c=0,d=0,l=0;switch(r){case 0:if(this.pov.target[2]<0)return;c=2*a-1,d=-1*(2*h-1),l=1;break;case 1:if(this.pov.target[0]<0)return;c=1,d=-1*(2*h-1),l=1-2*a;break;case 2:if(this.pov.target[2]>0)return;c=1-2*a,d=-1*(2*h-1),l=-1;break;case 3:if(this.pov.target[0]>0)return;c=-1,d=-1*(2*h-1),l=2*a-1;break;case 4:if(this.pov.target[1]<0)return;c=2*a-1,d=1,l=2*h-1;break;case 5:if(this.pov.target[1]>0)return;c=2*a-1,d=-1,l=-1*(2*h-1)}const m=e.v3.normalize([c,d,l]),u=e.m4.transformPoint(o,m),v={x:i-.5*i*(u[0]+1),y:s-.5*s*(u[1]+1)};t.push(Object.assign(Object.assign({},n),{position2D:v}))}))})),t}async load(t,e,i,s){let o=Promise.resolve();const n=JSON.stringify(t);n===this.snapshotHash?o=o.then((()=>(this.animationFrameId=requestAnimationFrame(this.render),Promise.resolve()))):(this.images=[],this.animationFrameId=requestAnimationFrame(this.render),o=o.then((()=>this.loader.loadVRCubeSnapshot(t).then((t=>{this.images=t,r.createTexture(this.gl,{target:this.gl.TEXTURE_CUBE_MAP,minMag:this.gl.LINEAR,auto:!1,cubeFaceOrder:[this.gl.TEXTURE_CUBE_MAP_POSITIVE_Z,this.gl.TEXTURE_CUBE_MAP_POSITIVE_X,this.gl.TEXTURE_CUBE_MAP_NEGATIVE_Z,this.gl.TEXTURE_CUBE_MAP_NEGATIVE_X,this.gl.TEXTURE_CUBE_MAP_POSITIVE_Y,this.gl.TEXTURE_CUBE_MAP_NEGATIVE_Y],src:t},((t,e)=>{t||(i&&this.interaction.reset(),this.uniforms.u_mix=s?0:1,this.uniforms.u_texture_back=this.uniforms.u_texture,this.uniforms.u_texture=e,this.animationFrameId=requestAnimationFrame(this.render))}))})))));const a=JSON.stringify(e);return!e.length||n===this.snapshotHash&&a===this.tagsHash||(o=o.then((()=>this.loader.loadVRCubeHotspots(t,e).then((t=>{this.hotspotsList=t}))))),this.snapshotHash=n,this.tagsHash=a,o.then((()=>Promise.resolve(this.hotspots)))}snapshot(t,e){return this.canvas.element.toDataURL(t,e)}get modelViewProjectionMatrix(){const t=this.canvas.element.clientWidth,i=this.canvas.element.clientHeight,s=t>i?t/i:i/t,o=c.getStandardAspectRatio(t,i),n=this.interaction.fov*(o/s),r=t>i?m.perspectiveWithFovY(n,t/i,.5,100):m.perspectiveWithFovX(n,t/i,.5,100),a=e.m4.inverse(r),h=this.interaction.orientedPov,d=e.m4.lookAt(h.eye,h.target,h.up);return e.m4.multiply(d,a)}render(){this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height),this.uniforms.u_matrix=this.modelViewProjectionMatrix,this.gl.useProgram(this.programInfo.program),r.setBuffersAndAttributes(this.gl,this.programInfo,this.quad),r.setUniforms(this.programInfo,this.uniforms),r.drawBufferInfo(this.gl,this.quad),this.uniforms.u_mix<1&&(this.uniforms.u_mix=Math.min(this.uniforms.u_mix+.05,1),this.animationFrameId=requestAnimationFrame(this.render))}onMouseDown(t){this.container.classList.add("ls-viewer-container-vrcube-grabbing"),this.interaction.start(P.pointFromMouseEvent(t),{width:this.gl.canvas.width,height:this.gl.canvas.height})}onMouseMove(t){this.interaction.isStarted&&(this.interaction.motion(P.pointFromMouseEvent(t)),t.preventDefault())}onMouseUp(t){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrcube-grabbing"),this.interaction.end(P.pointFromMouseEvent(t),!0))}onMouseEnter(t){this.interaction.isStarted&&0===t.buttons&&(this.container.classList.remove("ls-viewer-container-vrcube-grabbing"),this.interaction.end(P.pointFromMouseEvent(t),!1))}onTouchStart(t){this.container.classList.add("ls-viewer-container-vrcube-grabbing"),this.interaction.start(P.pointFromTouchEvent(t),{width:this.gl.canvas.width,height:this.gl.canvas.height})}onTouchMove(t){this.interaction.isStarted&&(this.interaction.motion(P.pointFromTouchEvent(t)),t.preventDefault())}onTouchEnd(t){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrcube-grabbing"),this.interaction.end(P.pointFromTouchEvent(t),!0))}onDeviceOrientation(t){this.interaction.orientation(t.alpha,t.beta,t.gamma)}}class S{constructor(t,e,i,s,o){this.isStarted=!1,this.position=t,this.frames=e,this.rows=i,this.loop=s,this.onMotion=o,this.inertia=new E(this.motion.bind(this)),this.initPosition=this.position,this.startPosition={x:0,y:0},this.startPoint=new f(0,0),this.startSize={width:0,height:0},this.lastPoints=[],this.lastPointsNumber=20}destroy(){this.inertia.destroy()}reset(){this.position=this.initPosition}get positionIndex(){return this.frames*this.position.y+this.position.x}set positionIndex(t){if(this.positionIndex===t)return;const e=this.loop?m.mod(t,this.frames*this.rows):Math.max(0,Math.min(t,this.frames*this.rows));this.position.x=m.mod(e,this.frames),this.position.y=Math.floor(e/this.frames)}start(t,e){this.isStarted=!0,this.startPosition=Object.assign({},this.position),this.startPoint=t,this.startSize=e,this.lastPoints=[],this.inertia.stop()}motion(t){this.isStarted&&this.inertia.track(t),this.lastPoints.push({x:t.x,y:t.y}),this.lastPoints.splice(0,this.lastPoints.length-this.lastPointsNumber);const e=a.default.linear(this.lastPoints.map((t=>[t.x,t.y])));if(Math.abs(e.equation[0])<1){const e=m.accelerate(t.x-this.startPoint.x,1.3)/this.startSize.width*(this.frames/4);let i=this.startPosition.x-Math.round(e);i=this.loop?m.mod(i,this.frames):Math.max(0,Math.min(i,this.frames-1)),i!==this.position.x&&(this.position.x=i,this.onMotion());const s=Math.min(...this.lastPoints.map((t=>t.x)));Math.max(...this.lastPoints.map((t=>t.x)))-s>25&&(this.startPoint.y=t.y,this.startPosition.y=this.position.y)}else{const e=m.accelerate(t.y-this.startPoint.y,1.7)/this.startSize.height*(this.rows/4);let i=this.startPosition.y+Math.round(e);i=Math.max(0,Math.min(i,this.rows-1)),i!==this.position.y&&(this.position.y=i,this.onMotion());const s=Math.min(...this.lastPoints.map((t=>t.y)));Math.max(...this.lastPoints.map((t=>t.y)))-s>25&&(this.startPoint.x=t.x,this.startPosition.x=this.position.x)}}end(t,e){this.isStarted=!1,e&&(this.inertia.track(t),this.inertia.start())}}class F{constructor(t,e,i,s){this.container=t,this.canvas=e,this.loader=i,this.images=[],this.frames=24,this.hotspotsList=[[]],this.interaction=new S({x:0,y:0},1,1,!1,(()=>{this.canvas.draw(this.image,!0,.5),this.onInteraction({position:this.interaction.positionIndex})})),this.onInteraction=s}destroy(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}show(){this.canvas.show(!1),this.container.classList.add("ls-viewer-container-vrobject")}hide(){this.canvas.hide(!1),this.container.classList.remove("ls-viewer-container-vrobject")}async goto(t){return new Promise((e=>{let i=this.interaction.positionIndex;const s=()=>{if(this.interaction.positionIndex===t)e();else{let e=i>t?-1:1;this.interaction.loop&&this.interaction.frames-i+t<Math.abs(t-i)&&(e*=-1),i+=.5*e,this.position=Math.floor(i),this.animationFrameId=requestAnimationFrame(s)}};this.animationFrameId=requestAnimationFrame(s)}))}get position(){return this.interaction.positionIndex}set position(t){this.interaction.positionIndex=t,this.canvas.draw(this.image,!0,.5)}get image(){return this.images[this.interaction.positionIndex]}get hotspots(){return this.hotspotsList[this.interaction.positionIndex]||[]}async load(t,e,i,s){let o=Promise.resolve();i&&this.interaction.reset();const n=JSON.stringify(t);n===this.snapshotHash&&this.image?o=o.then((()=>this.canvas.draw(this.image,s,.05))):(this.images=[],o=o.then((()=>this.loader.loadVRObjectSnapshot(t,this.interaction.positionIndex).then((e=>{const o=e.length;return this.images=new Array(o),this.interaction.frames=t.view.frames||this.frames,this.interaction.rows=o/this.interaction.frames,this.interaction.loop=!!t.view.loop,i&&this.interaction.reset(),e.forEach(((t,e)=>{t.then((t=>{this.images[e]=t,t===this.image&&this.canvas.draw(this.image,s,.05)})).catch((()=>{}))})),e[this.interaction.positionIndex].then((()=>Promise.resolve()))})))));const r=JSON.stringify(e);return!e.length||n===this.snapshotHash&&r===this.tagsHash||(o=o.then((()=>this.loader.loadVRObjectHotspots(t,e).then((t=>{this.hotspotsList=t}))))),this.snapshotHash=n,this.tagsHash=r,o.then((()=>Promise.resolve(this.hotspots)))}snapshot(t,e){return this.canvas.element.toDataURL(t,e)}onMouseDown(t){this.container.classList.add("ls-viewer-container-vrobject-grabbing"),this.interaction.start(P.pointFromMouseEvent(t),{width:this.canvas.element.width,height:this.canvas.element.height})}onMouseMove(t){this.interaction.isStarted&&(this.interaction.motion(P.pointFromMouseEvent(t)),t.preventDefault())}onMouseUp(t){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrobject-grabbing"),this.interaction.end(P.pointFromMouseEvent(t),!0))}onMouseEnter(t){this.interaction.isStarted&&0===t.buttons&&(this.container.classList.remove("ls-viewer-container-vrobject-grabbing"),this.interaction.end(P.pointFromMouseEvent(t),!1))}onTouchStart(t){this.container.classList.add("ls-viewer-container-vrobject-grabbing"),this.interaction.start(P.pointFromTouchEvent(t),{width:this.canvas.element.width,height:this.canvas.element.height})}onTouchMove(t){this.interaction.isStarted&&(this.interaction.motion(P.pointFromTouchEvent(t)),t.preventDefault())}onTouchEnd(t){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrobject-grabbing"),this.interaction.end(P.pointFromTouchEvent(t),!0))}onDeviceOrientation(t){}}var T,j,O,k;!function(t,e){void 0===e&&(e={});var i=e.insertAt;if(t&&"undefined"!=typeof document){var s=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===i&&s.firstChild?s.insertBefore(o,s.firstChild):s.appendChild(o),o.styleSheet?o.styleSheet.cssText=t:o.appendChild(document.createTextNode(t))}}(".ls-viewer-container{display:block;height:100%;overflow:hidden;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:100%}.ls-viewer-container-image,.ls-viewer-container-video{cursor:default;pointer-events:none}.ls-viewer-container-vrcube{cursor:pointer;cursor:-webkit-grab;cursor:grab}.ls-viewer-container-vrcube-grabbing{cursor:move;cursor:-webkit-grabbing;cursor:grabbing}.ls-viewer-container-vrobject{cursor:move;cursor:-webkit-grab;cursor:grab}.ls-viewer-container-vrobject-grabbing{cursor:move;cursor:-webkit-grabbing;cursor:grabbing}.ls-viewer-container-loading{cursor:progress}.ls-viewer-canvas{opacity:0;position:absolute;-webkit-transition:opacity .5s;transition:opacity .5s}.ls-viewer-video{position:absolute}");exports.WRAPIv2=void 0,T=exports.WRAPIv2||(exports.WRAPIv2={}),(j=T.SunShadowQualityMode||(T.SunShadowQualityMode={})).VeryLow="veryLow",j.Low="low",j.Medium="medium",j.Fine="fine",j.Ultra="ultra",(O=T.SunShadowSmoothnessMode||(T.SunShadowSmoothnessMode={})).None="none",O.Weak="weak",O.Normal="normal",O.Fine="fine",O.UltraFine="ultraFine",O.Max="max",(k=T.SunUseCaseMode||(T.SunUseCaseMode={})).Manual="manual",k.ExtractedFromEnv="extractedFromEnv",exports.Viewer=class{constructor(t,e){this.checkResize=this.checkResize.bind(this),this.onDeviceOrientation=this.onDeviceOrientation.bind(this),this.onResize=this.onResize.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onMouseEnter=this.onMouseEnter.bind(this),this.onTouchStart=this.onTouchStart.bind(this),this.onTouchMove=this.onTouchMove.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this),this.onLoadStart=this.onLoadStart.bind(this),this.onLoadProgress=this.onLoadProgress.bind(this),this.onLoadEnd=this.onLoadEnd.bind(this),this.onLoadError=this.onLoadError.bind(this),this.onHotspotsChange=this.onHotspotsChange.bind(this),this.onVrcubeInteraction=this.onVrcubeInteraction.bind(this),this.onVrobjectInteraction=this.onVrobjectInteraction.bind(this),this.options=Object.assign({server:"localhost",api:"v1",fit:"cover",image:{},video:{},vrcube:{},vrobject:{},events:{}},e),this.options.events=Object.assign({onLoadStart:()=>{},onLoadProgress:()=>{},onLoadEnd:()=>{},onLoadError:()=>{},onInteraction:()=>{},onVrcubeInteraction:()=>{},onVrobjectInteraction:()=>{},onHotspotsChange:()=>{}},e.events),this.options.events.onLoadError=n.default(this.options.events.onLoadError,10),this.container=t,this.container.classList.add("ls-viewer-container"),this.containerWidth=0,this.containerHeight=0,this.canvas2D=new d(this.options.fit),this.container.appendChild(this.canvas2D.element),this.canvas3D=new l,this.container.appendChild(this.canvas3D.element),this.video=new w,this.container.appendChild(this.video.element),this.loader=new p(this.options.server,this.options.api,this),this.resolution=new h(0,0),this.parameters={width:0,height:0,antialiasing:!1,superSampling:2},this.encoder={format:"jpeg",quality:80},this.widgetImage=new b(t,this.canvas2D,this.loader),this.widgetVideo=new y(t,this.video,this.loader),this.widgetVRCube=new A(t,this.canvas3D,this.loader,this.onVrcubeInteraction),this.widgetVRObject=new F(t,this.canvas2D,this.loader,this.onVrobjectInteraction),this.widget=this.widgetImage,this.isDestroyed=!1,this.container.addEventListener("mousedown",this.onMouseDown),this.container.addEventListener("mouseenter",this.onMouseEnter),this.container.addEventListener("touchstart",this.onTouchStart),document.addEventListener("mousemove",this.onMouseMove,{passive:!1}),document.addEventListener("mouseup",this.onMouseUp),document.addEventListener("touchmove",this.onTouchMove,{passive:!1}),document.addEventListener("touchend",this.onTouchEnd),this.loadWidget=n.default(this.loadWidget,10),this.onResize=n.default(this.onResize,250),requestAnimationFrame(this.checkResize)}destroy(){this.canvas2D.destroy(),this.container.removeEventListener("mousedown",this.onMouseDown),this.container.removeEventListener("mouseenter",this.onMouseEnter),this.container.removeEventListener("touchstart",this.onTouchStart),document.removeEventListener("mousemove",this.onMouseMove),document.removeEventListener("mouseup",this.onMouseUp),document.removeEventListener("touchmove",this.onTouchMove),document.removeEventListener("touchend",this.onTouchEnd),this.isDestroyed=!0}async load(t,e){let i=Promise.resolve();return(null==e?void 0:e.animation)&&(i=i.then((()=>this.loadAnimation(e.animation)))),this.view&&void 0!==(null==e?void 0:e.fromPosition)&&this.viewWidget instanceof F&&(this.view.mode,i=i.then((()=>this.viewWidget.goto(e.fromPosition)))),(null==e?void 0:e.animation)&&(i=i.then((()=>this.widgetVideo.play()))),i=i.then((()=>(this.scene=Array.isArray(t)?[...t]:[t],this.loadWidget(!1,!(e&&e.animation))))),i.catch((t=>{this.onLoadError(t)})),i}async setEncoder(t){this.encoder=Object.assign({},t);let e=Promise.resolve();return e=e.then((()=>this.loadWidget(!1,!0))),e.catch((t=>{this.onLoadError(t)})),e}setParameters(t){this.parameters=Object.assign({},t),this.parameters.width=this.resolution.width,this.parameters.height=this.resolution.height;let e=Promise.resolve();return e=e.then((()=>this.loadWidget(!1,!0))),e.catch((t=>{this.onLoadError(t)})),e}setTags(t){this.tags=t,this.loadWidget(!1,!1)}async setView(t,e){let i=Promise.resolve();return(null==e?void 0:e.animation)&&(i=i.then((()=>this.loadAnimation(e.animation)))),this.view&&void 0!==(null==e?void 0:e.fromPosition)&&this.viewWidget instanceof F&&(i=i.then((()=>this.viewWidget.goto(e.fromPosition)))),(null==e?void 0:e.animation)&&(i=i.then((()=>this.widgetVideo.play()))),i=i.then((()=>{let i=!0;return this.view=Object.assign({},t),this.view&&this.viewWidget instanceof F&&void 0!==(null==e?void 0:e.toPosition)&&(i=!1,this.viewWidget.position=e.toPosition),this.loadWidget(i,!(e&&e.animation))})),i.catch((t=>{this.onLoadError(t)})),i}setVrcube(t){Object.assign(this.widgetVRCube,t)}setVrobject(t){Object.assign(this.widgetVRObject,t)}async loadAnimation(t){var e;const i={scene:this.scene,view:{animation:t.name,camera:t.camera,duration:t.duration,loop:t.loop,reverse:t.reverse},parameters:this.parameters,encoder:{format:"mp4"}};return(null===(e=i.view)||void 0===e?void 0:e.background)||(i.view.background="product"),this.widgetVideo.load(i).then((()=>Promise.resolve()))}async playAnimation(t){return this.loadAnimation(t).then((()=>this.widgetVideo.play())).catch((t=>{this.onLoadError(t)}))}stopAnimation(){this.widgetVideo.hide()}snapshot(t,e){return this.viewWidget.snapshot(t,e)}async loadWidget(t,e){if(!this.scene||!this.view)return Promise.resolve();if(!this.parameters.width||!this.parameters.height)return Promise.resolve();const i=this.viewWidget;if(!i)return Promise.reject(new Error("Unknown view mode"));const s={scene:this.scene,view:this.view,parameters:this.parameters,encoder:this.encoder};return s.view.background||(s.view.background="product"),i.load(s,this.tags||[],t,e).then((t=>{this.widget.hide(),this.widget=i,this.widget.show(),this.widgetVideo.hide(),this.onHotspotsChange(t)}))}get viewWidget(){var t;switch(null===(t=this.view)||void 0===t?void 0:t.mode){case"image":default:return this.widgetImage;case"video":return this.widgetVideo;case"vrcube":return this.widgetVRCube;case"vrobject":return this.widgetVRObject}}checkResize(){if(this.isDestroyed)return;const t=this.container.clientWidth,e=this.container.clientHeight;t===this.containerWidth&&e===this.containerHeight||(this.containerWidth=t,this.containerHeight=e,this.onResize()),this.isDestroyed||requestAnimationFrame(this.checkResize)}onMouseDown(t){this.widget.onMouseDown(t)}onMouseEnter(t){this.widget.onMouseEnter(t)}onMouseMove(t){this.widget.onMouseMove(t)}onMouseUp(t){this.widget.onMouseUp(t)}onTouchStart(t){this.widget.onTouchStart(t)}onTouchMove(t){this.widget.onTouchMove(t)}onTouchEnd(t){this.widget.onTouchEnd(t)}onDeviceOrientation(t){this.widget.onDeviceOrientation(t)}onResize(){const t=this.container.clientWidth,e=this.container.clientHeight;this.resolution=c.getStandardResolution(t*window.devicePixelRatio,e*window.devicePixelRatio),this.parameters.width=this.resolution.width,this.parameters.height=this.resolution.height,this.canvas2D.resize(t,e,window.devicePixelRatio),this.canvas3D.resize(t,e,window.devicePixelRatio),this.video.resize(t,e,this.resolution,this.options.fit),this.loadWidget(!1,!1).catch((t=>{this.onLoadError(t)}))}onVrcubeInteraction(...t){this.options.events.onHotspotsChange(this.widgetVRCube.hotspots),this.options.events.onInteraction(...t),this.options.events.onVrcubeInteraction(...t)}onVrobjectInteraction(...t){this.options.events.onHotspotsChange(this.widgetVRObject.hotspots),this.options.events.onInteraction(...t),this.options.events.onVrobjectInteraction(...t)}onHotspotsChange(...t){this.options.events.onHotspotsChange(...t)}onLoadStart(...t){this.container.classList.add("ls-viewer-container-loading"),this.options.events.onLoadStart(...t)}onLoadProgress(...t){this.options.events.onLoadProgress(...t)}onLoadEnd(...t){this.container.classList.remove("ls-viewer-container-loading"),this.options.events.onLoadEnd(...t)}onLoadError(...t){this.container.classList.remove("ls-viewer-container-loading"),this.options.events.onLoadError(...t)}},exports.WidgetImage=b,exports.WidgetVRCube=A,exports.WidgetVRObject=F,exports.WidgetVideo=y;
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

export declare type ImageScene = string;
export type ImageScene = string;
export interface WebRenderScene {

@@ -13,2 +13,2 @@ database: string;

}
export declare type Scene = ImageScene | WebRenderScene;
export type Scene = ImageScene | WebRenderScene;
{
"name": "@lumiscaphe/viewer",
"version": "4.0.7",
"version": "4.0.8",
"description": "Lumiscaphe 3D Viewer",

@@ -19,12 +19,16 @@ "main": "dist/index.js",

"regression": "~2.0.0",
"twgl.js": "~5.0.0"
"twgl.js": "~5.3.0"
},
"devDependencies": {
"@rollup/plugin-typescript": "~8.5.0",
"@rollup/plugin-commonjs": "~24.0.0",
"@rollup/plugin-eslint": "~9.0.0",
"@rollup/plugin-node-resolve": "~15.0.0",
"@rollup/plugin-terser": "~0.2.0",
"@rollup/plugin-typescript": "~10.0.0",
"@types/debounce-promise": "~3.1.3",
"@types/regression": "~2.0.0",
"@typescript-eslint/eslint-plugin": "~5.39.0",
"@typescript-eslint/parser": "~5.39.0",
"@typescript-eslint/eslint-plugin": "~5.47.0",
"@typescript-eslint/parser": "~5.47.0",
"cross-env": "~7.0.0",
"eslint": "~8.24.0",
"eslint": "~8.30.0",
"husky": "~8.0.0",

@@ -35,14 +39,10 @@ "postcss": "~8.4.0",

"rollup": "~2.79.0",
"rollup-plugin-commonjs": "~10.1.0",
"rollup-plugin-copy": "~3.4.0",
"rollup-plugin-eslint": "~7.0.0",
"rollup-plugin-glsl": "~1.3.0",
"rollup-plugin-node-resolve": "~5.2.0",
"rollup-plugin-postcss": "~4.0.0",
"rollup-plugin-terser": "~7.0.0",
"stylelint": "~14.13.0",
"stylelint-config-standard": "~28.0.0",
"typescript": "~4.8.0",
"typescript-plugin-css-modules": "3.4.0"
"stylelint": "~14.16.0",
"stylelint-config-standard": "~29.0.0",
"typescript": "~4.9.0",
"typescript-plugin-css-modules": "~4.1.0"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc