js-cloudimage-360-view 4.0.0-beta.7 → 4.0.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"canvas.worker-CauLFNM0.js","sources":["../src/canvas.worker.js","../src/utils/zoom/calculate-zoomed-dimensions.js","../src/utils/zoom/calculate-zoomed-offset.js"],"sourcesContent":["import { calculateZoomedDimensions, calculateZoomOffsets } from './utils';\n\nlet canvas, ctx, dpr, drawWidth, drawHeight, wideImage;\n\nself.onmessage = async (event) => {\n const {\n action,\n offscreen,\n devicePixelRatio,\n imageData,\n zoomScale,\n pointerX,\n pointerY,\n imageAspectRatio,\n containerWidth,\n containerHeight,\n } = event.data;\n\n switch (action) {\n case 'initCanvas':\n initCanvas(offscreen, devicePixelRatio);\n break;\n case 'adaptCanvasSize':\n adaptCanvasSize(imageAspectRatio, containerWidth, containerHeight);\n break;\n case 'drawImageOnCanvas':\n drawImageOnCanvas(imageData, zoomScale, pointerX, pointerY);\n break;\n default:\n break;\n }\n};\n\nconst initCanvas = (offscreenCanvas, devicePixelRatio) => {\n canvas = offscreenCanvas;\n ctx = canvas.getContext('2d');\n dpr = devicePixelRatio;\n};\n\nconst adaptCanvasSize = (imageAspectRatio, containerWidth, containerHeight) => {\n const containerAspectRatio = containerWidth / containerHeight;\n wideImage = imageAspectRatio > containerAspectRatio;\n\n canvas.width = containerWidth * dpr;\n canvas.height = containerHeight * dpr;\n ctx.scale(dpr, dpr);\n\n if (wideImage) {\n drawWidth = containerWidth;\n drawHeight = containerWidth / imageAspectRatio;\n } else {\n drawHeight = containerHeight;\n drawWidth = containerHeight * imageAspectRatio;\n }\n\n ctx.imageSmoothingEnabled = true;\n ctx.imageSmoothingQuality = 'high';\n};\n\n// Draw the image on the OffscreenCanvas\nconst drawImageOnCanvas = (imageData = {}, zoomScale = 1, pointerX = 0, pointerY = 0) => {\n const { bitmapImage } = imageData;\n if (!canvas || !bitmapImage) return;\n\n let offsetX, offsetY;\n if (wideImage) {\n offsetX = 0;\n offsetY = (canvas.height / dpr - drawHeight) / 2;\n } else {\n offsetX = (canvas.width / dpr - drawWidth) / 2;\n offsetY = 0;\n }\n\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n\n if (zoomScale !== 1) {\n const { zoomedWidth, zoomedHeight } = calculateZoomedDimensions(drawWidth, drawHeight, zoomScale);\n\n const { zoomOffsetX, zoomOffsetY } = calculateZoomOffsets({\n pointerX,\n pointerY,\n imageData,\n zoomedWidth,\n zoomedHeight,\n drawWidth,\n drawHeight,\n });\n\n ctx.drawImage(\n bitmapImage,\n zoomOffsetX,\n zoomOffsetY,\n zoomedWidth,\n zoomedHeight,\n offsetX,\n offsetY,\n drawWidth,\n drawHeight\n );\n } else {\n ctx.drawImage(bitmapImage, offsetX, offsetY, drawWidth, drawHeight);\n }\n};\n","export const calculateZoomedDimensions = (drawWidth, drawHeight, zoomScale) => {\n const zoomedWidth = drawWidth / zoomScale;\n const zoomedHeight = drawHeight / zoomScale;\n return { zoomedWidth, zoomedHeight };\n};\n","export const calculateZoomOffsets = ({\n pointerX,\n pointerY,\n imageData,\n zoomedWidth,\n zoomedHeight,\n drawWidth,\n drawHeight,\n}) => {\n const { naturalWidth, naturalHeight } = imageData;\n let zoomOffsetX = (pointerX / drawWidth) * naturalWidth - zoomedWidth / 2;\n let zoomOffsetY = (pointerY / drawHeight) * naturalHeight - zoomedHeight / 2;\n\n // Calculate max offset values\n const maxOffsetX = Math.max(0, naturalWidth - zoomedWidth);\n const maxOffsetY = Math.max(0, naturalHeight - zoomedHeight);\n\n // Clamp zoom offsets to the valid range\n zoomOffsetX = Math.max(0, Math.min(zoomOffsetX, maxOffsetX));\n zoomOffsetY = Math.max(0, Math.min(zoomOffsetY, maxOffsetY));\n\n return { zoomOffsetX, zoomOffsetY };\n};\n"],"names":["canvas","ctx","dpr","drawWidth","drawHeight","wideImage","self","onmessage","async","event","action","offscreen","devicePixelRatio","imageData","zoomScale","pointerX","pointerY","imageAspectRatio","containerWidth","containerHeight","data","initCanvas","adaptCanvasSize","drawImageOnCanvas","offscreenCanvas","getContext","width","height","scale","imageSmoothingEnabled","imageSmoothingQuality","bitmapImage","offsetX","offsetY","clearRect","zoomedWidth","zoomedHeight","calculateZoomedDimensions","zoomOffsetX","zoomOffsetY","naturalWidth","naturalHeight","maxOffsetX","Math","max","maxOffsetY","min","calculateZoomOffsets","drawImage"],"mappings":";;;;;;;;;yBAEA,IAAIA,EAAQC,EAAKC,EAAKC,EAAWC,EAAYC,EAExCC,KAAAC,UAAYC,MAAOC,IAChB,MAAAC,OACJA,EAAAC,UACAA,EAAAC,iBACAA,EAAAC,UACAA,EAAAC,UACAA,EAAAC,SACAA,EAAAC,SACAA,EAAAC,iBACAA,EAAAC,eACAA,EAAAC,gBACAA,GACEV,EAAMW,KAEV,OAAQV,GACN,IAAK,aACHW,EAAWV,EAAWC,GACtB,MACF,IAAK,kBACaU,EAAAL,EAAkBC,EAAgBC,GAClD,MACF,IAAK,oBACeI,EAAAV,EAAWC,EAAWC,EAAUC,GAIxD,EAGM,MAAAK,EAAa,CAACG,EAAiBZ,KAC1BZ,EAAAwB,EACHvB,EAAAD,EAAOyB,WAAW,MAClBvB,EAAAU,CAAA,EAGFU,EAAkB,CAACL,EAAkBC,EAAgBC,KAEzDd,EAAYY,EADiBC,EAAiBC,EAG9CnB,EAAO0B,MAAQR,EAAiBhB,EAChCF,EAAO2B,OAASR,EAAkBjB,EAC9BD,EAAA2B,MAAM1B,EAAKA,GAEXG,GACUF,EAAAe,EACZd,EAAac,EAAiBD,IAEjBb,EAAAe,EACbhB,EAAYgB,EAAkBF,GAGhChB,EAAI4B,uBAAwB,EAC5B5B,EAAI6B,sBAAwB,MAAA,EAIxBP,EAAoB,CAACV,EAAY,CAAA,EAAIC,EAAY,EAAGC,EAAW,EAAGC,EAAW,KAC3E,MAAAe,YAAEA,GAAgBlB,EACpB,IAACb,IAAW+B,EAAa,OAE7B,IAAIC,EAASC,EAWb,GAVI5B,GACQ2B,EAAA,EACCC,GAAAjC,EAAO2B,OAASzB,EAAME,GAAc,IAEpC4B,GAAAhC,EAAO0B,MAAQxB,EAAMC,GAAa,EACnC8B,EAAA,GAGZhC,EAAIiC,UAAU,EAAG,EAAGlC,EAAO0B,MAAO1B,EAAO2B,QAEvB,IAAdb,EAAiB,CACnB,MAAMqB,YAAEA,EAAaC,aAAAA,GC5EgB,EAACjC,EAAWC,EAAYU,KAGxD,CAAEqB,YAFWhC,EAAYW,EAEVsB,aADDhC,EAAaU,ID0EMuB,CAA0BlC,EAAWC,EAAYU,IAEjFwB,YAAEA,EAAAC,YAAaA,GE9EW,GAClCxB,WACAC,WACAH,YACAsB,cACAC,eACAjC,UAAAA,EACAC,WAAAA,MAEM,MAAAoC,aAAEA,EAAcC,cAAAA,GAAkB5B,EACxC,IAAIyB,EAAevB,EAAWZ,EAAaqC,EAAeL,EAAc,EACpEI,EAAevB,EAAWZ,EAAcqC,EAAgBL,EAAe,EAG3E,MAAMM,EAAaC,KAAKC,IAAI,EAAGJ,EAAeL,GACxCU,EAAaF,KAAKC,IAAI,EAAGH,EAAgBL,GAMxC,OAHPE,EAAcK,KAAKC,IAAI,EAAGD,KAAKG,IAAIR,EAAaI,IAChDH,EAAcI,KAAKC,IAAI,EAAGD,KAAKG,IAAIP,EAAaM,IAEzC,CAAEP,cAAaC,cAAa,EFyDIQ,CAAqB,CACxDhC,WACAC,WACAH,YACAsB,cACAC,eACAjC,YACAC,eAGEH,EAAA+C,UACFjB,EACAO,EACAC,EACAJ,EACAC,EACAJ,EACAC,EACA9B,EACAC,EAEN,MACIH,EAAI+C,UAAUjB,EAAaC,EAASC,EAAS9B,EAAWC,EAC5D"}
1
+ {"version":3,"file":"canvas.worker-B_m9quW5.js","sources":["../src/canvas.worker.js","../src/utils/zoom/calculate-zoomed-dimensions.js","../src/utils/zoom/calculate-zoomed-offset.js"],"sourcesContent":["import { calculateZoomedDimensions, calculateZoomOffsets } from './utils';\n\nlet canvas, ctx, dpr, drawWidth, drawHeight, wideImage;\n\nself.onmessage = async (event) => {\n const {\n action,\n offscreen,\n devicePixelRatio,\n imageData,\n zoomScale,\n pointerX,\n pointerY,\n imageAspectRatio,\n containerWidth,\n containerHeight,\n } = event.data;\n\n switch (action) {\n case 'initCanvas':\n initCanvas(offscreen, devicePixelRatio);\n break;\n case 'adaptCanvasSize':\n adaptCanvasSize(imageAspectRatio, containerWidth, containerHeight);\n break;\n case 'drawImageOnCanvas':\n drawImageOnCanvas(imageData, zoomScale, pointerX, pointerY);\n break;\n default:\n break;\n }\n};\n\nconst initCanvas = (offscreenCanvas, devicePixelRatio) => {\n canvas = offscreenCanvas;\n ctx = canvas.getContext('2d');\n dpr = devicePixelRatio;\n};\n\nconst adaptCanvasSize = (imageAspectRatio, containerWidth, containerHeight) => {\n const containerAspectRatio = containerWidth / containerHeight;\n wideImage = imageAspectRatio > containerAspectRatio;\n\n canvas.width = containerWidth * dpr;\n canvas.height = containerHeight * dpr;\n ctx.scale(dpr, dpr);\n\n if (wideImage) {\n drawWidth = containerWidth;\n drawHeight = containerWidth / imageAspectRatio;\n } else {\n drawHeight = containerHeight;\n drawWidth = containerHeight * imageAspectRatio;\n }\n\n ctx.imageSmoothingEnabled = true;\n ctx.imageSmoothingQuality = 'high';\n};\n\n// Draw the image on the OffscreenCanvas\nconst drawImageOnCanvas = (imageData = {}, zoomScale = 1, pointerX = 0, pointerY = 0) => {\n const { bitmapImage } = imageData;\n if (!canvas || !bitmapImage) return;\n\n let offsetX, offsetY;\n if (wideImage) {\n offsetX = 0;\n offsetY = (canvas.height / dpr - drawHeight) / 2;\n } else {\n offsetX = (canvas.width / dpr - drawWidth) / 2;\n offsetY = 0;\n }\n\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n\n if (zoomScale !== 1) {\n const { zoomedWidth, zoomedHeight } = calculateZoomedDimensions(drawWidth, drawHeight, zoomScale);\n\n const { zoomOffsetX, zoomOffsetY } = calculateZoomOffsets({\n pointerX,\n pointerY,\n imageData,\n zoomedWidth,\n zoomedHeight,\n drawWidth,\n drawHeight,\n });\n\n ctx.drawImage(\n bitmapImage,\n zoomOffsetX,\n zoomOffsetY,\n zoomedWidth,\n zoomedHeight,\n offsetX,\n offsetY,\n drawWidth,\n drawHeight\n );\n } else {\n ctx.drawImage(bitmapImage, offsetX, offsetY, drawWidth, drawHeight);\n }\n};\n","export const calculateZoomedDimensions = (drawWidth, drawHeight, zoomScale) => {\n const zoomedWidth = drawWidth / zoomScale;\n const zoomedHeight = drawHeight / zoomScale;\n return { zoomedWidth, zoomedHeight };\n};\n","export const calculateZoomOffsets = ({\n pointerX,\n pointerY,\n imageData,\n zoomedWidth,\n zoomedHeight,\n drawWidth,\n drawHeight,\n}) => {\n const { naturalWidth, naturalHeight } = imageData;\n let zoomOffsetX = (pointerX / drawWidth) * naturalWidth - zoomedWidth / 2;\n let zoomOffsetY = (pointerY / drawHeight) * naturalHeight - zoomedHeight / 2;\n\n // Calculate max offset values\n const maxOffsetX = Math.max(0, naturalWidth - zoomedWidth);\n const maxOffsetY = Math.max(0, naturalHeight - zoomedHeight);\n\n // Clamp zoom offsets to the valid range\n zoomOffsetX = Math.max(0, Math.min(zoomOffsetX, maxOffsetX));\n zoomOffsetY = Math.max(0, Math.min(zoomOffsetY, maxOffsetY));\n\n return { zoomOffsetX, zoomOffsetY };\n};\n"],"names":["canvas","ctx","dpr","drawWidth","drawHeight","wideImage","self","onmessage","async","event","action","offscreen","devicePixelRatio","imageData","zoomScale","pointerX","pointerY","imageAspectRatio","containerWidth","containerHeight","data","initCanvas","adaptCanvasSize","drawImageOnCanvas","offscreenCanvas","getContext","width","height","scale","imageSmoothingEnabled","imageSmoothingQuality","bitmapImage","offsetX","offsetY","clearRect","zoomedWidth","zoomedHeight","calculateZoomedDimensions","zoomOffsetX","zoomOffsetY","naturalWidth","naturalHeight","maxOffsetX","Math","max","maxOffsetY","min","calculateZoomOffsets","drawImage"],"mappings":"yBAEA,IAAIA,EAAQC,EAAKC,EAAKC,EAAWC,EAAYC,EAExCC,KAAAC,UAAYC,MAAOC,IAChB,MAAAC,OACJA,EAAAC,UACAA,EAAAC,iBACAA,EAAAC,UACAA,EAAAC,UACAA,EAAAC,SACAA,EAAAC,SACAA,EAAAC,iBACAA,EAAAC,eACAA,EAAAC,gBACAA,GACEV,EAAMW,KAEV,OAAQV,GACN,IAAK,aACHW,EAAWV,EAAWC,GACtB,MACF,IAAK,kBACaU,EAAAL,EAAkBC,EAAgBC,GAClD,MACF,IAAK,oBACeI,EAAAV,EAAWC,EAAWC,EAAUC,GAIxD,EAGM,MAAAK,EAAa,CAACG,EAAiBZ,KAC1BZ,EAAAwB,EACHvB,EAAAD,EAAOyB,WAAW,MAClBvB,EAAAU,CAAA,EAGFU,EAAkB,CAACL,EAAkBC,EAAgBC,KAEzDd,EAAYY,EADiBC,EAAiBC,EAG9CnB,EAAO0B,MAAQR,EAAiBhB,EAChCF,EAAO2B,OAASR,EAAkBjB,EAC9BD,EAAA2B,MAAM1B,EAAKA,GAEXG,GACUF,EAAAe,EACZd,EAAac,EAAiBD,IAEjBb,EAAAe,EACbhB,EAAYgB,EAAkBF,GAGhChB,EAAI4B,uBAAwB,EAC5B5B,EAAI6B,sBAAwB,MAAA,EAIxBP,EAAoB,CAACV,EAAY,CAAA,EAAIC,EAAY,EAAGC,EAAW,EAAGC,EAAW,KAC3E,MAAAe,YAAEA,GAAgBlB,EACpB,IAACb,IAAW+B,EAAa,OAE7B,IAAIC,EAASC,EAWb,GAVI5B,GACQ2B,EAAA,EACCC,GAAAjC,EAAO2B,OAASzB,EAAME,GAAc,IAEpC4B,GAAAhC,EAAO0B,MAAQxB,EAAMC,GAAa,EACnC8B,EAAA,GAGZhC,EAAIiC,UAAU,EAAG,EAAGlC,EAAO0B,MAAO1B,EAAO2B,QAEvB,IAAdb,EAAiB,CACnB,MAAMqB,YAAEA,EAAaC,aAAAA,GC5EgB,EAACjC,EAAWC,EAAYU,KAGxD,CAAEqB,YAFWhC,EAAYW,EAEVsB,aADDhC,EAAaU,ID0EMuB,CAA0BlC,EAAWC,EAAYU,IAEjFwB,YAAEA,EAAAC,YAAaA,GE9EW,GAClCxB,WACAC,WACAH,YACAsB,cACAC,eACAjC,UAAAA,EACAC,WAAAA,MAEM,MAAAoC,aAAEA,EAAcC,cAAAA,GAAkB5B,EACxC,IAAIyB,EAAevB,EAAWZ,EAAaqC,EAAeL,EAAc,EACpEI,EAAevB,EAAWZ,EAAcqC,EAAgBL,EAAe,EAG3E,MAAMM,EAAaC,KAAKC,IAAI,EAAGJ,EAAeL,GACxCU,EAAaF,KAAKC,IAAI,EAAGH,EAAgBL,GAMxC,OAHPE,EAAcK,KAAKC,IAAI,EAAGD,KAAKG,IAAIR,EAAaI,IAChDH,EAAcI,KAAKC,IAAI,EAAGD,KAAKG,IAAIP,EAAaM,IAEzC,CAAEP,cAAaC,cAAa,EFyDIQ,CAAqB,CACxDhC,WACAC,WACAH,YACAsB,cACAC,eACAjC,YACAC,eAGEH,EAAA+C,UACFjB,EACAO,EACAC,EACAJ,EACAC,EACAJ,EACAC,EACA9B,EACAC,EAEN,MACIH,EAAI+C,UAAUjB,EAAaC,EAASC,EAAS9B,EAAWC,EAC5D"}
@@ -1,10 +1 @@
1
-
2
- js-cloudimage-360-view v4.0.0-beta.6
3
- https://github.com/scaleflex/js-cloudimage-360-view
4
-
5
- Copyright (c) 2024 scaleflex
6
- Released under the MIT license
7
-
8
- Date: 2024-10-30T12:29:01.787Z
9
-
10
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Cloudimage360View=t()}(this,(function(){"use strict";var e=Object.defineProperty,t=(t,i,n)=>((t,i,n)=>i in t?e(t,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[i]=n)(t,"symbol"!=typeof i?i+"":i,n),i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var o="Expected a function",s=/^\s+|\s+$/g,a=/^[-+]0x[0-9a-f]+$/i,r=/^0b[01]+$/i,l=/^0o[0-7]+$/i,c=parseInt,h="object"==typeof i&&i&&i.Object===Object&&i,d="object"==typeof self&&self&&self.Object===Object&&self,p=h||d||Function("return this")(),u=Object.prototype.toString,f=Math.max,m=Math.min,g=function(){return p.Date.now()};function v(e,t,i){var n,s,a,r,l,c,h=0,d=!1,p=!1,u=!0;if("function"!=typeof e)throw new TypeError(o);function v(t){var i=n,o=s;return n=s=void 0,h=t,r=e.apply(o,i)}function w(e){var i=e-c;return void 0===c||i>=t||i<0||p&&e-h>=a}function x(){var e=g();if(w(e))return I(e);l=setTimeout(x,function(e){var i=t-(e-c);return p?m(i,a-(e-h)):i}(e))}function I(e){return l=void 0,u&&n?v(e):(n=s=void 0,r)}function C(){var e=g(),i=w(e);if(n=arguments,s=this,c=e,i){if(void 0===l)return function(e){return h=e,l=setTimeout(x,t),d?v(e):r}(c);if(p)return l=setTimeout(x,t),v(c)}return void 0===l&&(l=setTimeout(x,t)),r}return t=b(t)||0,y(i)&&(d=!!i.leading,a=(p="maxWait"in i)?f(b(i.maxWait)||0,t):a,u="trailing"in i?!!i.trailing:u),C.cancel=function(){void 0!==l&&clearTimeout(l),h=0,n=c=s=l=void 0},C.flush=function(){return void 0===l?r:I(g())},C}function y(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function b(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==u.call(e)}(e))return NaN;if(y(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=y(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(s,"");var i=r.test(e);return i||l.test(e)?c(e.slice(2),i?2:8):a.test(e)?NaN:+e}const w=n((function(e,t,i){var n=!0,s=!0;if("function"!=typeof e)throw new TypeError(o);return y(i)&&(n="leading"in i?!!i.leading:n,s="trailing"in i?!!i.trailing:s),v(e,t,{leading:n,maxWait:t,trailing:s})})),x="spin-x",I="spin-y",C="spin-xy",L="spin-yx",O=[!1,0,null,void 0,"false","0","null","undefined"],Y="x-axis",k="y-axis",S=["folder","folderX","folderY","filenameX","filenameY","imageListX","imageListY","indexZeroBase","amountX","amountY"],R=[37,39],X=[38,40],E={folder:"/",apiVersion:"v7",filenameX:"image-{index}.jpg",filenameY:null,imageListX:null,imageListY:null,indexZeroBase:0,amountX:0,amountY:0,speed:80,dragSpeed:150,draggable:!0,swipeable:!0,keys:!1,keysReverse:!1,autoplay:!1,autoplayBehavior:x,playOnce:!1,autoplayReverse:!1,pointerZoom:0,fullscreen:!1,magnifier:null,bottomCircle:!0,bottomCircleOffset:5,ciToken:null,ciFilters:null,ciTransformation:null,lazyload:!0,dragReverse:!1,stopAtEdges:!1,imageInfo:!1,initialIconShown:!0,hotspots:null},T=(e,t,i)=>e.getAttribute(t)||e.getAttribute(`data-${t}`)||i,Z=(e,t,i)=>e.hasAttribute(t)||e.hasAttribute(`data-${t}`)||i,A=(e,t)=>"false"===T(e,t,null),H=(e,t)=>{const{folder:i,apiVersion:n,filename:o="",ciParams:s}=e,{ciToken:a,ciFilters:r,ciTransformation:l}=s||{},c=`${i}${o}`;if(!a)return c;const h=O.includes(n)?null:n,d=h?`${h}/`:"",p=((e=1)=>{const t=Math.round(window.devicePixelRatio||1);return parseInt(e)*t})(t),u=((e,t,i)=>new URL(e).origin.includes("cloudimg")?e:`https://${t}.cloudimg.io/${i}${e}`)(c,a,d),f=(({ciTransformation:e,responsiveWidth:t,ciFilters:i})=>`${e||`width=${t}`}${i?`&f=${i}`:""}`)({ciTransformation:l,responsiveWidth:p,ciFilters:r});return`${u}${f?"?":""}${f}`},W=(e,t)=>((e,t,i)=>{const[n,o]=e.split("?"),s=`${t}=${encodeURIComponent(i)}`;if(!o)return`${n}?${s}`;const a=new URLSearchParams(o);return a.set(t,i),`${n}?${a.toString()}`})(e,"width",t),M=(e,t=0)=>(e+="").length>=t?e:new Array(t-e.length+1).join("0")+e,B=({cdnPathX:e,cdnPathY:t,configX:i,configY:n,onFirstImageLoad:o,onImageLoad:s,onAllImagesLoad:a})=>{let r={x:!1,y:!1},l=[],c=[];const h=e||i.imageList.length,d=t||n.imageList.length,p=({cdnPath:e,config:t,orientation:i,loadedImages:n,onFirstImageLoad:o})=>{const h=i===Y,d=t.imageList.length?t.imageList:((e,{amount:t=0,indexZeroBase:i=0}={})=>Array.from({length:t},((t,n)=>e.replace("{index}",M(n+1,i)))))(e,t);(({imagesUrls:e,onFirstImageLoad:t,onImageLoad:i,onAllImagesLoad:n,autoplayReverse:o})=>{let s=0;const a=e.length,r=[],l=(e,t)=>{const o=new Image;o.crossOrigin="anonymous",o.src=e,o.onload=async()=>{const l=await createImageBitmap(o),h={src:e,bitmapImage:l,naturalWidth:c.naturalWidth,naturalHeight:c.naturalHeight};s++,r[t]=h,null==i||i(h,t),s===a&&(null==n||n(r))},o.onerror=()=>{console.error(`Failed to load image: ${e}`),s++,s===a&&(null==n||n(r))}},c=new Image,h=e[o?e.length-1:0];c.crossOrigin="anonymous",c.src=h,c.onload=async()=>{const n=await createImageBitmap(c),o={src:h,bitmapImage:n,naturalWidth:c.naturalWidth,naturalHeight:c.naturalHeight};r[0]=o,s++,null==t||t(o),null==i||i(o,0);for(let t=1;t<e.length;t++)l(e[t],t)},c.onerror=()=>{console.error(`Failed to load first image: ${e[0]}`),s++;for(let t=1;t<e.length;t++)l(e[t],t)}})({imagesUrls:d,onFirstImageLoad:o,onImageLoad:(e,t)=>{null==s||s(e,t,i),n[t]=e},onAllImagesLoad:e=>{n=e,r[h?"x":"y"]=!0,r.x&&r.y&&a(l,c)},autoplayReverse:t.autoplayReverse})};h?p({cdnPath:e,config:i,orientation:Y,loadedImages:l,onFirstImageLoad:o}):r.x=!0,d?p({cdnPath:t,config:n,orientation:k,loadedImages:c,onFirstImageLoad:h?void 0:o}):r.y=!0},P=e=>{const t=document.createElement("div");return t.className="cloudimage-360-icons-container",e.appendChild(t),t},j=(e,t)=>{const i=e.querySelector(t);i&&i.parentNode.removeChild(i)},V=e=>{const t=((e,t)=>{const[i,n]=e.split("?");if(!n)return e;const o=new RegExp(`^${t}=|&${t}=`),s=n.split("&").filter((e=>!o.test(e))).join("&");return s?`${i}?${s}`:i})(e,"width"),i=t.includes("?")?"&":"?";return`${t}${i}width=${150*devicePixelRatio}`},D=(e,t)=>{const{imageList:i,indexZeroBase:n}=t;if(i.length)try{return((e,t)=>{const[i]=e,n=/(https?):\/\//i.test(i);return H({...t,folder:n?"":t.folder,filename:i})})(JSON.parse(i),t)}catch(o){console.error(`Wrong format in image-list attribute: ${o.message}`)}return((e,t)=>{const i=M(1,t);return e.replace("{index}",i)})(e,n)},F=(e,t,i)=>{const n=new Image;return n.setAttribute(t?"data-src":"src",e),n.className=i,n.style.cssText=`\n position: ${t?"absolute":"static"};\n width: 100%;\n inset: 0;\n height: 100%;\n object-fit: contain;\n object-position: center;\n filter: blur(10px);\n `,n},G=(e,t,i)=>{const{innerBox:n,imageList:o,lazyload:s}=t||{},[a]=o,r=a||D(e,t),l=V(r),c=F(l,s,"cloudimage-lazy"),h=F(l,!1,"cloudimage-360-placeholder");var d;c.onload=e=>{j(n,".cloudimage-lazy"),i&&i({event:e,width:c.width,height:c.height,naturalWidth:c.naturalWidth,naturalHeight:c.naturalHeight,src:l})},n.appendChild(c),n.appendChild(h),d=c,new IntersectionObserver(((e,t)=>{e.forEach((e=>{e.isIntersecting&&((e=>{const t=e.getAttribute("data-src");t&&(e.src=t)})(e.target),t.unobserve(e.target))}))}),{root:null,rootMargin:"0px",threshold:.1}).observe(d)},z=(e,t,i)=>{const{container:n,w:o,h:s,zoom:a,bw:r,offsetX:l,offsetY:c}=t,h=((e,t)=>{const i=t.getBoundingClientRect(),n=e.touches?e.touches[0].clientX:e.clientX,o=e.touches?e.touches[0].clientY:e.clientY;return{x:n-i.left,y:o-i.top}})(e,n);let d=h.x,p=h.y;d=Math.max(o/a,Math.min(d,n.offsetWidth-o/a)),p=Math.max(s/a,Math.min(p,n.offsetHeight-s/a)),i.style.left=d-o+"px",i.style.top=p-s+"px";const u=(d-l)*a-o+r,f=(p-c)*a-s+r;i.style.backgroundPosition=`-${u}px -${f}px`},N=(e,{bottom:t,top:i})=>{e?t():i()},U=(e,{left:t,right:i})=>{e?t():i()},$=(e,t)=>{const i=[...R];return t?[...i,...X].includes(e):i.includes(e)},K=(e,t=150)=>{let i;return function(...n){clearTimeout(i),i=setTimeout((()=>{e.apply(this,n)}),t)}},Q="CiBqcy1jbG91ZGltYWdlLTM2MC12aWV3IHY0LjAuMC1iZXRhLjYKIGh0dHBzOi8vZ2l0aHViLmNvbS9zY2FsZWZsZXgvanMtY2xvdWRpbWFnZS0zNjAtdmlldwoKIENvcHlyaWdodCAoYykgMjAyNCBzY2FsZWZsZXgKIFJlbGVhc2VkIHVuZGVyIHRoZSBNSVQgbGljZW5zZQoKIERhdGU6IDIwMjQtMTAtMzBUMTI6Mjk6MDEuNzg3WgoKIWZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2xldCB0LGUsYSxpLG8sbjtzZWxmLm9ubWVzc2FnZT1hc3luYyB0PT57Y29uc3R7YWN0aW9uOmUsb2Zmc2NyZWVuOmEsZGV2aWNlUGl4ZWxSYXRpbzppLGltYWdlRGF0YTpvLHpvb21TY2FsZTpuLHBvaW50ZXJYOnMscG9pbnRlclk6ZyxpbWFnZUFzcGVjdFJhdGlvOnIsY29udGFpbmVyV2lkdGg6Yyxjb250YWluZXJIZWlnaHQ6Zn09dC5kYXRhO3N3aXRjaChlKXtjYXNlImluaXRDYW52YXMiOmgoYSxpKTticmVhaztjYXNlImFkYXB0Q2FudmFzU2l6ZSI6bShyLGMsZik7YnJlYWs7Y2FzZSJkcmF3SW1hZ2VPbkNhbnZhcyI6ZChvLG4scyxnKX19O2NvbnN0IGg9KGksbyk9Pnt0PWksZT10LmdldENvbnRleHQoIjJkIiksYT1vfSxtPShoLG0sZCk9PntuPWg+bS9kLHQud2lkdGg9bSphLHQuaGVpZ2h0PWQqYSxlLnNjYWxlKGEsYSksbj8oaT1tLG89bS9oKToobz1kLGk9ZCpoKSxlLmltYWdlU21vb3RoaW5nRW5hYmxlZD0hMCxlLmltYWdlU21vb3RoaW5nUXVhbGl0eT0iaGlnaCJ9LGQ9KGg9e30sbT0xLGQ9MCxzPTApPT57Y29uc3R7Yml0bWFwSW1hZ2U6Z309aDtpZighdHx8IWcpcmV0dXJuO2xldCByLGM7aWYobj8ocj0wLGM9KHQuaGVpZ2h0L2EtbykvMik6KHI9KHQud2lkdGgvYS1pKS8yLGM9MCksZS5jbGVhclJlY3QoMCwwLHQud2lkdGgsdC5oZWlnaHQpLDEhPT1tKXtjb25zdHt6b29tZWRXaWR0aDp0LHpvb21lZEhlaWdodDphfT0oKHQsZSxhKT0+KHt6b29tZWRXaWR0aDp0L2Esem9vbWVkSGVpZ2h0OmUvYX0pKShpLG8sbSkse3pvb21PZmZzZXRYOm4sem9vbU9mZnNldFk6Zn09KCh7cG9pbnRlclg6dCxwb2ludGVyWTplLGltYWdlRGF0YTphLHpvb21lZFdpZHRoOmksem9vbWVkSGVpZ2h0Om8sZHJhd1dpZHRoOm4sZHJhd0hlaWdodDpofSk9Pntjb25zdHtuYXR1cmFsV2lkdGg6bSxuYXR1cmFsSGVpZ2h0OmR9PWE7bGV0IHM9dC9uKm0taS8yLGc9ZS9oKmQtby8yO2NvbnN0IHI9TWF0aC5tYXgoMCxtLWkpLGM9TWF0aC5tYXgoMCxkLW8pO3JldHVybiBzPU1hdGgubWF4KDAsTWF0aC5taW4ocyxyKSksZz1NYXRoLm1heCgwLE1hdGgubWluKGcsYykpLHt6b29tT2Zmc2V0WDpzLHpvb21PZmZzZXRZOmd9fSkoe3BvaW50ZXJYOmQscG9pbnRlclk6cyxpbWFnZURhdGE6aCx6b29tZWRXaWR0aDp0LHpvb21lZEhlaWdodDphLGRyYXdXaWR0aDppLGRyYXdIZWlnaHQ6b30pO2UuZHJhd0ltYWdlKGcsbixmLHQsYSxyLGMsaSxvKX1lbHNlIGUuZHJhd0ltYWdlKGcscixjLGksbyl9fSgpOwo=",q="undefined"!=typeof self&&self.Blob&&new Blob([(J=Q,Uint8Array.from(atob(J),(e=>e.charCodeAt(0))))],{type:"text/javascript;charset=utf-8"});var J;function _(e){let t;try{if(t=q&&(self.URL||self.webkitURL).createObjectURL(q),!t)throw"";const i=new Worker(t,{name:null==e?void 0:e.name});return i.addEventListener("error",(()=>{(self.URL||self.webkitURL).revokeObjectURL(t)})),i}catch(i){return new Worker("data:text/javascript;base64,"+Q,{name:null==e?void 0:e.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}const ee=(e,t,i)=>e.filter((e=>(e=>"x"===e?Y:k)(e.orientation)===i&&t in e.positions)),te=e=>{const t=Object.entries(e).sort((([e],[t])=>Number(e)-Number(t)));let i=null,n=null;const o={};for(const[s,a]of t)if(a){const{x:e,y:t}=a;null!=e&&(i=e),null!=t&&(n=t),o[s]={x:e||i,y:t||n}}else o[s]={x:i,y:n};return o};var ie="top",ne="bottom",oe="right",se="left",ae="auto",re=[ie,ne,oe,se],le="start",ce="end",he="viewport",de="popper",pe=re.reduce((function(e,t){return e.concat([t+"-"+le,t+"-"+ce])}),[]),ue=[].concat(re,[ae]).reduce((function(e,t){return e.concat([t,t+"-"+le,t+"-"+ce])}),[]),fe=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function me(e){return e?(e.nodeName||"").toLowerCase():null}function ge(e){if(null==e)return window;if("[object Window]"!==e.toString()){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function ve(e){return e instanceof ge(e).Element||e instanceof Element}function ye(e){return e instanceof ge(e).HTMLElement||e instanceof HTMLElement}function be(e){return"undefined"!=typeof ShadowRoot&&(e instanceof ge(e).ShadowRoot||e instanceof ShadowRoot)}const we={name:"applyStyles",enabled:!0,phase:"write",fn:function(e){var t=e.state;Object.keys(t.elements).forEach((function(e){var i=t.styles[e]||{},n=t.attributes[e]||{},o=t.elements[e];ye(o)&&me(o)&&(Object.assign(o.style,i),Object.keys(n).forEach((function(e){var t=n[e];!1===t?o.removeAttribute(e):o.setAttribute(e,!0===t?"":t)})))}))},effect:function(e){var t=e.state,i={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,i.popper),t.styles=i,t.elements.arrow&&Object.assign(t.elements.arrow.style,i.arrow),function(){Object.keys(t.elements).forEach((function(e){var n=t.elements[e],o=t.attributes[e]||{},s=Object.keys(t.styles.hasOwnProperty(e)?t.styles[e]:i[e]).reduce((function(e,t){return e[t]="",e}),{});ye(n)&&me(n)&&(Object.assign(n.style,s),Object.keys(o).forEach((function(e){n.removeAttribute(e)})))}))}},requires:["computeStyles"]};function xe(e){return e.split("-")[0]}var Ie=Math.max,Ce=Math.min,Le=Math.round;function Oe(){var e=navigator.userAgentData;return null!=e&&e.brands&&Array.isArray(e.brands)?e.brands.map((function(e){return e.brand+"/"+e.version})).join(" "):navigator.userAgent}function Ye(){return!/^((?!chrome|android).)*safari/i.test(Oe())}function ke(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=!1);var n=e.getBoundingClientRect(),o=1,s=1;t&&ye(e)&&(o=e.offsetWidth>0&&Le(n.width)/e.offsetWidth||1,s=e.offsetHeight>0&&Le(n.height)/e.offsetHeight||1);var a=(ve(e)?ge(e):window).visualViewport,r=!Ye()&&i,l=(n.left+(r&&a?a.offsetLeft:0))/o,c=(n.top+(r&&a?a.offsetTop:0))/s,h=n.width/o,d=n.height/s;return{width:h,height:d,top:c,right:l+h,bottom:c+d,left:l,x:l,y:c}}function Se(e){var t=ke(e),i=e.offsetWidth,n=e.offsetHeight;return Math.abs(t.width-i)<=1&&(i=t.width),Math.abs(t.height-n)<=1&&(n=t.height),{x:e.offsetLeft,y:e.offsetTop,width:i,height:n}}function Re(e,t){var i=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(i&&be(i)){var n=t;do{if(n&&e.isSameNode(n))return!0;n=n.parentNode||n.host}while(n)}return!1}function Xe(e){return ge(e).getComputedStyle(e)}function Ee(e){return["table","td","th"].indexOf(me(e))>=0}function Te(e){return((ve(e)?e.ownerDocument:e.document)||window.document).documentElement}function Ze(e){return"html"===me(e)?e:e.assignedSlot||e.parentNode||(be(e)?e.host:null)||Te(e)}function Ae(e){return ye(e)&&"fixed"!==Xe(e).position?e.offsetParent:null}function He(e){for(var t=ge(e),i=Ae(e);i&&Ee(i)&&"static"===Xe(i).position;)i=Ae(i);return i&&("html"===me(i)||"body"===me(i)&&"static"===Xe(i).position)?t:i||function(e){var t=/firefox/i.test(Oe());if(/Trident/i.test(Oe())&&ye(e)&&"fixed"===Xe(e).position)return null;var i=Ze(e);for(be(i)&&(i=i.host);ye(i)&&["html","body"].indexOf(me(i))<0;){var n=Xe(i);if("none"!==n.transform||"none"!==n.perspective||"paint"===n.contain||-1!==["transform","perspective"].indexOf(n.willChange)||t&&"filter"===n.willChange||t&&n.filter&&"none"!==n.filter)return i;i=i.parentNode}return null}(e)||t}function We(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function Me(e,t,i){return Ie(e,Ce(t,i))}function Be(e){return Object.assign({},{top:0,right:0,bottom:0,left:0},e)}function Pe(e,t){return t.reduce((function(t,i){return t[i]=e,t}),{})}function je(e){return e.split("-")[1]}var Ve={top:"auto",right:"auto",bottom:"auto",left:"auto"};function De(e){var t,i=e.popper,n=e.popperRect,o=e.placement,s=e.variation,a=e.offsets,r=e.position,l=e.gpuAcceleration,c=e.adaptive,h=e.roundOffsets,d=e.isFixed,p=a.x,u=void 0===p?0:p,f=a.y,m=void 0===f?0:f,g="function"==typeof h?h({x:u,y:m}):{x:u,y:m};u=g.x,m=g.y;var v=a.hasOwnProperty("x"),y=a.hasOwnProperty("y"),b=se,w=ie,x=window;if(c){var I=He(i),C="clientHeight",L="clientWidth";if(I===ge(i)&&"static"!==Xe(I=Te(i)).position&&"absolute"===r&&(C="scrollHeight",L="scrollWidth"),o===ie||(o===se||o===oe)&&s===ce)w=ne,m-=(d&&I===x&&x.visualViewport?x.visualViewport.height:I[C])-n.height,m*=l?1:-1;if(o===se||(o===ie||o===ne)&&s===ce)b=oe,u-=(d&&I===x&&x.visualViewport?x.visualViewport.width:I[L])-n.width,u*=l?1:-1}var O,Y=Object.assign({position:r},c&&Ve),k=!0===h?function(e,t){var i=e.x,n=e.y,o=t.devicePixelRatio||1;return{x:Le(i*o)/o||0,y:Le(n*o)/o||0}}({x:u,y:m},ge(i)):{x:u,y:m};return u=k.x,m=k.y,l?Object.assign({},Y,((O={})[w]=y?"0":"",O[b]=v?"0":"",O.transform=(x.devicePixelRatio||1)<=1?"translate("+u+"px, "+m+"px)":"translate3d("+u+"px, "+m+"px, 0)",O)):Object.assign({},Y,((t={})[w]=y?m+"px":"",t[b]=v?u+"px":"",t.transform="",t))}var Fe={passive:!0};var Ge={left:"right",right:"left",bottom:"top",top:"bottom"};function ze(e){return e.replace(/left|right|bottom|top/g,(function(e){return Ge[e]}))}var Ne={start:"end",end:"start"};function Ue(e){return e.replace(/start|end/g,(function(e){return Ne[e]}))}function $e(e){var t=ge(e);return{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function Ke(e){return ke(Te(e)).left+$e(e).scrollLeft}function Qe(e){var t=Xe(e),i=t.overflow,n=t.overflowX,o=t.overflowY;return/auto|scroll|overlay|hidden/.test(i+o+n)}function qe(e){return["html","body","#document"].indexOf(me(e))>=0?e.ownerDocument.body:ye(e)&&Qe(e)?e:qe(Ze(e))}function Je(e,t){var i;void 0===t&&(t=[]);var n=qe(e),o=n===(null==(i=e.ownerDocument)?void 0:i.body),s=ge(n),a=o?[s].concat(s.visualViewport||[],Qe(n)?n:[]):n,r=t.concat(a);return o?r:r.concat(Je(Ze(a)))}function _e(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function et(e,t,i){return t===he?_e(function(e,t){var i=ge(e),n=Te(e),o=i.visualViewport,s=n.clientWidth,a=n.clientHeight,r=0,l=0;if(o){s=o.width,a=o.height;var c=Ye();(c||!c&&"fixed"===t)&&(r=o.offsetLeft,l=o.offsetTop)}return{width:s,height:a,x:r+Ke(e),y:l}}(e,i)):ve(t)?function(e,t){var i=ke(e,!1,"fixed"===t);return i.top=i.top+e.clientTop,i.left=i.left+e.clientLeft,i.bottom=i.top+e.clientHeight,i.right=i.left+e.clientWidth,i.width=e.clientWidth,i.height=e.clientHeight,i.x=i.left,i.y=i.top,i}(t,i):_e(function(e){var t,i=Te(e),n=$e(e),o=null==(t=e.ownerDocument)?void 0:t.body,s=Ie(i.scrollWidth,i.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),a=Ie(i.scrollHeight,i.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),r=-n.scrollLeft+Ke(e),l=-n.scrollTop;return"rtl"===Xe(o||i).direction&&(r+=Ie(i.clientWidth,o?o.clientWidth:0)-s),{width:s,height:a,x:r,y:l}}(Te(e)))}function tt(e,t,i,n){var o="clippingParents"===t?function(e){var t=Je(Ze(e)),i=["absolute","fixed"].indexOf(Xe(e).position)>=0&&ye(e)?He(e):e;return ve(i)?t.filter((function(e){return ve(e)&&Re(e,i)&&"body"!==me(e)})):[]}(e):[].concat(t),s=[].concat(o,[i]),a=s[0],r=s.reduce((function(t,i){var o=et(e,i,n);return t.top=Ie(o.top,t.top),t.right=Ce(o.right,t.right),t.bottom=Ce(o.bottom,t.bottom),t.left=Ie(o.left,t.left),t}),et(e,a,n));return r.width=r.right-r.left,r.height=r.bottom-r.top,r.x=r.left,r.y=r.top,r}function it(e){var t,i=e.reference,n=e.element,o=e.placement,s=o?xe(o):null,a=o?je(o):null,r=i.x+i.width/2-n.width/2,l=i.y+i.height/2-n.height/2;switch(s){case ie:t={x:r,y:i.y-n.height};break;case ne:t={x:r,y:i.y+i.height};break;case oe:t={x:i.x+i.width,y:l};break;case se:t={x:i.x-n.width,y:l};break;default:t={x:i.x,y:i.y}}var c=s?We(s):null;if(null!=c){var h="y"===c?"height":"width";switch(a){case le:t[c]=t[c]-(i[h]/2-n[h]/2);break;case ce:t[c]=t[c]+(i[h]/2-n[h]/2)}}return t}function nt(e,t){void 0===t&&(t={});var i=t,n=i.placement,o=void 0===n?e.placement:n,s=i.strategy,a=void 0===s?e.strategy:s,r=i.boundary,l=void 0===r?"clippingParents":r,c=i.rootBoundary,h=void 0===c?he:c,d=i.elementContext,p=void 0===d?de:d,u=i.altBoundary,f=void 0!==u&&u,m=i.padding,g=void 0===m?0:m,v=Be("number"!=typeof g?g:Pe(g,re)),y=p===de?"reference":de,b=e.rects.popper,w=e.elements[f?y:p],x=tt(ve(w)?w:w.contextElement||Te(e.elements.popper),l,h,a),I=ke(e.elements.reference),C=it({reference:I,element:b,strategy:"absolute",placement:o}),L=_e(Object.assign({},b,C)),O=p===de?L:I,Y={top:x.top-O.top+v.top,bottom:O.bottom-x.bottom+v.bottom,left:x.left-O.left+v.left,right:O.right-x.right+v.right},k=e.modifiersData.offset;if(p===de&&k){var S=k[o];Object.keys(Y).forEach((function(e){var t=[oe,ne].indexOf(e)>=0?1:-1,i=[ie,ne].indexOf(e)>=0?"y":"x";Y[e]+=S[i]*t}))}return Y}function ot(e,t,i){return void 0===i&&(i={x:0,y:0}),{top:e.top-t.height-i.y,right:e.right-t.width+i.x,bottom:e.bottom-t.height+i.y,left:e.left-t.width-i.x}}function st(e){return[ie,oe,ne,se].some((function(t){return e[t]>=0}))}function at(e,t,i){void 0===i&&(i=!1);var n,o,s=ye(t),a=ye(t)&&function(e){var t=e.getBoundingClientRect(),i=Le(t.width)/e.offsetWidth||1,n=Le(t.height)/e.offsetHeight||1;return 1!==i||1!==n}(t),r=Te(t),l=ke(e,a,i),c={scrollLeft:0,scrollTop:0},h={x:0,y:0};return(s||!s&&!i)&&(("body"!==me(t)||Qe(r))&&(c=(n=t)!==ge(n)&&ye(n)?{scrollLeft:(o=n).scrollLeft,scrollTop:o.scrollTop}:$e(n)),ye(t)?((h=ke(t,!0)).x+=t.clientLeft,h.y+=t.clientTop):r&&(h.x=Ke(r))),{x:l.left+c.scrollLeft-h.x,y:l.top+c.scrollTop-h.y,width:l.width,height:l.height}}function rt(e){var t=new Map,i=new Set,n=[];function o(e){i.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach((function(e){if(!i.has(e)){var n=t.get(e);n&&o(n)}})),n.push(e)}return e.forEach((function(e){t.set(e.name,e)})),e.forEach((function(e){i.has(e.name)||o(e)})),n}var lt={placement:"bottom",modifiers:[],strategy:"absolute"};function ct(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return!t.some((function(e){return!(e&&"function"==typeof e.getBoundingClientRect)}))}function ht(e){void 0===e&&(e={});var t=e,i=t.defaultModifiers,n=void 0===i?[]:i,o=t.defaultOptions,s=void 0===o?lt:o;return function(e,t,i){void 0===i&&(i=s);var o,a,r={placement:"bottom",orderedModifiers:[],options:Object.assign({},lt,s),modifiersData:{},elements:{reference:e,popper:t},attributes:{},styles:{}},l=[],c=!1,h={state:r,setOptions:function(i){var o="function"==typeof i?i(r.options):i;d(),r.options=Object.assign({},s,r.options,o),r.scrollParents={reference:ve(e)?Je(e):e.contextElement?Je(e.contextElement):[],popper:Je(t)};var a,c,p=function(e){var t=rt(e);return fe.reduce((function(e,i){return e.concat(t.filter((function(e){return e.phase===i})))}),[])}((a=[].concat(n,r.options.modifiers),c=a.reduce((function(e,t){var i=e[t.name];return e[t.name]=i?Object.assign({},i,t,{options:Object.assign({},i.options,t.options),data:Object.assign({},i.data,t.data)}):t,e}),{}),Object.keys(c).map((function(e){return c[e]}))));return r.orderedModifiers=p.filter((function(e){return e.enabled})),r.orderedModifiers.forEach((function(e){var t=e.name,i=e.options,n=void 0===i?{}:i,o=e.effect;if("function"==typeof o){var s=o({state:r,name:t,instance:h,options:n}),a=function(){};l.push(s||a)}})),h.update()},forceUpdate:function(){if(!c){var e=r.elements,t=e.reference,i=e.popper;if(ct(t,i)){r.rects={reference:at(t,He(i),"fixed"===r.options.strategy),popper:Se(i)},r.reset=!1,r.placement=r.options.placement,r.orderedModifiers.forEach((function(e){return r.modifiersData[e.name]=Object.assign({},e.data)}));for(var n=0;n<r.orderedModifiers.length;n++)if(!0!==r.reset){var o=r.orderedModifiers[n],s=o.fn,a=o.options,l=void 0===a?{}:a,d=o.name;"function"==typeof s&&(r=s({state:r,options:l,name:d,instance:h})||r)}else r.reset=!1,n=-1}}},update:(o=function(){return new Promise((function(e){h.forceUpdate(),e(r)}))},function(){return a||(a=new Promise((function(e){Promise.resolve().then((function(){a=void 0,e(o())}))}))),a}),destroy:function(){d(),c=!0}};if(!ct(e,t))return h;function d(){l.forEach((function(e){return e()})),l=[]}return h.setOptions(i).then((function(e){!c&&i.onFirstUpdate&&i.onFirstUpdate(e)})),h}}var dt=ht({defaultModifiers:[{name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(e){var t=e.state,i=e.instance,n=e.options,o=n.scroll,s=void 0===o||o,a=n.resize,r=void 0===a||a,l=ge(t.elements.popper),c=[].concat(t.scrollParents.reference,t.scrollParents.popper);return s&&c.forEach((function(e){e.addEventListener("scroll",i.update,Fe)})),r&&l.addEventListener("resize",i.update,Fe),function(){s&&c.forEach((function(e){e.removeEventListener("scroll",i.update,Fe)})),r&&l.removeEventListener("resize",i.update,Fe)}},data:{}},{name:"popperOffsets",enabled:!0,phase:"read",fn:function(e){var t=e.state,i=e.name;t.modifiersData[i]=it({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})},data:{}},{name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(e){var t=e.state,i=e.options,n=i.gpuAcceleration,o=void 0===n||n,s=i.adaptive,a=void 0===s||s,r=i.roundOffsets,l=void 0===r||r,c={placement:xe(t.placement),variation:je(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:o,isFixed:"fixed"===t.options.strategy};null!=t.modifiersData.popperOffsets&&(t.styles.popper=Object.assign({},t.styles.popper,De(Object.assign({},c,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:a,roundOffsets:l})))),null!=t.modifiersData.arrow&&(t.styles.arrow=Object.assign({},t.styles.arrow,De(Object.assign({},c,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})},data:{}},we,{name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(e){var t=e.state,i=e.options,n=e.name,o=i.offset,s=void 0===o?[0,0]:o,a=ue.reduce((function(e,i){return e[i]=function(e,t,i){var n=xe(e),o=[se,ie].indexOf(n)>=0?-1:1,s="function"==typeof i?i(Object.assign({},t,{placement:e})):i,a=s[0],r=s[1];return a=a||0,r=(r||0)*o,[se,oe].indexOf(n)>=0?{x:r,y:a}:{x:a,y:r}}(i,t.rects,s),e}),{}),r=a[t.placement],l=r.x,c=r.y;null!=t.modifiersData.popperOffsets&&(t.modifiersData.popperOffsets.x+=l,t.modifiersData.popperOffsets.y+=c),t.modifiersData[n]=a}},{name:"flip",enabled:!0,phase:"main",fn:function(e){var t=e.state,i=e.options,n=e.name;if(!t.modifiersData[n]._skip){for(var o=i.mainAxis,s=void 0===o||o,a=i.altAxis,r=void 0===a||a,l=i.fallbackPlacements,c=i.padding,h=i.boundary,d=i.rootBoundary,p=i.altBoundary,u=i.flipVariations,f=void 0===u||u,m=i.allowedAutoPlacements,g=t.options.placement,v=xe(g),y=l||(v===g||!f?[ze(g)]:function(e){if(xe(e)===ae)return[];var t=ze(e);return[Ue(e),t,Ue(t)]}(g)),b=[g].concat(y).reduce((function(e,i){return e.concat(xe(i)===ae?function(e,t){void 0===t&&(t={});var i=t,n=i.placement,o=i.boundary,s=i.rootBoundary,a=i.padding,r=i.flipVariations,l=i.allowedAutoPlacements,c=void 0===l?ue:l,h=je(n),d=h?r?pe:pe.filter((function(e){return je(e)===h})):re,p=d.filter((function(e){return c.indexOf(e)>=0}));0===p.length&&(p=d);var u=p.reduce((function(t,i){return t[i]=nt(e,{placement:i,boundary:o,rootBoundary:s,padding:a})[xe(i)],t}),{});return Object.keys(u).sort((function(e,t){return u[e]-u[t]}))}(t,{placement:i,boundary:h,rootBoundary:d,padding:c,flipVariations:f,allowedAutoPlacements:m}):i)}),[]),w=t.rects.reference,x=t.rects.popper,I=new Map,C=!0,L=b[0],O=0;O<b.length;O++){var Y=b[O],k=xe(Y),S=je(Y)===le,R=[ie,ne].indexOf(k)>=0,X=R?"width":"height",E=nt(t,{placement:Y,boundary:h,rootBoundary:d,altBoundary:p,padding:c}),T=R?S?oe:se:S?ne:ie;w[X]>x[X]&&(T=ze(T));var Z=ze(T),A=[];if(s&&A.push(E[k]<=0),r&&A.push(E[T]<=0,E[Z]<=0),A.every((function(e){return e}))){L=Y,C=!1;break}I.set(Y,A)}if(C)for(var H=function(e){var t=b.find((function(t){var i=I.get(t);if(i)return i.slice(0,e).every((function(e){return e}))}));if(t)return L=t,"break"},W=f?3:1;W>0;W--){if("break"===H(W))break}t.placement!==L&&(t.modifiersData[n]._skip=!0,t.placement=L,t.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}},{name:"preventOverflow",enabled:!0,phase:"main",fn:function(e){var t=e.state,i=e.options,n=e.name,o=i.mainAxis,s=void 0===o||o,a=i.altAxis,r=void 0!==a&&a,l=i.boundary,c=i.rootBoundary,h=i.altBoundary,d=i.padding,p=i.tether,u=void 0===p||p,f=i.tetherOffset,m=void 0===f?0:f,g=nt(t,{boundary:l,rootBoundary:c,padding:d,altBoundary:h}),v=xe(t.placement),y=je(t.placement),b=!y,w=We(v),x="x"===w?"y":"x",I=t.modifiersData.popperOffsets,C=t.rects.reference,L=t.rects.popper,O="function"==typeof m?m(Object.assign({},t.rects,{placement:t.placement})):m,Y="number"==typeof O?{mainAxis:O,altAxis:O}:Object.assign({mainAxis:0,altAxis:0},O),k=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,S={x:0,y:0};if(I){if(s){var R,X="y"===w?ie:se,E="y"===w?ne:oe,T="y"===w?"height":"width",Z=I[w],A=Z+g[X],H=Z-g[E],W=u?-L[T]/2:0,M=y===le?C[T]:L[T],B=y===le?-L[T]:-C[T],P=t.elements.arrow,j=u&&P?Se(P):{width:0,height:0},V=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},D=V[X],F=V[E],G=Me(0,C[T],j[T]),z=b?C[T]/2-W-G-D-Y.mainAxis:M-G-D-Y.mainAxis,N=b?-C[T]/2+W+G+F+Y.mainAxis:B+G+F+Y.mainAxis,U=t.elements.arrow&&He(t.elements.arrow),$=U?"y"===w?U.clientTop||0:U.clientLeft||0:0,K=null!=(R=null==k?void 0:k[w])?R:0,Q=Z+N-K,q=Me(u?Ce(A,Z+z-K-$):A,Z,u?Ie(H,Q):H);I[w]=q,S[w]=q-Z}if(r){var J,_="x"===w?ie:se,ee="x"===w?ne:oe,te=I[x],ae="y"===x?"height":"width",re=te+g[_],ce=te-g[ee],he=-1!==[ie,se].indexOf(v),de=null!=(J=null==k?void 0:k[x])?J:0,pe=he?re:te-C[ae]-L[ae]-de+Y.altAxis,ue=he?te+C[ae]+L[ae]-de-Y.altAxis:ce,fe=u&&he?(ge=Me(pe,te,me=ue))>me?me:ge:Me(u?pe:re,te,u?ue:ce);I[x]=fe,S[x]=fe-te}var me,ge;t.modifiersData[n]=S}},requiresIfExists:["offset"]},{name:"arrow",enabled:!0,phase:"main",fn:function(e){var t,i=e.state,n=e.name,o=e.options,s=i.elements.arrow,a=i.modifiersData.popperOffsets,r=xe(i.placement),l=We(r),c=[se,oe].indexOf(r)>=0?"height":"width";if(s&&a){var h=function(e,t){return Be("number"!=typeof(e="function"==typeof e?e(Object.assign({},t.rects,{placement:t.placement})):e)?e:Pe(e,re))}(o.padding,i),d=Se(s),p="y"===l?ie:se,u="y"===l?ne:oe,f=i.rects.reference[c]+i.rects.reference[l]-a[l]-i.rects.popper[c],m=a[l]-i.rects.reference[l],g=He(s),v=g?"y"===l?g.clientHeight||0:g.clientWidth||0:0,y=f/2-m/2,b=h[p],w=v-d[c]-h[u],x=v/2-d[c]/2+y,I=Me(b,x,w),C=l;i.modifiersData[n]=((t={})[C]=I,t.centerOffset=I-x,t)}},effect:function(e){var t=e.state,i=e.options.element,n=void 0===i?"[data-popper-arrow]":i;null!=n&&("string"!=typeof n||(n=t.elements.popper.querySelector(n)))&&Re(t.elements.popper,n)&&(t.elements.arrow=n)},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]},{name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(e){var t=e.state,i=e.name,n=t.rects.reference,o=t.rects.popper,s=t.modifiersData.preventOverflow,a=nt(t,{elementContext:"reference"}),r=nt(t,{altBoundary:!0}),l=ot(a,n),c=ot(r,o,s),h=st(l),d=st(c);t.modifiersData[i]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:h,hasPopperEscaped:d},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":h,"data-popper-escaped":d})}}]});class pt{constructor(e,i,n){t(this,"updateHotspotPosition",((e,t)=>{this.currentActiveIndex=e,this.currentOrientation=t;const i=ee(this.hotspotsConfig,e,t);this.hideHotspots(),i.forEach((t=>this.updateAndShowHotspot(t,e)))})),this.container=i,this.popper=null,this.popperInstance=null,this.hotspotsContainer=(e=>{const t=document.createElement("div");return t.className="cloudimage-360-hotspot-container",e.appendChild(t),t})(this.container),this.hotspotsConfig=(e=>{const t=[...e];return t.forEach(((e,i)=>{const n={...te(e.positions)};t[i].initialPositions=n,t[i].positions=n})),t})(e),this.shouldHidePopper=!0,this.hidePopper=this.hidePopper.bind(this),this.imageAspectRatio=n;const{containerSize:o}=e[0];this.initialContainerSize=o||[i.offsetWidth,i.offsetHeight],this.initHotspots(),this.observeContainerResize()}observeContainerResize(){this.resizeObserver=new ResizeObserver((()=>{const e=this.container.offsetWidth,t=this.container.offsetHeight;this.updateHotspotsForResize(e,t)})),this.resizeObserver.observe(this.container)}updateHotspotsForResize(e,t){this.hotspotsConfig=(({newWidth:e,newHeight:t,initialContainerSize:i,imageAspectRatio:n,hotspotsConfig:o})=>{const[s,a]=i;let r=e,l=t,c=0,h=0;n>e/t?(l=e/n,h=(t-l)/2):(r=t*n,c=(e-r)/2);const d=r/s,p=l/a;return o.map((e=>{const t={};return Object.entries(e.initialPositions).forEach((([e,i])=>{t[e]={x:i.x*d+c,y:i.y*p+h}})),{...e,positions:t}}))})({newWidth:e,newHeight:t,initialContainerSize:this.initialContainerSize,imageAspectRatio:this.imageAspectRatio,hotspotsConfig:this.hotspotsConfig}),this.updateHotspotPosition(this.currentActiveIndex,this.currentOrientation)}showPopper({hotspotElement:e,content:t,id:i,keepOpen:n}){this.popperInstance&&this.popperInstance.instanceId!==i&&this.hidePopper();const o={placement:"top",modifiers:(s=this.container,[{name:"offset",options:{offset:[0,10]}},{name:"preventOverflow",options:{boundary:s}}])};var s;this.popper=((e,t)=>{const i=document.createElement("div");return i.className="cloudimage-360-popper",i.id=`cloudimage-360-popper-${t}`,i.dataset.popperId=t,"string"==typeof e&&/<\/?[a-z][\s\S]*>/i.test(e)?i.innerHTML=e:i.textContent=e,document.body.appendChild(i),i})(t,i),this.popper.setAttribute("data-show",""),this.popper.addEventListener("mouseenter",(()=>{this.shouldHidePopper=!1})),this.popper.addEventListener("mouseleave",(()=>{this.shouldHidePopper=!0,this.checkAndHidePopper()})),e.addEventListener("mouseleave",(()=>{this.shouldHidePopper=!0,this.checkAndHidePopper()})),e.addEventListener("mouseenter",(()=>{this.shouldHidePopper=!1,this.hidePopperTimeout&&clearTimeout(this.hidePopperTimeout)})),this.popperInstance={...dt(e,this.popper,o),keepOpen:n,instanceId:i}}checkAndHidePopper(){var e;this.shouldHidePopper&&!(null==(e=this.popperInstance)?void 0:e.keepOpen)&&(this.hidePopperTimeout=setTimeout((()=>{this.shouldHidePopper&&this.hidePopper()}),150))}hidePopper(){this.popperInstance&&(this.popperInstance.destroy(),this.popperInstance=null),this.popper&&(this.popper.removeAttribute("data-show"),setTimeout((()=>{this.popper&&this.popper.remove(),this.popper=null}),200))}createHotspot(e){const{id:t,content:i,keepOpen:n,onClick:o}=e,s=(e=>{const t=document.createElement("span");return t.id=e,t.className="cloudimage-360-hotspot",t.dataset.hotspotId=e,t})(t);o&&(s.style.cursor="pointer"),s.onclick=e=>{e.stopPropagation(),null==o||o(e,this.popperInstance,t)},i&&s.addEventListener("mouseenter",(()=>this.showPopper({hotspotElement:s,content:i,id:t,keepOpen:n}))),this.hotspotsContainer.appendChild(s)}hideHotspots(){this.hotspotsContainer.querySelectorAll(".cloudimage-360-hotspot").forEach((e=>{e.style.opacity=0,e.style.pointerEvents="none"}))}updateAndShowHotspot(e,t){const{positions:i,id:n}=e,{x:o,y:s}=i[t]??{},a=this.hotspotsContainer.querySelector(`[data-hotspot-id="${n}"]`);a&&(a.style.translate=`${o}px ${s}px`,a.style.opacity=1,a.style.pointerEvents="all")}createAllHotspots(){this.hotspotsConfig.forEach((e=>this.createHotspot(e)))}initHotspots(){this.createAllHotspots()}destroy(){this.resizeObserver.disconnect(),this.hidePopper(),this.hotspotsContainer.innerHTML=""}}class ut{constructor(e,t,i){this.container=e,this.isClicked=!1,this.fullscreenView=!!i,this.imagesX=[],this.imagesY=[],this.devicePixelRatio=Math.round(window.devicePixelRatio||1),this.id=e.id,this.movementStart={x:0,y:0},this.draggingDirection=null,this.isReady=!1,this.currentZoomScale=1,this.touchDevice="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,this.canvasWorker=new _,this.onMoveHandler=this.onMoveHandler.bind(this),this.destroy=this.destroy.bind(this),this.init(this.container,t)}mouseDown(e){if(!this.isReady||this.glass)return;const{pageX:t,pageY:i}=e;(this.autoplay||this.loopTimeoutId)&&(this.stopAutoplay(),this.autoplay=!1),this.movementStart={x:t,y:i},this.isClicked=!0,this.isDragging=!1}mouseUp(){this.isReady&&(this.isZoomed||this.showAllIcons(),this.movementStart={x:0,y:0},this.isClicked=!1,this.innerBox.style.cursor="grab")}drag(e,t){if(!this.isReady||!this.isClicked)return;const i=e-this.movementStart.x,n=t-this.movementStart.y;this.draggingDirection=(({deltaX:e,deltaY:t,reversed:i,allowSpinX:n,allowSpinY:o,threshold:s=0})=>{const a=n&&!o||o&&!n?0:s,r=Math.abs(e),l=Math.abs(t);return n&&r-a>l?i?e>0?"left":"right":e>0?"right":"left":o&&l-a>r?i?t>0?"up":"down":t>0?"down":"up":null})({deltaX:i,deltaY:n,reversed:this.dragReverse,allowSpinX:this.allowSpinX,allowSpinY:this.allowSpinY})||this.draggingDirection;const o=this.fullscreenView?document.body:this.container,s=this.dragSpeed/50,a=s*(this.amountX/o.offsetWidth),r=s*(this.amountY/o.offsetHeight),l=this.allowSpinX?Math.abs(Math.round(i*a)):0,c=this.allowSpinY?Math.abs(Math.round(n*r)):0;(this.allowSpinX&&0!==l||this.allowSpinY&&0!==c)&&(this.hideHotspotPopper(),this.onMoveHandler(this.draggingDirection,l,c),this.movementStart={x:e,y:t},setTimeout((()=>{this.isDragging=!0}),150))}mouseMove(e){this.isReady&&(this.isClicked||this.isZoomed)&&!this.glass&&(this.hideAllIcons(),this.drag(e.pageX,e.pageY),this.isZoomed&&this.applyZoom(e))}mouseClick(e){this.isReady&&!this.isDragging&&(this.glass&&this.magnified?this.removeGlass():!this.pointerZoom||this.glass||this.touchDevice||this.toggleZoom(e))}loadHigherQualityImages(e,t){const i=H(this.srcXConfig,e),n=this.allowSpinY?H(this.srcYConfig,e):null;B({cdnPathX:i,cdnPathY:n,configX:this.srcXConfig,configY:this.srcYConfig,onAllImagesLoad:(e,i)=>{this.imagesX=e,this.imagesY=i,t()}})}hideHotspots(){this.hotspotsInstance&&this.hotspotsInstance.hideHotspots()}hideHotspotPopper(){this.hotspotsInstance&&this.hotspotsInstance.hidePopper()}toggleZoom(e){if(this.isZoomed)this.showTransitionOverlay(),setTimeout((()=>{this.removeZoom()}),800);else{let t=(this.fullscreenView||this.pointerZoom?document.body:this.container).offsetWidth;this.hideHotspots(),this.showLoadingSpinner(),this.loadHigherQualityImages(t,(()=>{this.showTransitionOverlay(),setTimeout((()=>{this.applyZoom(e)}),800)}))}}removeZoom(){this.isZoomed=!1,this.updateView(),this.showAllIcons(),this.hideTransitionOverlay()}applyZoom(e){const{offsetX:t,offsetY:i}=((e,t,i)=>{const{clientX:n,clientY:o}=e,s=t.getBoundingClientRect(),a=t.width/(s.width*i),r=t.height/(s.height*i);return{offsetX:(n-s.left)*a,offsetY:(o-s.top)*r}})(e,this.canvas,this.devicePixelRatio);this.isZoomed=!0,this.hideAllIcons(),this.hideLoadingSpinner(),this.hideTransitionOverlay(),this.updateView(this.pointerZoom,t,i)}touchOutside(e){if(!this.glass)return;!this.canvas.contains(e.target)&&this.removeGlass()}touchStart(e){if(!this.isReady||e.touches.length>1||this.glass)return;const{pageX:t,pageY:i}=e.touches[0];(this.autoplay||this.loopTimeoutId)&&(this.stopAutoplay(),this.autoplay=!1),this.hideAllIcons(),this.movementStart={x:t,y:i},this.isClicked=!0}touchEnd(){this.isReady&&(this.showAllIcons(),this.movementStart={x:0,y:0},this.isClicked=!1)}touchMove(e){if(!this.isReady||!this.isClicked||this.glass)return;const{pageX:t,pageY:i}=e.touches[0];e.preventDefault(),this.drag(t,i)}keyDown(e){if(!this.isReady)return;const{keyCode:t}=e,i=this.keysReverse;switch(this.autoplay&&this.stopAutoplay(),$(t,this.allowSpinY)&&this.hideAllIcons(),t){case 37:i?this.moveLeft():this.moveRight();break;case 39:i?this.moveRight():this.moveLeft();break;case 38:this.allowSpinY&&(e.preventDefault(),i?this.moveTop():this.moveBottom());break;case 40:this.allowSpinY&&(e.preventDefault(),i?this.moveBottom():this.moveTop())}}keyUp(e){const{keyCode:t}=e;$(t,this.allowSpinY)&&this.showAllIcons()}moveActiveXIndexUp(e){this.orientation=Y,this.activeImageX=(this.activeImageX+e)%this.amountX}moveActiveXIndexDown(e){this.orientation=Y,this.activeImageX=(this.activeImageX-e+this.amountX)%this.amountX}moveActiveYIndexUp(e){this.orientation=k,this.activeImageY=(this.activeImageY+e)%this.amountY}moveActiveYIndexDown(e){this.orientation=k,this.activeImageY=(this.activeImageY-e+this.amountY)%this.amountY}moveRight(e,t=1){e&&this.activeImageX>=this.imagesX.length-1||(this.moveActiveXIndexUp(t),this.isZoomed||this.updateView())}moveLeft(e,t=1){e&&this.activeImageX<=0||(this.moveActiveXIndexDown(t),this.isZoomed||this.updateView())}moveTop(e,t=1){e&&this.activeImageY>=this.imagesY.length-1||(this.moveActiveYIndexUp(t),this.isZoomed||this.updateView())}moveBottom(e,t=1){e&&this.activeImageY<=0||(this.moveActiveYIndexDown(t),this.isZoomed||this.updateView())}onMoveHandler(e,t=1,i=1){"right"===e?this.moveRight(this.stopAtEdges,t):"left"===e?this.moveLeft(this.stopAtEdges,t):"up"===e?this.moveTop(this.stopAtEdges,i):"down"===e&&this.moveBottom(this.stopAtEdges,i)}updateView(e,t,i){const n=this.orientation===Y?this.activeImageX:this.activeImageY,o=this.orientation===Y?this.imagesX[this.activeImageX]:this.imagesY[this.activeImageY];!this.hotspotsInstance||this.isZoomed||this.autoplay||this.hotspotsInstance.updateHotspotPosition(n,this.orientation),this.drawImageOnCanvas(o,e,t,i)}updatePercentageInLoader(e=0){this.loader&&(this.loader.innerText=e+"%")}adaptCanvasSize(e){const{naturalWidth:t,naturalHeight:i}=e;this.imageAspectRatio=t/i;const n=this.fullscreenView?window.innerWidth:this.canvas.clientWidth,o=this.fullscreenView?window.innerHeight:this.canvas.clientHeight;this.canvasWorker.postMessage({action:"adaptCanvasSize",devicePixelRatio:this.devicePixelRatio,imageAspectRatio:this.imageAspectRatio,containerWidth:n,containerHeight:o})}drawImageOnCanvas(e,t=1,i=0,n=0){this.canvasWorker.postMessage({action:"drawImageOnCanvas",imageData:e,zoomScale:t,pointerX:i,pointerY:n})}pushImageToSet(e,t,i){i===Y?this.imagesX[t]=e:this.imagesY[t]=e}calculatePercentage(){const e=this.amountX+this.amountY,t=this.imagesX.length+this.imagesY.length;return Math.round(t/e*100)}onImageLoad(e,t,i){this.pushImageToSet(e,t,i),this.updatePercentageInLoader(this.calculatePercentage())}onFirstImageLoaded(e,t){this.createContainers(e),this.adaptCanvasSize(t),this.drawImageOnCanvas(t)}onAllImagesLoaded(){if(this.addAllIcons(),this.hotspots&&(this.hotspotsInstance=new pt(this.hotspots,this.innerBox,this.imageAspectRatio)),this.isReady=!0,this.amountX=this.imagesX.length,this.amountY=this.imagesY.length,this.activeImageX=this.autoplayReverse?this.amountX-1:0,this.activeImageY=this.autoplayReverse?this.amountY-1:0,this.autoplay){this.hideAllIcons();K(this.play.bind(this))()}}magnify(e){e.stopPropagation();const{src:t}=this.orientation===k?this.imagesY[this.activeImageY]:this.imagesX[this.activeImageX],i=(this.fullscreenView?document.body:this.container).offsetWidth*this.magnifier,n=W(t,i);this.showLoadingSpinner(),this.createGlass();((e,t)=>{const i=new Image;i.src=e,i.onload=n=>{t&&t({event:n,width:i.width,height:i.height,naturalWidth:i.naturalWidth,naturalHeight:i.naturalHeight,src:e})},i.onerror=function(){}})(n,(t=>{this.hideLoadingSpinner(),this.magnified=!0,((e,t,i,n,o,s)=>{const{x:a=0,y:r=0}=i||{},l=(t.offsetWidth-2*a)*s,c=(t.offsetHeight-2*r)*s;if(!o)return;o.setAttribute("class","cloudimage-360-img-magnifier-glass"),t.prepend(o),o.style.backgroundImage=`url('${n.src}')`,o.style.backgroundSize=`${l}px ${c}px`;const h={container:t,w:o.offsetWidth/2,h:o.offsetHeight/2,zoom:s,bw:3,offsetX:a,offsetY:r};z(e,h,o);const d=e=>{z(e,h,o)};o.addEventListener("mousemove",d),t.addEventListener("mousemove",d),t.addEventListener("touchmove",(e=>{e.preventDefault(),z(e,h,o)}))})(e,this.innerBox,this.offset,t,this.glass,this.magnifier)}))}openFullscreenModal(e){e.stopPropagation();const t=(e=>{const t=document.createElement("div");t.className="cloudimage-360-fullscreen-modal";const i=e.cloneNode();return i.style.height="100vh",i.style.maxHeight="100%",t.appendChild(i),window.document.body.appendChild(t),i})(this.container);new ut(t,this.viewerConfig,!0)}closeFullscreenModal(e){e.stopPropagation(),document.body.removeChild(this.container.parentNode),window.document.body.style.overflow="visible"}play(){if(this.isClicked)return;this.hide360ViewCircleIcon();const e=36*this.speed/(this.amountX+this.amountY),t={left:this.moveLeft.bind(this),right:this.moveRight.bind(this),top:this.moveTop.bind(this),bottom:this.moveBottom.bind(this)};this.loopTimeoutId=window.setInterval((()=>{if(this.playOnce&&(({autoplayBehavior:e,activeImageX:t,activeImageY:i,amountX:n,amountY:o,autoplayReverse:s})=>{const a=(e,t)=>s?0===e:e===t-1;switch(e){case C:case I:return a(i,o);default:return a(t,n)}})({autoplayBehavior:this.autoplayBehavior,activeImageX:this.activeImageX,activeImageY:this.activeImageY,amountX:this.amountX,amountY:this.amountY,autoplayReverse:this.autoplayReverse}))return void this.stopAutoplay();(({autoplayBehavior:e,activeImageX:t,activeImageY:i,amountX:n,amountY:o,autoplayReverse:s,spinDirection:a})=>(e===C||e===L)&&("x"===a&&t===(s?0:n-1)||"y"===a&&i===(s?0:o-1)))({autoplayBehavior:this.autoplayBehavior,activeImageX:this.activeImageX,activeImageY:this.activeImageY,amountX:this.amountX,amountY:this.amountY,autoplayReverse:this.autoplayReverse,spinDirection:this.spinDirection})&&(this.spinDirection="x"===this.spinDirection?"y":"x");const e="y"===this.spinDirection;(({autoplayBehavior:e,spinY:t,reversed:i,loopTriggers:n})=>{switch(e){case C:case L:t?N(i,n):U(i,n);break;case I:N(i,n);break;default:U(i,n)}})({autoplayBehavior:this.autoplayBehavior,spinY:e,reversed:this.autoplayReverse,loopTriggers:t})}),e)}stopAutoplay(){this.showAllIcons(),this.autoplay=!1,window.clearTimeout(this.loopTimeoutId)}destroy(){this.stopAutoplay(),this.hotspotsInstance&&this.hotspotsInstance.destroy();const e=this.container,t=e.cloneNode(!0),i=t.querySelector(".cloudimage-360-inner-box");t.removeChild(i),e.parentNode.replaceChild(t,e)}addInitialIcon(){this.initialIcon||(this.initialIcon=(()=>{const e=document.createElement("div");return e.className="cloudimage-initial-icon",e.innerText="360°",e})(),this.innerBox.appendChild(this.initialIcon))}showInitialIcon(){this.initialIcon&&(this.initialIcon.style.opacity=1)}hideInitialIcon(){this.initialIcon&&(this.initialIcon.style.opacity=0)}createGlass(){this.hideAllIcons(),this.glass=document.createElement("div"),this.innerBox.appendChild(this.glass),this.innerBox.style.cursor="default"}removeGlass(){this.showAllIcons(),this.innerBox.removeChild(this.glass),this.glass=null,this.magnified=!1}addMagnifierIcon(){this.magnifier&&(this.magnifierIcon=(()=>{const e=document.createElement("div");return e.className="cloudimage-360-button cloudimage-360-magnifier-button",e.innerHTML="<img alt=\"magnifier icon\" src=data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='20px'%20viewBox='0%20-960%20960%20960'%20width='20px'%20fill='%235f6368'%3e%3cpath%20d='M765-144%20526-383q-30%2022-65.79%2034.5-35.79%2012.5-76.18%2012.5Q284-336%20214-406t-70-170q0-100%2070-170t170-70q100%200%20170%2070t70%20170.03q0%2040.39-12.5%2076.18Q599-464%20577-434l239%20239-51%2051ZM384-408q70%200%20119-49t49-119q0-70-49-119t-119-49q-70%200-119%2049t-49%20119q0%2070%2049%20119t119%2049Z'/%3e%3c/svg%3e>",e})(),this.magnifierIcon.onclick=this.magnify.bind(this),this.iconsContainer.appendChild(this.magnifierIcon))}showMagnifierIcon(){this.magnifierIcon&&(this.magnifierIcon.style.visibility="visible",this.magnifierIcon.style.opacity=1)}hideMagnifierIcon(){this.magnifierIcon&&(this.magnifierIcon.style.visibility="hidden",this.magnifierIcon.style.opacity=0)}addFullscreenIcon(){this.fullscreen&&(this.fullscreenIcon=(()=>{const e=document.createElement("div");return e.className="cloudimage-360-button cloudimage-360-fullscreen-button",e.innerHTML="<img alt=\"fullscreen icon\" src=data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='20px'%20viewBox='0%20-960%20960%20960'%20width='20px'%20fill='%235f6368'%3e%3cpath%20d='M144-144v-192h72v120h120v72H144Zm480%200v-72h120v-120h72v192H624ZM144-624v-192h192v72H216v120h-72Zm600%200v-120H624v-72h192v192h-72Z'/%3e%3c/svg%3e>",e})(),this.fullscreenIcon.onclick=this.openFullscreenModal.bind(this),this.iconsContainer.appendChild(this.fullscreenIcon))}addCloseFullscreenIcon(){this.fullscreenCloseIcon=(()=>{const e=document.createElement("div");return e.className="cloudimage-360-button cloudimage-360-close-icon",e.innerHTML="<img alt=\"close icon\" src=data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='20px'%20viewBox='0%20-960%20960%20960'%20width='20px'%20fill='%235f6368'%3e%3cpath%20d='m147-96-51-51%20261-261H192v-72h288v288h-72v-165L147-96Zm333-384v-288h72v165l261-261%2051%2051-261%20261h165v72H480Z'/%3e%3c/svg%3e>",e})(),this.fullscreenCloseIcon.onclick=this.closeFullscreenModal.bind(this),this.iconsContainer.appendChild(this.fullscreenCloseIcon)}showFullscreenIcon(){this.fullscreenIcon&&(this.fullscreenIcon.style.opacity=1)}hideFullscreenIcon(){this.fullscreenIcon&&(this.fullscreenIcon.style.opacity=0)}add360ViewCircleIcon(){this.view360CircleIcon||(this.view360CircleIcon=(e=>{const t=new Image;return t.src="https://scaleflex.cloudimg.io/v7/plugins/js-cloudimage-360-view/assets/img/360.svg",t.style.bottom=`${e}%`,t.className="cloudimage-360-view-360-circle",t})(this.bottomCircleOffset),this.innerBox.appendChild(this.view360CircleIcon))}show360ViewCircleIcon(){this.view360CircleIcon&&(this.view360CircleIcon.style.opacity=1)}hide360ViewCircleIcon(){this.view360CircleIcon&&(this.view360CircleIcon.style.opacity=0)}addLoadingSpinner(){this.loadingSpinner=(()=>{const e=document.createElement("div");return e.className="cloudimage-loading-spinner",e})(),this.innerBox.appendChild(this.loadingSpinner)}showLoadingSpinner(){this.loadingSpinner&&(this.hideAllIcons(),this.loadingSpinner.style.opacity=1)}createTransitionOverlay(){this.transitionOverlay=(()=>{const e=document.createElement("div");return e.className="cloudimage-360-transition-overlay",e})(),this.innerBox.appendChild(this.transitionOverlay)}showTransitionOverlay(){this.transitionOverlay&&(this.hideAllIcons(),this.transitionOverlay.style.opacity=1)}hideTransitionOverlay(){this.transitionOverlay&&(this.transitionOverlay.style.opacity=0)}hideLoadingSpinner(){this.loadingSpinner&&(this.loadingSpinner.style.opacity=0)}remove360ViewCircleIcon(){this.view360CircleIcon&&(this.innerBox.removeChild(this.view360CircleIcon),this.view360CircleIcon=null)}addAllIcons(){this.removeLoader(),this.innerBox.style.cursor="grab",this.pointerZoom&&(this.createTransitionOverlay(),this.addLoadingSpinner()),this.fullscreenView||this.touchDevice||this.addMagnifierIcon(),this.fullscreenView||this.addFullscreenIcon(),this.initialIconShown&&this.addInitialIcon(),this.bottomCircle||this.add360ViewCircleIcon()}showAllIcons(){this.showInitialIcon(),this.show360ViewCircleIcon(),this.showMagnifierIcon(),this.showFullscreenIcon()}hideAllIcons(){this.hideInitialIcon(),this.hide360ViewCircleIcon(),this.hideMagnifierIcon(),this.hideFullscreenIcon()}removeLoader(){this.loader&&(this.innerBox.removeChild(this.loader),this.loader=null)}attachEvents(e,t,i){e&&this.addMouseEvents(),t&&this.addTouchEvents(),i&&this.addKeyboardEvents()}removeEvents(){this.removeMouseEvents(),this.removeTouchEvents(),this.removeKeyboardEvents()}addMouseEvents(){this.boundMouseClick=this.mouseClick.bind(this),this.boundMouseDown=this.mouseDown.bind(this),this.boundMouseMove=w(this.mouseMove.bind(this),10),this.boundMouseUp=this.mouseUp.bind(this),this.innerBox.addEventListener("click",this.boundMouseClick),this.innerBox.addEventListener("mousedown",this.boundMouseDown),document.addEventListener("mousemove",this.boundMouseMove),document.addEventListener("mouseup",this.boundMouseUp)}addTouchEvents(){this.boundTouchOutside=this.touchOutside.bind(this),this.boundTouchStart=this.touchStart.bind(this),this.boundTouchEnd=this.touchEnd.bind(this),this.boundTouchMove=w(this.touchMove.bind(this),10),document.addEventListener("touchstart",this.boundTouchOutside),this.container.addEventListener("touchstart",this.boundTouchStart),this.container.addEventListener("touchend",this.boundTouchEnd),this.container.addEventListener("touchmove",this.boundTouchMove)}addKeyboardEvents(){this.boundKeyDown=this.keyDown.bind(this),this.boundKeyUp=this.keyUp.bind(this),document.addEventListener("keydown",this.boundKeyDown),document.addEventListener("keyup",this.boundKeyUp)}removeMouseEvents(){this.innerBox.removeEventListener("click",this.boundMouseClick),this.innerBox.removeEventListener("mousedown",this.boundMouseDown),document.removeEventListener("mousemove",this.boundMouseMove),document.removeEventListener("mouseup",this.boundMouseUp)}removeTouchEvents(){document.removeEventListener("touchstart",this.boundTouchOutside),this.container.removeEventListener("touchstart",this.boundTouchStart),this.container.removeEventListener("touchend",this.boundTouchEnd),this.container.removeEventListener("touchmove",this.boundTouchMove)}removeKeyboardEvents(){document.removeEventListener("keydown",this.boundKeyDown),document.removeEventListener("keyup",this.boundKeyUp)}createContainers(e){this.iconsContainer=P(this.innerBox),this.canvas=((e,t)=>{const{width:i,height:n}=t,o=document.createElement("canvas");return o.width=i,o.height=n,o.style.width="100%",o.style.height="auto",e.appendChild(o),o})(this.innerBox,e),this.loader=(e=>{const t=document.createElement("div");t.className="cloudimage-initial-icon";const i=document.createElement("span");return i.className="percentage",i.innerText="0%",t.appendChild(i),e.appendChild(t),t})(this.innerBox);const t=this.canvas.transferControlToOffscreen();this.canvasWorker.postMessage({action:"initCanvas",offscreen:t,devicePixelRatio:this.devicePixelRatio},[t]),this.fullscreenView&&this.addCloseFullscreenIcon(),j(this.innerBox,".cloudimage-360-placeholder")}update(e){this.isReady&&(this.stopAutoplay(),j(this.innerBox,".cloudimage-360-icons-container"),this.init(this.container,e,!0),this.iconsContainer=P(this.innerBox),this.onAllImagesLoaded())}init(e,t,i){const n=t?(e=>({folder:e.folder||E.folder,apiVersion:e.apiVersion||E.apiVersion,filenameX:e.filenameX||e.filename||E.filenameX,filenameY:e.filenameY||E.filenameY,imageListX:e.imageListX||E.imageListX,imageListY:e.imageListY||E.imageListY,indexZeroBase:parseInt(e.indexZeroBase??E.indexZeroBase,10),amountX:parseInt(e.amountX??E.amountX,10),amountY:parseInt(e.amountY??E.amountY,10),speed:parseInt(e.speed??E.speed,10),draggable:e.draggable??E.draggable,swipeable:e.swipeable??E.swipeable,dragSpeed:parseInt(e.dragSpeed??E.dragSpeed,10),keys:e.keys??E.keys,keysReverse:e.keysReverse??E.keysReverse,autoplay:e.autoplay??E.autoplay,autoplayBehavior:e.autoplayBehavior||E.autoplayBehavior,playOnce:e.playOnce??E.playOnce,autoplayReverse:e.autoplayReverse??E.autoplayReverse,pointerZoom:parseFloat(e.pointerZoom??E.pointerZoom,10),fullscreen:e.fullscreen??E.fullscreen,magnifier:parseFloat(e.magnifier??E.magnifier,10),bottomCircleOffset:parseInt(e.bottomCircleOffset??E.bottomCircleOffset,10),ciToken:e.ciToken||E.ciToken,ciFilters:e.ciFilters||E.ciFilters,ciTransformation:e.ciTransformation||E.ciTransformation,lazyload:e.lazyload??E.lazyload,dragReverse:e.dragReverse??E.dragReverse,stopAtEdges:e.stopAtEdges??E.stopAtEdges,imageInfo:e.imageInfo??E.imageInfo,initialIconShown:e.initialIconShown??E.initialIconShown,bottomCircle:e.bottomCircle??E.bottomCircle,hotspots:e.hotspots??E.hotspots}))(t):{folder:T(o=e,"folder",E.folder),apiVersion:T(o,"api-version",E.apiVersion),filenameX:T(o,"filename")||T(o,"filename-x")||E.filenameX,filenameY:T(o,"filename-y",E.filenameY),imageListX:T(o,"image-list-x",E.imageListX),imageListY:T(o,"image-list-y",E.imageListY),indexZeroBase:parseInt(T(o,"index-zero-base",E.indexZeroBase),10),amountX:parseInt(T(o,"amount-x",E.amountX),10),amountY:parseInt(T(o,"amount-y",E.amountY),10),speed:parseInt(T(o,"speed",E.speed),10),dragSpeed:parseInt(T(o,"drag-speed",E.dragSpeed),10),draggable:Z(o,"draggable",E.draggable),swipeable:Z(o,"swipeable",E.swipeable),keys:Z(o,"keys",E.keys),keysReverse:Z(o,"keys-reverse",E.keysReverse),autoplay:Z(o,"autoplay",E.autoplay),autoplayBehavior:T(o,"autoplay-behavior",E.autoplayBehavior),playOnce:Z(o,"play-once",E.playOnce),autoplayReverse:Z(o,"autoplay-reverse",E.autoplayReverse),pointerZoom:parseFloat(T(o,"pointer-zoom",E.pointerZoom),10),fullscreen:Z(o,"fullscreen")||Z(o,"full-screen",E.fullscreen),magnifier:parseFloat(T(o,"magnifier",E.magnifier),10),bottomCircleOffset:parseInt(T(o,"bottom-circle-offset",E.bottomCircleOffset),10),ciToken:T(o,"responsive",E.ciToken),ciFilters:T(o,"filters",E.ciFilters),ciTransformation:T(o,"transformation",E.ciTransformation),lazyload:Z(o,"lazyload",E.lazyload),dragReverse:Z(o,"drag-reverse",E.dragReverse),stopAtEdges:Z(o,"stop-at-edges",E.stopAtEdges),imageInfo:Z(o,"info",E.imageInfo),initialIconShown:!A(o,"initial-icon"),bottomCircle:!A(o,"bottom-circle")};var o;const{folder:s,apiVersion:a,filenameX:r,filenameY:l,imageListX:c,imageListY:h,indexZeroBase:d,amountX:p,amountY:u,draggable:f=!0,swipeable:m=!0,keys:g,keysReverse:v,bottomCircleOffset:y,autoplay:b,autoplayBehavior:w,playOnce:x,speed:O,autoplayReverse:Y,fullscreen:S,magnifier:R,ciToken:X,ciFilters:W,ciTransformation:M,lazyload:P,dragSpeed:j,stopAtEdges:V,pointerZoom:D,imageInfo:F="black",initialIconShown:z,bottomCircle:N,hotspots:U,dragReverse:$}=n,K={ciToken:X,ciFilters:W,ciTransformation:M},Q=c?JSON.parse(c):[],q=h?JSON.parse(h):[];if(this.viewerConfig=n,this.amountX=Q.length||p,this.amountY=q.length||u,this.allowSpinX=!!this.amountX,this.allowSpinY=!!this.amountY,this.activeImageX=Y?this.amountX-1:0,this.activeImageY=Y?this.amountY-1:0,this.bottomCircleOffset=y,this.autoplay=b,this.autoplayBehavior=w,this.playOnce=x,this.speed=O,this.autoplayReverse=Y,this.fullscreen=S,this.magnifier=R>1?Math.min(R,5):0,this.dragSpeed=Math.max(j,50),this.stopAtEdges=V,this.ciParams=K,this.apiVersion=a,this.pointerZoom=D>1?Math.min(D,5):null,this.keysReverse=v,this.info=F,this.keys=g,this.innerBox=this.innerBox??(e=>{const t=document.createElement("div");return t.className="cloudimage-360-inner-box",e.appendChild(t),t})(this.container),this.initialIconShown=z,this.bottomCircle=N,this.spinDirection=((e,t,i)=>{if(!i)return"x";if(!t)return"y";switch(e){case C:return"x";case L:case I:return"y";default:return"x"}})(this.autoplayBehavior,this.allowSpinX,this.allowSpinY),this.dragReverse=$,this.hotspots=U,this.srcXConfig={folder:s,filename:r,imageList:Q,container:e,innerBox:this.innerBox,apiVersion:a,ciParams:K,lazyload:P,amount:this.amountX,indexZeroBase:d,autoplayReverse:Y},this.srcYConfig={...this.srcXConfig,filename:l,imageList:q,orientation:k,amount:this.amountY},i&&this.removeEvents(),this.attachEvents(f,m,g),i)return;const J=(this.fullscreenView?document.body:this.container).offsetWidth,_=this.allowSpinX&&!Q.length?H(this.srcXConfig,J):null,ee=this.allowSpinY&&!q.length?H(this.srcYConfig,J):null,te=e=>{B({cdnPathX:_,cdnPathY:ee,configX:this.srcXConfig,configY:this.srcYConfig,onImageLoad:(e,t,i)=>this.onImageLoad(e,t,i),onFirstImageLoad:t=>this.onFirstImageLoaded(e,t),onAllImagesLoad:this.onAllImagesLoaded.bind(this)})};this.allowSpinX?G(_,this.srcXConfig,te):this.allowSpinY&&G(ee,this.srcYConfig,te)}}class ft{constructor(){this.views=new Map,this.initAll=this.initAll.bind(this),this.getViews=this.getViews.bind(this)}generateId(){return`ci360-${Math.random().toString(36).slice(2,11)}`}init(e,t,i){if(!e)return;const n=e.id||this.generateId();e.id||(e.id=n);const o=new ut(e,t,i);return this.views.set(n,o),o}initAll(e="cloudimage-360"){[...document.querySelectorAll(`.${e}`)].filter(Boolean).forEach((e=>{const t=e.id||this.generateId();e.id||(e.id=t);const i=new ut(e);this.views.set(t,i)}))}destroy(e){const t=this.getViewById(e);t&&(t.destroy(),this.views.delete(e))}destroyAll(){this.views.forEach((e=>{e.destroy()})),this.views.clear()}getViewById(e){return this.views.get(e)}getViews(){return Array.from(this.views.values())}updateView(e,t){const i=this.getViewById(e),n={...i.viewerConfig,...t};if(((e,t,i=S)=>i.some((i=>i in t&&t[i]!==e[i])))(i.viewerConfig,t)){i.destroy();const t=document.getElementById(e);this.init(t,n)}else i.update(n);return i}}return window.CI360=ft,ft}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Cloudimage360View=t()}(this,(function(){"use strict";var e=Object.defineProperty,t=(t,i,n)=>((t,i,n)=>i in t?e(t,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[i]=n)(t,"symbol"!=typeof i?i+"":i,n),i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var o="Expected a function",s=/^\s+|\s+$/g,a=/^[-+]0x[0-9a-f]+$/i,r=/^0b[01]+$/i,l=/^0o[0-7]+$/i,c=parseInt,h="object"==typeof i&&i&&i.Object===Object&&i,d="object"==typeof self&&self&&self.Object===Object&&self,p=h||d||Function("return this")(),u=Object.prototype.toString,f=Math.max,m=Math.min,g=function(){return p.Date.now()};function v(e,t,i){var n,s,a,r,l,c,h=0,d=!1,p=!1,u=!0;if("function"!=typeof e)throw new TypeError(o);function v(t){var i=n,o=s;return n=s=void 0,h=t,r=e.apply(o,i)}function w(e){var i=e-c;return void 0===c||i>=t||i<0||p&&e-h>=a}function x(){var e=g();if(w(e))return I(e);l=setTimeout(x,function(e){var i=t-(e-c);return p?m(i,a-(e-h)):i}(e))}function I(e){return l=void 0,u&&n?v(e):(n=s=void 0,r)}function C(){var e=g(),i=w(e);if(n=arguments,s=this,c=e,i){if(void 0===l)return function(e){return h=e,l=setTimeout(x,t),d?v(e):r}(c);if(p)return l=setTimeout(x,t),v(c)}return void 0===l&&(l=setTimeout(x,t)),r}return t=b(t)||0,y(i)&&(d=!!i.leading,a=(p="maxWait"in i)?f(b(i.maxWait)||0,t):a,u="trailing"in i?!!i.trailing:u),C.cancel=function(){void 0!==l&&clearTimeout(l),h=0,n=c=s=l=void 0},C.flush=function(){return void 0===l?r:I(g())},C}function y(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function b(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==u.call(e)}(e))return NaN;if(y(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=y(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(s,"");var i=r.test(e);return i||l.test(e)?c(e.slice(2),i?2:8):a.test(e)?NaN:+e}const w=n((function(e,t,i){var n=!0,s=!0;if("function"!=typeof e)throw new TypeError(o);return y(i)&&(n="leading"in i?!!i.leading:n,s="trailing"in i?!!i.trailing:s),v(e,t,{leading:n,maxWait:t,trailing:s})})),x="spin-x",I="spin-y",C="spin-xy",L="spin-yx",O=[!1,0,null,void 0,"false","0","null","undefined"],Y="x-axis",k="y-axis",S=["folder","folderX","folderY","filenameX","filenameY","imageListX","imageListY","indexZeroBase","amountX","amountY"],R=[37,39],X=[38,40],E={folder:"/",apiVersion:"v7",filenameX:"image-{index}.jpg",filenameY:null,imageListX:null,imageListY:null,indexZeroBase:0,amountX:0,amountY:0,speed:80,dragSpeed:150,draggable:!0,swipeable:!0,keys:!1,keysReverse:!1,autoplay:!1,autoplayBehavior:x,playOnce:!1,autoplayReverse:!1,pointerZoom:0,fullscreen:!1,magnifier:null,bottomCircle:!0,bottomCircleOffset:5,ciToken:null,ciFilters:null,ciTransformation:null,lazyload:!0,dragReverse:!1,stopAtEdges:!1,imageInfo:!1,initialIconShown:!0,hotspots:null},T=(e,t,i)=>e.getAttribute(t)||e.getAttribute(`data-${t}`)||i,A=(e,t,i)=>e.hasAttribute(t)||e.hasAttribute(`data-${t}`)||i,H=(e,t)=>"false"===T(e,t,null),W=(e,t)=>{const{folder:i,apiVersion:n,filename:o="",ciParams:s}=e,{ciToken:a,ciFilters:r,ciTransformation:l}=s||{},c=`${i}${o}`;if(!a)return c;const h=O.includes(n)?null:n,d=h?`${h}/`:"",p=((e=1)=>{const t=Math.round(window.devicePixelRatio||1);return parseInt(e)*t})(t),u=((e,t,i)=>new URL(e).origin.includes("cloudimg")?e:`https://${t}.cloudimg.io/${i}${e}`)(c,a,d),f=(({ciTransformation:e,responsiveWidth:t,ciFilters:i})=>`${e||`width=${t}`}${i?`&f=${i}`:""}`)({ciTransformation:l,responsiveWidth:p,ciFilters:r});return`${u}${f?"?":""}${f}`},Z=(e,t)=>((e,t,i)=>{const[n,o]=e.split("?"),s=`${t}=${encodeURIComponent(i)}`;if(!o)return`${n}?${s}`;const a=new URLSearchParams(o);return a.set(t,i),`${n}?${a.toString()}`})(e,"width",t),M=(e,t=0)=>(e+="").length>=t?e:new Array(t-e.length+1).join("0")+e,B=({cdnPathX:e,cdnPathY:t,configX:i,configY:n,onFirstImageLoad:o,onImageLoad:s,onAllImagesLoad:a})=>{let r={x:!1,y:!1},l=[],c=[];const h=e||i.imageList.length,d=t||n.imageList.length,p=({cdnPath:e,config:t,orientation:i,loadedImages:n,onFirstImageLoad:o})=>{const h=i===Y,d=t.imageList.length?t.imageList:((e,{amount:t=0,indexZeroBase:i=0}={})=>Array.from({length:t},((t,n)=>e.replace("{index}",M(n+1,i)))))(e,t);(({imagesUrls:e,onFirstImageLoad:t,onImageLoad:i,onAllImagesLoad:n,autoplayReverse:o})=>{let s=0;const a=e.length,r=[],l=(e,t)=>{const o=new Image;o.crossOrigin="anonymous",o.src=e,o.onload=async()=>{const l=await createImageBitmap(o),h={src:e,bitmapImage:l,naturalWidth:c.naturalWidth,naturalHeight:c.naturalHeight};s++,r[t]=h,null==i||i(h,t),s===a&&(null==n||n(r))},o.onerror=()=>{console.error(`Failed to load image: ${e}`),s++,s===a&&(null==n||n(r))}},c=new Image,h=e[o?e.length-1:0];c.crossOrigin="anonymous",c.src=h,c.onload=async()=>{const n=await createImageBitmap(c),o={src:h,bitmapImage:n,naturalWidth:c.naturalWidth,naturalHeight:c.naturalHeight};r[0]=o,s++,null==t||t(o),null==i||i(o,0);for(let t=1;t<e.length;t++)l(e[t],t)},c.onerror=()=>{console.error(`Failed to load first image: ${e[0]}`),s++;for(let t=1;t<e.length;t++)l(e[t],t)}})({imagesUrls:d,onFirstImageLoad:o,onImageLoad:(e,t)=>{null==s||s(e,t,i),n[t]=e},onAllImagesLoad:e=>{n=e,r[h?"x":"y"]=!0,r.x&&r.y&&a(l,c)},autoplayReverse:t.autoplayReverse})};h?p({cdnPath:e,config:i,orientation:Y,loadedImages:l,onFirstImageLoad:o}):r.x=!0,d?p({cdnPath:t,config:n,orientation:k,loadedImages:c,onFirstImageLoad:h?void 0:o}):r.y=!0},P=e=>{const t=document.createElement("div");return t.className="cloudimage-360-icons-container",e.appendChild(t),t},D=(e,t)=>{const i=e.querySelector(t);i&&i.parentNode.removeChild(i)},V=e=>{const t=((e,t)=>{const[i,n]=e.split("?");if(!n)return e;const o=new RegExp(`^${t}=|&${t}=`),s=n.split("&").filter((e=>!o.test(e))).join("&");return s?`${i}?${s}`:i})(e,"width"),i=t.includes("?")?"&":"?";return`${t}${i}width=${150*devicePixelRatio}`},j=(e,t)=>{const{imageList:i,indexZeroBase:n}=t;if(i.length)try{return((e,t)=>{const[i]=e,n=/(https?):\/\//i.test(i);return W({...t,folder:n?"":t.folder,filename:i})})(JSON.parse(i),t)}catch(o){console.error(`Wrong format in image-list attribute: ${o.message}`)}return((e,t)=>{const i=M(1,t);return e.replace("{index}",i)})(e,n)},F=(e,t,i)=>{const n=new Image;return n.setAttribute(t?"data-src":"src",e),n.className=i,n.style.cssText=`\n position: ${t?"absolute":"static"};\n width: 100%;\n inset: 0;\n height: 100%;\n object-fit: contain;\n object-position: center;\n filter: blur(10px);\n `,n},G=(e,t,i)=>{const{innerBox:n,imageList:o,lazyload:s}=t||{},[a]=o,r=a||j(e,t),l=V(r),c=F(l,s,"cloudimage-lazy"),h=F(l,!1,"cloudimage-360-placeholder");var d;c.onload=e=>{D(n,".cloudimage-lazy"),i&&i({event:e,width:c.width,height:c.height,naturalWidth:c.naturalWidth,naturalHeight:c.naturalHeight,src:l})},n.appendChild(c),n.appendChild(h),d=c,new IntersectionObserver(((e,t)=>{e.forEach((e=>{e.isIntersecting&&((e=>{const t=e.getAttribute("data-src");t&&(e.src=t)})(e.target),t.unobserve(e.target))}))}),{root:null,rootMargin:"0px",threshold:.1}).observe(d)},z=(e,t,i)=>{const{container:n,w:o,h:s,zoom:a,bw:r,offsetX:l,offsetY:c}=t,h=((e,t)=>{const i=t.getBoundingClientRect(),n=e.touches?e.touches[0].clientX:e.clientX,o=e.touches?e.touches[0].clientY:e.clientY;return{x:n-i.left,y:o-i.top}})(e,n);let d=h.x,p=h.y;d=Math.max(o/a,Math.min(d,n.offsetWidth-o/a)),p=Math.max(s/a,Math.min(p,n.offsetHeight-s/a)),i.style.left=d-o+"px",i.style.top=p-s+"px";const u=(d-l)*a-o+r,f=(p-c)*a-s+r;i.style.backgroundPosition=`-${u}px -${f}px`},N=(e,{bottom:t,top:i})=>{e?t():i()},U=(e,{left:t,right:i})=>{e?t():i()},$=(e,t)=>{const i=[...R];return t?[...i,...X].includes(e):i.includes(e)},K=(e,t=150)=>{let i;return function(...n){clearTimeout(i),i=setTimeout((()=>{e.apply(this,n)}),t)}},q="IWZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2xldCB0LGUsYSxpLG8sbjtzZWxmLm9ubWVzc2FnZT1hc3luYyB0PT57Y29uc3R7YWN0aW9uOmUsb2Zmc2NyZWVuOmEsZGV2aWNlUGl4ZWxSYXRpbzppLGltYWdlRGF0YTpvLHpvb21TY2FsZTpuLHBvaW50ZXJYOnMscG9pbnRlclk6ZyxpbWFnZUFzcGVjdFJhdGlvOnIsY29udGFpbmVyV2lkdGg6Yyxjb250YWluZXJIZWlnaHQ6Zn09dC5kYXRhO3N3aXRjaChlKXtjYXNlImluaXRDYW52YXMiOmgoYSxpKTticmVhaztjYXNlImFkYXB0Q2FudmFzU2l6ZSI6bShyLGMsZik7YnJlYWs7Y2FzZSJkcmF3SW1hZ2VPbkNhbnZhcyI6ZChvLG4scyxnKX19O2NvbnN0IGg9KGksbyk9Pnt0PWksZT10LmdldENvbnRleHQoIjJkIiksYT1vfSxtPShoLG0sZCk9PntuPWg+bS9kLHQud2lkdGg9bSphLHQuaGVpZ2h0PWQqYSxlLnNjYWxlKGEsYSksbj8oaT1tLG89bS9oKToobz1kLGk9ZCpoKSxlLmltYWdlU21vb3RoaW5nRW5hYmxlZD0hMCxlLmltYWdlU21vb3RoaW5nUXVhbGl0eT0iaGlnaCJ9LGQ9KGg9e30sbT0xLGQ9MCxzPTApPT57Y29uc3R7Yml0bWFwSW1hZ2U6Z309aDtpZighdHx8IWcpcmV0dXJuO2xldCByLGM7aWYobj8ocj0wLGM9KHQuaGVpZ2h0L2EtbykvMik6KHI9KHQud2lkdGgvYS1pKS8yLGM9MCksZS5jbGVhclJlY3QoMCwwLHQud2lkdGgsdC5oZWlnaHQpLDEhPT1tKXtjb25zdHt6b29tZWRXaWR0aDp0LHpvb21lZEhlaWdodDphfT0oKHQsZSxhKT0+KHt6b29tZWRXaWR0aDp0L2Esem9vbWVkSGVpZ2h0OmUvYX0pKShpLG8sbSkse3pvb21PZmZzZXRYOm4sem9vbU9mZnNldFk6Zn09KCh7cG9pbnRlclg6dCxwb2ludGVyWTplLGltYWdlRGF0YTphLHpvb21lZFdpZHRoOmksem9vbWVkSGVpZ2h0Om8sZHJhd1dpZHRoOm4sZHJhd0hlaWdodDpofSk9Pntjb25zdHtuYXR1cmFsV2lkdGg6bSxuYXR1cmFsSGVpZ2h0OmR9PWE7bGV0IHM9dC9uKm0taS8yLGc9ZS9oKmQtby8yO2NvbnN0IHI9TWF0aC5tYXgoMCxtLWkpLGM9TWF0aC5tYXgoMCxkLW8pO3JldHVybiBzPU1hdGgubWF4KDAsTWF0aC5taW4ocyxyKSksZz1NYXRoLm1heCgwLE1hdGgubWluKGcsYykpLHt6b29tT2Zmc2V0WDpzLHpvb21PZmZzZXRZOmd9fSkoe3BvaW50ZXJYOmQscG9pbnRlclk6cyxpbWFnZURhdGE6aCx6b29tZWRXaWR0aDp0LHpvb21lZEhlaWdodDphLGRyYXdXaWR0aDppLGRyYXdIZWlnaHQ6b30pO2UuZHJhd0ltYWdlKGcsbixmLHQsYSxyLGMsaSxvKX1lbHNlIGUuZHJhd0ltYWdlKGcscixjLGksbyl9fSgpOwo=",Q="undefined"!=typeof self&&self.Blob&&new Blob([(J=q,Uint8Array.from(atob(J),(e=>e.charCodeAt(0))))],{type:"text/javascript;charset=utf-8"});var J;function _(e){let t;try{if(t=Q&&(self.URL||self.webkitURL).createObjectURL(Q),!t)throw"";const i=new Worker(t,{name:null==e?void 0:e.name});return i.addEventListener("error",(()=>{(self.URL||self.webkitURL).revokeObjectURL(t)})),i}catch(i){return new Worker("data:text/javascript;base64,"+q,{name:null==e?void 0:e.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}const ee=(e,t,i)=>e.filter((e=>(e=>"x"===e?Y:k)(e.orientation)===i&&t in e.positions)),te=e=>{const t=Object.entries(e).sort((([e],[t])=>Number(e)-Number(t)));let i=null,n=null;const o={};for(const[s,a]of t)if(a){const{x:e,y:t}=a;null!=e&&(i=e),null!=t&&(n=t),o[s]={x:e||i,y:t||n}}else o[s]={x:i,y:n};return o};var ie="top",ne="bottom",oe="right",se="left",ae="auto",re=[ie,ne,oe,se],le="start",ce="end",he="viewport",de="popper",pe=re.reduce((function(e,t){return e.concat([t+"-"+le,t+"-"+ce])}),[]),ue=[].concat(re,[ae]).reduce((function(e,t){return e.concat([t,t+"-"+le,t+"-"+ce])}),[]),fe=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function me(e){return e?(e.nodeName||"").toLowerCase():null}function ge(e){if(null==e)return window;if("[object Window]"!==e.toString()){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function ve(e){return e instanceof ge(e).Element||e instanceof Element}function ye(e){return e instanceof ge(e).HTMLElement||e instanceof HTMLElement}function be(e){return"undefined"!=typeof ShadowRoot&&(e instanceof ge(e).ShadowRoot||e instanceof ShadowRoot)}const we={name:"applyStyles",enabled:!0,phase:"write",fn:function(e){var t=e.state;Object.keys(t.elements).forEach((function(e){var i=t.styles[e]||{},n=t.attributes[e]||{},o=t.elements[e];ye(o)&&me(o)&&(Object.assign(o.style,i),Object.keys(n).forEach((function(e){var t=n[e];!1===t?o.removeAttribute(e):o.setAttribute(e,!0===t?"":t)})))}))},effect:function(e){var t=e.state,i={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,i.popper),t.styles=i,t.elements.arrow&&Object.assign(t.elements.arrow.style,i.arrow),function(){Object.keys(t.elements).forEach((function(e){var n=t.elements[e],o=t.attributes[e]||{},s=Object.keys(t.styles.hasOwnProperty(e)?t.styles[e]:i[e]).reduce((function(e,t){return e[t]="",e}),{});ye(n)&&me(n)&&(Object.assign(n.style,s),Object.keys(o).forEach((function(e){n.removeAttribute(e)})))}))}},requires:["computeStyles"]};function xe(e){return e.split("-")[0]}var Ie=Math.max,Ce=Math.min,Le=Math.round;function Oe(){var e=navigator.userAgentData;return null!=e&&e.brands&&Array.isArray(e.brands)?e.brands.map((function(e){return e.brand+"/"+e.version})).join(" "):navigator.userAgent}function Ye(){return!/^((?!chrome|android).)*safari/i.test(Oe())}function ke(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=!1);var n=e.getBoundingClientRect(),o=1,s=1;t&&ye(e)&&(o=e.offsetWidth>0&&Le(n.width)/e.offsetWidth||1,s=e.offsetHeight>0&&Le(n.height)/e.offsetHeight||1);var a=(ve(e)?ge(e):window).visualViewport,r=!Ye()&&i,l=(n.left+(r&&a?a.offsetLeft:0))/o,c=(n.top+(r&&a?a.offsetTop:0))/s,h=n.width/o,d=n.height/s;return{width:h,height:d,top:c,right:l+h,bottom:c+d,left:l,x:l,y:c}}function Se(e){var t=ke(e),i=e.offsetWidth,n=e.offsetHeight;return Math.abs(t.width-i)<=1&&(i=t.width),Math.abs(t.height-n)<=1&&(n=t.height),{x:e.offsetLeft,y:e.offsetTop,width:i,height:n}}function Re(e,t){var i=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(i&&be(i)){var n=t;do{if(n&&e.isSameNode(n))return!0;n=n.parentNode||n.host}while(n)}return!1}function Xe(e){return ge(e).getComputedStyle(e)}function Ee(e){return["table","td","th"].indexOf(me(e))>=0}function Te(e){return((ve(e)?e.ownerDocument:e.document)||window.document).documentElement}function Ae(e){return"html"===me(e)?e:e.assignedSlot||e.parentNode||(be(e)?e.host:null)||Te(e)}function He(e){return ye(e)&&"fixed"!==Xe(e).position?e.offsetParent:null}function We(e){for(var t=ge(e),i=He(e);i&&Ee(i)&&"static"===Xe(i).position;)i=He(i);return i&&("html"===me(i)||"body"===me(i)&&"static"===Xe(i).position)?t:i||function(e){var t=/firefox/i.test(Oe());if(/Trident/i.test(Oe())&&ye(e)&&"fixed"===Xe(e).position)return null;var i=Ae(e);for(be(i)&&(i=i.host);ye(i)&&["html","body"].indexOf(me(i))<0;){var n=Xe(i);if("none"!==n.transform||"none"!==n.perspective||"paint"===n.contain||-1!==["transform","perspective"].indexOf(n.willChange)||t&&"filter"===n.willChange||t&&n.filter&&"none"!==n.filter)return i;i=i.parentNode}return null}(e)||t}function Ze(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function Me(e,t,i){return Ie(e,Ce(t,i))}function Be(e){return Object.assign({},{top:0,right:0,bottom:0,left:0},e)}function Pe(e,t){return t.reduce((function(t,i){return t[i]=e,t}),{})}function De(e){return e.split("-")[1]}var Ve={top:"auto",right:"auto",bottom:"auto",left:"auto"};function je(e){var t,i=e.popper,n=e.popperRect,o=e.placement,s=e.variation,a=e.offsets,r=e.position,l=e.gpuAcceleration,c=e.adaptive,h=e.roundOffsets,d=e.isFixed,p=a.x,u=void 0===p?0:p,f=a.y,m=void 0===f?0:f,g="function"==typeof h?h({x:u,y:m}):{x:u,y:m};u=g.x,m=g.y;var v=a.hasOwnProperty("x"),y=a.hasOwnProperty("y"),b=se,w=ie,x=window;if(c){var I=We(i),C="clientHeight",L="clientWidth";if(I===ge(i)&&"static"!==Xe(I=Te(i)).position&&"absolute"===r&&(C="scrollHeight",L="scrollWidth"),o===ie||(o===se||o===oe)&&s===ce)w=ne,m-=(d&&I===x&&x.visualViewport?x.visualViewport.height:I[C])-n.height,m*=l?1:-1;if(o===se||(o===ie||o===ne)&&s===ce)b=oe,u-=(d&&I===x&&x.visualViewport?x.visualViewport.width:I[L])-n.width,u*=l?1:-1}var O,Y=Object.assign({position:r},c&&Ve),k=!0===h?function(e,t){var i=e.x,n=e.y,o=t.devicePixelRatio||1;return{x:Le(i*o)/o||0,y:Le(n*o)/o||0}}({x:u,y:m},ge(i)):{x:u,y:m};return u=k.x,m=k.y,l?Object.assign({},Y,((O={})[w]=y?"0":"",O[b]=v?"0":"",O.transform=(x.devicePixelRatio||1)<=1?"translate("+u+"px, "+m+"px)":"translate3d("+u+"px, "+m+"px, 0)",O)):Object.assign({},Y,((t={})[w]=y?m+"px":"",t[b]=v?u+"px":"",t.transform="",t))}var Fe={passive:!0};var Ge={left:"right",right:"left",bottom:"top",top:"bottom"};function ze(e){return e.replace(/left|right|bottom|top/g,(function(e){return Ge[e]}))}var Ne={start:"end",end:"start"};function Ue(e){return e.replace(/start|end/g,(function(e){return Ne[e]}))}function $e(e){var t=ge(e);return{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function Ke(e){return ke(Te(e)).left+$e(e).scrollLeft}function qe(e){var t=Xe(e),i=t.overflow,n=t.overflowX,o=t.overflowY;return/auto|scroll|overlay|hidden/.test(i+o+n)}function Qe(e){return["html","body","#document"].indexOf(me(e))>=0?e.ownerDocument.body:ye(e)&&qe(e)?e:Qe(Ae(e))}function Je(e,t){var i;void 0===t&&(t=[]);var n=Qe(e),o=n===(null==(i=e.ownerDocument)?void 0:i.body),s=ge(n),a=o?[s].concat(s.visualViewport||[],qe(n)?n:[]):n,r=t.concat(a);return o?r:r.concat(Je(Ae(a)))}function _e(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function et(e,t,i){return t===he?_e(function(e,t){var i=ge(e),n=Te(e),o=i.visualViewport,s=n.clientWidth,a=n.clientHeight,r=0,l=0;if(o){s=o.width,a=o.height;var c=Ye();(c||!c&&"fixed"===t)&&(r=o.offsetLeft,l=o.offsetTop)}return{width:s,height:a,x:r+Ke(e),y:l}}(e,i)):ve(t)?function(e,t){var i=ke(e,!1,"fixed"===t);return i.top=i.top+e.clientTop,i.left=i.left+e.clientLeft,i.bottom=i.top+e.clientHeight,i.right=i.left+e.clientWidth,i.width=e.clientWidth,i.height=e.clientHeight,i.x=i.left,i.y=i.top,i}(t,i):_e(function(e){var t,i=Te(e),n=$e(e),o=null==(t=e.ownerDocument)?void 0:t.body,s=Ie(i.scrollWidth,i.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),a=Ie(i.scrollHeight,i.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),r=-n.scrollLeft+Ke(e),l=-n.scrollTop;return"rtl"===Xe(o||i).direction&&(r+=Ie(i.clientWidth,o?o.clientWidth:0)-s),{width:s,height:a,x:r,y:l}}(Te(e)))}function tt(e,t,i,n){var o="clippingParents"===t?function(e){var t=Je(Ae(e)),i=["absolute","fixed"].indexOf(Xe(e).position)>=0&&ye(e)?We(e):e;return ve(i)?t.filter((function(e){return ve(e)&&Re(e,i)&&"body"!==me(e)})):[]}(e):[].concat(t),s=[].concat(o,[i]),a=s[0],r=s.reduce((function(t,i){var o=et(e,i,n);return t.top=Ie(o.top,t.top),t.right=Ce(o.right,t.right),t.bottom=Ce(o.bottom,t.bottom),t.left=Ie(o.left,t.left),t}),et(e,a,n));return r.width=r.right-r.left,r.height=r.bottom-r.top,r.x=r.left,r.y=r.top,r}function it(e){var t,i=e.reference,n=e.element,o=e.placement,s=o?xe(o):null,a=o?De(o):null,r=i.x+i.width/2-n.width/2,l=i.y+i.height/2-n.height/2;switch(s){case ie:t={x:r,y:i.y-n.height};break;case ne:t={x:r,y:i.y+i.height};break;case oe:t={x:i.x+i.width,y:l};break;case se:t={x:i.x-n.width,y:l};break;default:t={x:i.x,y:i.y}}var c=s?Ze(s):null;if(null!=c){var h="y"===c?"height":"width";switch(a){case le:t[c]=t[c]-(i[h]/2-n[h]/2);break;case ce:t[c]=t[c]+(i[h]/2-n[h]/2)}}return t}function nt(e,t){void 0===t&&(t={});var i=t,n=i.placement,o=void 0===n?e.placement:n,s=i.strategy,a=void 0===s?e.strategy:s,r=i.boundary,l=void 0===r?"clippingParents":r,c=i.rootBoundary,h=void 0===c?he:c,d=i.elementContext,p=void 0===d?de:d,u=i.altBoundary,f=void 0!==u&&u,m=i.padding,g=void 0===m?0:m,v=Be("number"!=typeof g?g:Pe(g,re)),y=p===de?"reference":de,b=e.rects.popper,w=e.elements[f?y:p],x=tt(ve(w)?w:w.contextElement||Te(e.elements.popper),l,h,a),I=ke(e.elements.reference),C=it({reference:I,element:b,strategy:"absolute",placement:o}),L=_e(Object.assign({},b,C)),O=p===de?L:I,Y={top:x.top-O.top+v.top,bottom:O.bottom-x.bottom+v.bottom,left:x.left-O.left+v.left,right:O.right-x.right+v.right},k=e.modifiersData.offset;if(p===de&&k){var S=k[o];Object.keys(Y).forEach((function(e){var t=[oe,ne].indexOf(e)>=0?1:-1,i=[ie,ne].indexOf(e)>=0?"y":"x";Y[e]+=S[i]*t}))}return Y}function ot(e,t,i){return void 0===i&&(i={x:0,y:0}),{top:e.top-t.height-i.y,right:e.right-t.width+i.x,bottom:e.bottom-t.height+i.y,left:e.left-t.width-i.x}}function st(e){return[ie,oe,ne,se].some((function(t){return e[t]>=0}))}function at(e,t,i){void 0===i&&(i=!1);var n,o,s=ye(t),a=ye(t)&&function(e){var t=e.getBoundingClientRect(),i=Le(t.width)/e.offsetWidth||1,n=Le(t.height)/e.offsetHeight||1;return 1!==i||1!==n}(t),r=Te(t),l=ke(e,a,i),c={scrollLeft:0,scrollTop:0},h={x:0,y:0};return(s||!s&&!i)&&(("body"!==me(t)||qe(r))&&(c=(n=t)!==ge(n)&&ye(n)?{scrollLeft:(o=n).scrollLeft,scrollTop:o.scrollTop}:$e(n)),ye(t)?((h=ke(t,!0)).x+=t.clientLeft,h.y+=t.clientTop):r&&(h.x=Ke(r))),{x:l.left+c.scrollLeft-h.x,y:l.top+c.scrollTop-h.y,width:l.width,height:l.height}}function rt(e){var t=new Map,i=new Set,n=[];function o(e){i.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach((function(e){if(!i.has(e)){var n=t.get(e);n&&o(n)}})),n.push(e)}return e.forEach((function(e){t.set(e.name,e)})),e.forEach((function(e){i.has(e.name)||o(e)})),n}var lt={placement:"bottom",modifiers:[],strategy:"absolute"};function ct(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return!t.some((function(e){return!(e&&"function"==typeof e.getBoundingClientRect)}))}function ht(e){void 0===e&&(e={});var t=e,i=t.defaultModifiers,n=void 0===i?[]:i,o=t.defaultOptions,s=void 0===o?lt:o;return function(e,t,i){void 0===i&&(i=s);var o,a,r={placement:"bottom",orderedModifiers:[],options:Object.assign({},lt,s),modifiersData:{},elements:{reference:e,popper:t},attributes:{},styles:{}},l=[],c=!1,h={state:r,setOptions:function(i){var o="function"==typeof i?i(r.options):i;d(),r.options=Object.assign({},s,r.options,o),r.scrollParents={reference:ve(e)?Je(e):e.contextElement?Je(e.contextElement):[],popper:Je(t)};var a,c,p=function(e){var t=rt(e);return fe.reduce((function(e,i){return e.concat(t.filter((function(e){return e.phase===i})))}),[])}((a=[].concat(n,r.options.modifiers),c=a.reduce((function(e,t){var i=e[t.name];return e[t.name]=i?Object.assign({},i,t,{options:Object.assign({},i.options,t.options),data:Object.assign({},i.data,t.data)}):t,e}),{}),Object.keys(c).map((function(e){return c[e]}))));return r.orderedModifiers=p.filter((function(e){return e.enabled})),r.orderedModifiers.forEach((function(e){var t=e.name,i=e.options,n=void 0===i?{}:i,o=e.effect;if("function"==typeof o){var s=o({state:r,name:t,instance:h,options:n}),a=function(){};l.push(s||a)}})),h.update()},forceUpdate:function(){if(!c){var e=r.elements,t=e.reference,i=e.popper;if(ct(t,i)){r.rects={reference:at(t,We(i),"fixed"===r.options.strategy),popper:Se(i)},r.reset=!1,r.placement=r.options.placement,r.orderedModifiers.forEach((function(e){return r.modifiersData[e.name]=Object.assign({},e.data)}));for(var n=0;n<r.orderedModifiers.length;n++)if(!0!==r.reset){var o=r.orderedModifiers[n],s=o.fn,a=o.options,l=void 0===a?{}:a,d=o.name;"function"==typeof s&&(r=s({state:r,options:l,name:d,instance:h})||r)}else r.reset=!1,n=-1}}},update:(o=function(){return new Promise((function(e){h.forceUpdate(),e(r)}))},function(){return a||(a=new Promise((function(e){Promise.resolve().then((function(){a=void 0,e(o())}))}))),a}),destroy:function(){d(),c=!0}};if(!ct(e,t))return h;function d(){l.forEach((function(e){return e()})),l=[]}return h.setOptions(i).then((function(e){!c&&i.onFirstUpdate&&i.onFirstUpdate(e)})),h}}var dt=ht({defaultModifiers:[{name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(e){var t=e.state,i=e.instance,n=e.options,o=n.scroll,s=void 0===o||o,a=n.resize,r=void 0===a||a,l=ge(t.elements.popper),c=[].concat(t.scrollParents.reference,t.scrollParents.popper);return s&&c.forEach((function(e){e.addEventListener("scroll",i.update,Fe)})),r&&l.addEventListener("resize",i.update,Fe),function(){s&&c.forEach((function(e){e.removeEventListener("scroll",i.update,Fe)})),r&&l.removeEventListener("resize",i.update,Fe)}},data:{}},{name:"popperOffsets",enabled:!0,phase:"read",fn:function(e){var t=e.state,i=e.name;t.modifiersData[i]=it({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})},data:{}},{name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(e){var t=e.state,i=e.options,n=i.gpuAcceleration,o=void 0===n||n,s=i.adaptive,a=void 0===s||s,r=i.roundOffsets,l=void 0===r||r,c={placement:xe(t.placement),variation:De(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:o,isFixed:"fixed"===t.options.strategy};null!=t.modifiersData.popperOffsets&&(t.styles.popper=Object.assign({},t.styles.popper,je(Object.assign({},c,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:a,roundOffsets:l})))),null!=t.modifiersData.arrow&&(t.styles.arrow=Object.assign({},t.styles.arrow,je(Object.assign({},c,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})},data:{}},we,{name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(e){var t=e.state,i=e.options,n=e.name,o=i.offset,s=void 0===o?[0,0]:o,a=ue.reduce((function(e,i){return e[i]=function(e,t,i){var n=xe(e),o=[se,ie].indexOf(n)>=0?-1:1,s="function"==typeof i?i(Object.assign({},t,{placement:e})):i,a=s[0],r=s[1];return a=a||0,r=(r||0)*o,[se,oe].indexOf(n)>=0?{x:r,y:a}:{x:a,y:r}}(i,t.rects,s),e}),{}),r=a[t.placement],l=r.x,c=r.y;null!=t.modifiersData.popperOffsets&&(t.modifiersData.popperOffsets.x+=l,t.modifiersData.popperOffsets.y+=c),t.modifiersData[n]=a}},{name:"flip",enabled:!0,phase:"main",fn:function(e){var t=e.state,i=e.options,n=e.name;if(!t.modifiersData[n]._skip){for(var o=i.mainAxis,s=void 0===o||o,a=i.altAxis,r=void 0===a||a,l=i.fallbackPlacements,c=i.padding,h=i.boundary,d=i.rootBoundary,p=i.altBoundary,u=i.flipVariations,f=void 0===u||u,m=i.allowedAutoPlacements,g=t.options.placement,v=xe(g),y=l||(v===g||!f?[ze(g)]:function(e){if(xe(e)===ae)return[];var t=ze(e);return[Ue(e),t,Ue(t)]}(g)),b=[g].concat(y).reduce((function(e,i){return e.concat(xe(i)===ae?function(e,t){void 0===t&&(t={});var i=t,n=i.placement,o=i.boundary,s=i.rootBoundary,a=i.padding,r=i.flipVariations,l=i.allowedAutoPlacements,c=void 0===l?ue:l,h=De(n),d=h?r?pe:pe.filter((function(e){return De(e)===h})):re,p=d.filter((function(e){return c.indexOf(e)>=0}));0===p.length&&(p=d);var u=p.reduce((function(t,i){return t[i]=nt(e,{placement:i,boundary:o,rootBoundary:s,padding:a})[xe(i)],t}),{});return Object.keys(u).sort((function(e,t){return u[e]-u[t]}))}(t,{placement:i,boundary:h,rootBoundary:d,padding:c,flipVariations:f,allowedAutoPlacements:m}):i)}),[]),w=t.rects.reference,x=t.rects.popper,I=new Map,C=!0,L=b[0],O=0;O<b.length;O++){var Y=b[O],k=xe(Y),S=De(Y)===le,R=[ie,ne].indexOf(k)>=0,X=R?"width":"height",E=nt(t,{placement:Y,boundary:h,rootBoundary:d,altBoundary:p,padding:c}),T=R?S?oe:se:S?ne:ie;w[X]>x[X]&&(T=ze(T));var A=ze(T),H=[];if(s&&H.push(E[k]<=0),r&&H.push(E[T]<=0,E[A]<=0),H.every((function(e){return e}))){L=Y,C=!1;break}I.set(Y,H)}if(C)for(var W=function(e){var t=b.find((function(t){var i=I.get(t);if(i)return i.slice(0,e).every((function(e){return e}))}));if(t)return L=t,"break"},Z=f?3:1;Z>0;Z--){if("break"===W(Z))break}t.placement!==L&&(t.modifiersData[n]._skip=!0,t.placement=L,t.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}},{name:"preventOverflow",enabled:!0,phase:"main",fn:function(e){var t=e.state,i=e.options,n=e.name,o=i.mainAxis,s=void 0===o||o,a=i.altAxis,r=void 0!==a&&a,l=i.boundary,c=i.rootBoundary,h=i.altBoundary,d=i.padding,p=i.tether,u=void 0===p||p,f=i.tetherOffset,m=void 0===f?0:f,g=nt(t,{boundary:l,rootBoundary:c,padding:d,altBoundary:h}),v=xe(t.placement),y=De(t.placement),b=!y,w=Ze(v),x="x"===w?"y":"x",I=t.modifiersData.popperOffsets,C=t.rects.reference,L=t.rects.popper,O="function"==typeof m?m(Object.assign({},t.rects,{placement:t.placement})):m,Y="number"==typeof O?{mainAxis:O,altAxis:O}:Object.assign({mainAxis:0,altAxis:0},O),k=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,S={x:0,y:0};if(I){if(s){var R,X="y"===w?ie:se,E="y"===w?ne:oe,T="y"===w?"height":"width",A=I[w],H=A+g[X],W=A-g[E],Z=u?-L[T]/2:0,M=y===le?C[T]:L[T],B=y===le?-L[T]:-C[T],P=t.elements.arrow,D=u&&P?Se(P):{width:0,height:0},V=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},j=V[X],F=V[E],G=Me(0,C[T],D[T]),z=b?C[T]/2-Z-G-j-Y.mainAxis:M-G-j-Y.mainAxis,N=b?-C[T]/2+Z+G+F+Y.mainAxis:B+G+F+Y.mainAxis,U=t.elements.arrow&&We(t.elements.arrow),$=U?"y"===w?U.clientTop||0:U.clientLeft||0:0,K=null!=(R=null==k?void 0:k[w])?R:0,q=A+N-K,Q=Me(u?Ce(H,A+z-K-$):H,A,u?Ie(W,q):W);I[w]=Q,S[w]=Q-A}if(r){var J,_="x"===w?ie:se,ee="x"===w?ne:oe,te=I[x],ae="y"===x?"height":"width",re=te+g[_],ce=te-g[ee],he=-1!==[ie,se].indexOf(v),de=null!=(J=null==k?void 0:k[x])?J:0,pe=he?re:te-C[ae]-L[ae]-de+Y.altAxis,ue=he?te+C[ae]+L[ae]-de-Y.altAxis:ce,fe=u&&he?(ge=Me(pe,te,me=ue))>me?me:ge:Me(u?pe:re,te,u?ue:ce);I[x]=fe,S[x]=fe-te}var me,ge;t.modifiersData[n]=S}},requiresIfExists:["offset"]},{name:"arrow",enabled:!0,phase:"main",fn:function(e){var t,i=e.state,n=e.name,o=e.options,s=i.elements.arrow,a=i.modifiersData.popperOffsets,r=xe(i.placement),l=Ze(r),c=[se,oe].indexOf(r)>=0?"height":"width";if(s&&a){var h=function(e,t){return Be("number"!=typeof(e="function"==typeof e?e(Object.assign({},t.rects,{placement:t.placement})):e)?e:Pe(e,re))}(o.padding,i),d=Se(s),p="y"===l?ie:se,u="y"===l?ne:oe,f=i.rects.reference[c]+i.rects.reference[l]-a[l]-i.rects.popper[c],m=a[l]-i.rects.reference[l],g=We(s),v=g?"y"===l?g.clientHeight||0:g.clientWidth||0:0,y=f/2-m/2,b=h[p],w=v-d[c]-h[u],x=v/2-d[c]/2+y,I=Me(b,x,w),C=l;i.modifiersData[n]=((t={})[C]=I,t.centerOffset=I-x,t)}},effect:function(e){var t=e.state,i=e.options.element,n=void 0===i?"[data-popper-arrow]":i;null!=n&&("string"!=typeof n||(n=t.elements.popper.querySelector(n)))&&Re(t.elements.popper,n)&&(t.elements.arrow=n)},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]},{name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(e){var t=e.state,i=e.name,n=t.rects.reference,o=t.rects.popper,s=t.modifiersData.preventOverflow,a=nt(t,{elementContext:"reference"}),r=nt(t,{altBoundary:!0}),l=ot(a,n),c=ot(r,o,s),h=st(l),d=st(c);t.modifiersData[i]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:h,hasPopperEscaped:d},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":h,"data-popper-escaped":d})}}]});class pt{constructor(e,i,n){t(this,"updateHotspotPosition",((e,t)=>{this.currentActiveIndex=e,this.currentOrientation=t;const i=ee(this.hotspotsConfig,e,t);this.hideHotspots(),i.forEach((t=>this.updateAndShowHotspot(t,e)))})),this.container=i,this.popper=null,this.popperInstance=null,this.hotspotsContainer=(e=>{const t=document.createElement("div");return t.className="cloudimage-360-hotspot-container",e.appendChild(t),t})(this.container),this.hotspotsConfig=(e=>{const t=[...e];return t.forEach(((e,i)=>{const n={...te(e.positions)};t[i].initialPositions=n,t[i].positions=n})),t})(e),this.shouldHidePopper=!0,this.hidePopper=this.hidePopper.bind(this),this.imageAspectRatio=n;const{containerSize:o}=e[0];this.initialContainerSize=o||[i.offsetWidth,i.offsetHeight],this.initHotspots(),this.observeContainerResize()}observeContainerResize(){this.resizeObserver=new ResizeObserver((()=>{const e=this.container.offsetWidth,t=this.container.offsetHeight;this.updateHotspotsForResize(e,t)})),this.resizeObserver.observe(this.container)}updateHotspotsForResize(e,t){this.hotspotsConfig=(({newWidth:e,newHeight:t,initialContainerSize:i,imageAspectRatio:n,hotspotsConfig:o})=>{const[s,a]=i;let r=e,l=t,c=0,h=0;n>e/t?(l=e/n,h=(t-l)/2):(r=t*n,c=(e-r)/2);const d=r/s,p=l/a;return o.map((e=>{const t={};return Object.entries(e.initialPositions).forEach((([e,i])=>{t[e]={x:i.x*d+c,y:i.y*p+h}})),{...e,positions:t}}))})({newWidth:e,newHeight:t,initialContainerSize:this.initialContainerSize,imageAspectRatio:this.imageAspectRatio,hotspotsConfig:this.hotspotsConfig}),this.updateHotspotPosition(this.currentActiveIndex,this.currentOrientation)}showPopper({hotspotElement:e,content:t,id:i,keepOpen:n}){this.popperInstance&&this.popperInstance.instanceId!==i&&this.hidePopper();const o={placement:"top",modifiers:(s=this.container,[{name:"offset",options:{offset:[0,10]}},{name:"preventOverflow",options:{boundary:s}}])};var s;this.popper=((e,t)=>{const i=document.createElement("div");return i.className="cloudimage-360-popper",i.id=`cloudimage-360-popper-${t}`,i.dataset.popperId=t,"string"==typeof e&&/<\/?[a-z][\s\S]*>/i.test(e)?i.innerHTML=e:i.textContent=e,document.body.appendChild(i),i})(t,i),this.popper.setAttribute("data-show",""),this.popper.addEventListener("mouseenter",(()=>{this.shouldHidePopper=!1})),this.popper.addEventListener("mouseleave",(()=>{this.shouldHidePopper=!0,this.checkAndHidePopper()})),e.addEventListener("mouseleave",(()=>{this.shouldHidePopper=!0,this.checkAndHidePopper()})),e.addEventListener("mouseenter",(()=>{this.shouldHidePopper=!1,this.hidePopperTimeout&&clearTimeout(this.hidePopperTimeout)})),this.popperInstance={...dt(e,this.popper,o),keepOpen:n,instanceId:i}}checkAndHidePopper(){var e;this.shouldHidePopper&&!(null==(e=this.popperInstance)?void 0:e.keepOpen)&&(this.hidePopperTimeout=setTimeout((()=>{this.shouldHidePopper&&this.hidePopper()}),150))}hidePopper(){this.popperInstance&&(this.popperInstance.destroy(),this.popperInstance=null),this.popper&&(this.popper.removeAttribute("data-show"),setTimeout((()=>{this.popper&&this.popper.remove(),this.popper=null}),200))}createHotspot(e){const{id:t,content:i,keepOpen:n,onClick:o}=e,s=(e=>{const t=document.createElement("span");return t.id=e,t.className="cloudimage-360-hotspot",t.dataset.hotspotId=e,t})(t);o&&(s.style.cursor="pointer"),s.onclick=e=>{e.stopPropagation(),null==o||o(e,this.popperInstance,t)},i&&s.addEventListener("mouseenter",(()=>this.showPopper({hotspotElement:s,content:i,id:t,keepOpen:n}))),this.hotspotsContainer.appendChild(s)}hideHotspots(){this.hotspotsContainer.querySelectorAll(".cloudimage-360-hotspot").forEach((e=>{e.style.opacity=0,e.style.pointerEvents="none"}))}updateAndShowHotspot(e,t){const{positions:i,id:n}=e,{x:o,y:s}=i[t]??{},a=this.hotspotsContainer.querySelector(`[data-hotspot-id="${n}"]`);a&&(a.style.translate=`${o}px ${s}px`,a.style.opacity=1,a.style.pointerEvents="all")}createAllHotspots(){this.hotspotsConfig.forEach((e=>this.createHotspot(e)))}initHotspots(){this.createAllHotspots()}destroy(){this.resizeObserver.disconnect(),this.hidePopper(),this.hotspotsContainer.innerHTML=""}}class ut{constructor(e,t,i){this.container=e,this.isClicked=!1,this.fullscreenView=!!i,this.imagesX=[],this.imagesY=[],this.devicePixelRatio=Math.round(window.devicePixelRatio||1),this.id=e.id,this.movementStart={x:0,y:0},this.draggingDirection=null,this.isReady=!1,this.currentZoomScale=1,this.touchDevice="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,this.canvasWorker=new _,this.onMoveHandler=this.onMoveHandler.bind(this),this.destroy=this.destroy.bind(this),this.init(this.container,t)}mouseDown(e){if(!this.isReady||this.glass)return;const{pageX:t,pageY:i}=e;(this.autoplay||this.loopTimeoutId)&&(this.stopAutoplay(),this.autoplay=!1),this.movementStart={x:t,y:i},this.isClicked=!0,this.isDragging=!1}mouseUp(){this.isReady&&(this.isZoomed||this.showAllIcons(),this.movementStart={x:0,y:0},this.isClicked=!1,this.innerBox.style.cursor="grab")}drag(e,t){if(!this.isReady||!this.isClicked)return;const i=e-this.movementStart.x,n=t-this.movementStart.y;this.draggingDirection=(({deltaX:e,deltaY:t,reversed:i,allowSpinX:n,allowSpinY:o,threshold:s=0})=>{const a=n&&!o||o&&!n?0:s,r=Math.abs(e),l=Math.abs(t);return n&&r-a>l?i?e>0?"left":"right":e>0?"right":"left":o&&l-a>r?i?t>0?"up":"down":t>0?"down":"up":null})({deltaX:i,deltaY:n,reversed:this.dragReverse,allowSpinX:this.allowSpinX,allowSpinY:this.allowSpinY})||this.draggingDirection;const o=this.fullscreenView?document.body:this.container,s=this.dragSpeed/50,a=s*(this.amountX/o.offsetWidth),r=s*(this.amountY/o.offsetHeight),l=this.allowSpinX?Math.abs(Math.round(i*a)):0,c=this.allowSpinY?Math.abs(Math.round(n*r)):0;(this.allowSpinX&&0!==l||this.allowSpinY&&0!==c)&&(this.hideHotspotPopper(),this.onMoveHandler(this.draggingDirection,l,c),this.movementStart={x:e,y:t},setTimeout((()=>{this.isDragging=!0}),150))}mouseMove(e){this.isReady&&(this.isClicked||this.isZoomed)&&!this.glass&&(this.hideAllIcons(),this.drag(e.pageX,e.pageY),this.isZoomed&&this.applyZoom(e))}mouseClick(e){this.isReady&&!this.isDragging&&(this.glass&&this.magnified?this.removeGlass():!this.pointerZoom||this.glass||this.touchDevice||this.toggleZoom(e))}loadHigherQualityImages(e,t){const i=W(this.srcXConfig,e),n=this.allowSpinY?W(this.srcYConfig,e):null;B({cdnPathX:i,cdnPathY:n,configX:this.srcXConfig,configY:this.srcYConfig,onAllImagesLoad:(e,i)=>{this.imagesX=e,this.imagesY=i,t()}})}hideHotspots(){this.hotspotsInstance&&this.hotspotsInstance.hideHotspots()}hideHotspotPopper(){this.hotspotsInstance&&this.hotspotsInstance.hidePopper()}toggleZoom(e){if(this.isZoomed)this.showTransitionOverlay(),setTimeout((()=>{this.removeZoom()}),800);else{let t=(this.fullscreenView||this.pointerZoom?document.body:this.container).offsetWidth;this.hideHotspots(),this.showLoadingSpinner(),this.loadHigherQualityImages(t,(()=>{this.showTransitionOverlay(),setTimeout((()=>{this.applyZoom(e)}),800)}))}}removeZoom(){this.isZoomed=!1,this.updateView(),this.showAllIcons(),this.hideTransitionOverlay()}applyZoom(e){const{offsetX:t,offsetY:i}=((e,t,i)=>{const{clientX:n,clientY:o}=e,s=t.getBoundingClientRect(),a=t.width/(s.width*i),r=t.height/(s.height*i);return{offsetX:(n-s.left)*a,offsetY:(o-s.top)*r}})(e,this.canvas,this.devicePixelRatio);this.isZoomed=!0,this.hideAllIcons(),this.hideLoadingSpinner(),this.hideTransitionOverlay(),this.updateView(this.pointerZoom,t,i)}touchOutside(e){if(!this.glass)return;!this.canvas.contains(e.target)&&this.removeGlass()}touchStart(e){if(!this.isReady||e.touches.length>1||this.glass)return;const{pageX:t,pageY:i}=e.touches[0];(this.autoplay||this.loopTimeoutId)&&(this.stopAutoplay(),this.autoplay=!1),this.hideAllIcons(),this.movementStart={x:t,y:i},this.isClicked=!0}touchEnd(){this.isReady&&(this.showAllIcons(),this.movementStart={x:0,y:0},this.isClicked=!1)}touchMove(e){if(!this.isReady||!this.isClicked||this.glass)return;const{pageX:t,pageY:i}=e.touches[0];e.preventDefault(),this.drag(t,i)}keyDown(e){if(!this.isReady)return;const{keyCode:t}=e,i=this.keysReverse;switch(this.autoplay&&this.stopAutoplay(),$(t,this.allowSpinY)&&this.hideAllIcons(),t){case 37:i?this.moveLeft():this.moveRight();break;case 39:i?this.moveRight():this.moveLeft();break;case 38:this.allowSpinY&&(e.preventDefault(),i?this.moveTop():this.moveBottom());break;case 40:this.allowSpinY&&(e.preventDefault(),i?this.moveBottom():this.moveTop())}}keyUp(e){const{keyCode:t}=e;$(t,this.allowSpinY)&&this.showAllIcons()}moveActiveXIndexUp(e){this.orientation=Y,this.activeImageX=(this.activeImageX+e)%this.amountX}moveActiveXIndexDown(e){this.orientation=Y,this.activeImageX=(this.activeImageX-e+this.amountX)%this.amountX}moveActiveYIndexUp(e){this.orientation=k,this.activeImageY=(this.activeImageY+e)%this.amountY}moveActiveYIndexDown(e){this.orientation=k,this.activeImageY=(this.activeImageY-e+this.amountY)%this.amountY}moveRight(e,t=1){e&&this.activeImageX>=this.imagesX.length-1||(this.moveActiveXIndexUp(t),this.isZoomed||this.updateView())}moveLeft(e,t=1){e&&this.activeImageX<=0||(this.moveActiveXIndexDown(t),this.isZoomed||this.updateView())}moveTop(e,t=1){e&&this.activeImageY>=this.imagesY.length-1||(this.moveActiveYIndexUp(t),this.isZoomed||this.updateView())}moveBottom(e,t=1){e&&this.activeImageY<=0||(this.moveActiveYIndexDown(t),this.isZoomed||this.updateView())}onMoveHandler(e,t=1,i=1){"right"===e?this.moveRight(this.stopAtEdges,t):"left"===e?this.moveLeft(this.stopAtEdges,t):"up"===e?this.moveTop(this.stopAtEdges,i):"down"===e&&this.moveBottom(this.stopAtEdges,i)}updateView(e,t,i){const n=this.orientation===Y?this.activeImageX:this.activeImageY,o=this.orientation===Y?this.imagesX[this.activeImageX]:this.imagesY[this.activeImageY];!this.hotspotsInstance||this.isZoomed||this.autoplay||this.hotspotsInstance.updateHotspotPosition(n,this.orientation),this.drawImageOnCanvas(o,e,t,i)}updatePercentageInLoader(e=0){this.loader&&(this.loader.innerText=e+"%")}adaptCanvasSize(e){const{naturalWidth:t,naturalHeight:i}=e;this.imageAspectRatio=t/i;const n=this.fullscreenView?window.innerWidth:this.canvas.clientWidth,o=this.fullscreenView?window.innerHeight:this.canvas.clientHeight;this.canvasWorker.postMessage({action:"adaptCanvasSize",devicePixelRatio:this.devicePixelRatio,imageAspectRatio:this.imageAspectRatio,containerWidth:n,containerHeight:o})}drawImageOnCanvas(e,t=1,i=0,n=0){this.canvasWorker.postMessage({action:"drawImageOnCanvas",imageData:e,zoomScale:t,pointerX:i,pointerY:n})}pushImageToSet(e,t,i){i===Y?this.imagesX[t]=e:this.imagesY[t]=e}calculatePercentage(){const e=this.amountX+this.amountY,t=this.imagesX.length+this.imagesY.length;return Math.round(t/e*100)}onImageLoad(e,t,i){this.pushImageToSet(e,t,i),this.updatePercentageInLoader(this.calculatePercentage())}onFirstImageLoaded(e,t){this.createContainers(e),this.adaptCanvasSize(t),this.drawImageOnCanvas(t)}onAllImagesLoaded(){if(this.addAllIcons(),this.hotspots&&(this.hotspotsInstance=new pt(this.hotspots,this.innerBox,this.imageAspectRatio)),this.isReady=!0,this.amountX=this.imagesX.length,this.amountY=this.imagesY.length,this.activeImageX=this.autoplayReverse?this.amountX-1:0,this.activeImageY=this.autoplayReverse?this.amountY-1:0,this.autoplay){this.hideAllIcons();K(this.play.bind(this))()}}magnify(e){e.stopPropagation();const{src:t}=this.orientation===k?this.imagesY[this.activeImageY]:this.imagesX[this.activeImageX],i=(this.fullscreenView?document.body:this.container).offsetWidth*this.magnifier,n=Z(t,i);this.showLoadingSpinner(),this.createGlass();((e,t)=>{const i=new Image;i.src=e,i.onload=n=>{t&&t({event:n,width:i.width,height:i.height,naturalWidth:i.naturalWidth,naturalHeight:i.naturalHeight,src:e})},i.onerror=function(){}})(n,(t=>{this.hideLoadingSpinner(),this.magnified=!0,((e,t,i,n,o,s)=>{const{x:a=0,y:r=0}=i||{},l=(t.offsetWidth-2*a)*s,c=(t.offsetHeight-2*r)*s;if(!o)return;o.setAttribute("class","cloudimage-360-img-magnifier-glass"),t.prepend(o),o.style.backgroundImage=`url('${n.src}')`,o.style.backgroundSize=`${l}px ${c}px`;const h={container:t,w:o.offsetWidth/2,h:o.offsetHeight/2,zoom:s,bw:3,offsetX:a,offsetY:r};z(e,h,o);const d=e=>{z(e,h,o)};o.addEventListener("mousemove",d),t.addEventListener("mousemove",d),t.addEventListener("touchmove",(e=>{e.preventDefault(),z(e,h,o)}))})(e,this.innerBox,this.offset,t,this.glass,this.magnifier)}))}openFullscreenModal(e){e.stopPropagation();const t=(e=>{const t=document.createElement("div");t.className="cloudimage-360-fullscreen-modal";const i=e.cloneNode();return i.style.height="100vh",i.style.maxHeight="100%",t.appendChild(i),window.document.body.appendChild(t),i})(this.container);new ut(t,this.viewerConfig,!0)}closeFullscreenModal(e){e.stopPropagation(),document.body.removeChild(this.container.parentNode),window.document.body.style.overflow="visible"}play(){if(this.isClicked)return;this.hide360ViewCircleIcon();const e=36*this.speed/(this.amountX+this.amountY),t={left:this.moveLeft.bind(this),right:this.moveRight.bind(this),top:this.moveTop.bind(this),bottom:this.moveBottom.bind(this)};this.loopTimeoutId=window.setInterval((()=>{if(this.playOnce&&(({autoplayBehavior:e,activeImageX:t,activeImageY:i,amountX:n,amountY:o,autoplayReverse:s})=>{const a=(e,t)=>s?0===e:e===t-1;switch(e){case C:case I:return a(i,o);default:return a(t,n)}})({autoplayBehavior:this.autoplayBehavior,activeImageX:this.activeImageX,activeImageY:this.activeImageY,amountX:this.amountX,amountY:this.amountY,autoplayReverse:this.autoplayReverse}))return void this.stopAutoplay();(({autoplayBehavior:e,activeImageX:t,activeImageY:i,amountX:n,amountY:o,autoplayReverse:s,spinDirection:a})=>(e===C||e===L)&&("x"===a&&t===(s?0:n-1)||"y"===a&&i===(s?0:o-1)))({autoplayBehavior:this.autoplayBehavior,activeImageX:this.activeImageX,activeImageY:this.activeImageY,amountX:this.amountX,amountY:this.amountY,autoplayReverse:this.autoplayReverse,spinDirection:this.spinDirection})&&(this.spinDirection="x"===this.spinDirection?"y":"x");const e="y"===this.spinDirection;(({autoplayBehavior:e,spinY:t,reversed:i,loopTriggers:n})=>{switch(e){case C:case L:t?N(i,n):U(i,n);break;case I:N(i,n);break;default:U(i,n)}})({autoplayBehavior:this.autoplayBehavior,spinY:e,reversed:this.autoplayReverse,loopTriggers:t})}),e)}stopAutoplay(){this.showAllIcons(),this.autoplay=!1,window.clearTimeout(this.loopTimeoutId)}destroy(){this.stopAutoplay(),this.hotspotsInstance&&this.hotspotsInstance.destroy();const e=this.container,t=e.cloneNode(!0),i=t.querySelector(".cloudimage-360-inner-box");t.removeChild(i),e.parentNode.replaceChild(t,e)}addInitialIcon(){this.initialIcon||(this.initialIcon=(()=>{const e=document.createElement("div");return e.className="cloudimage-initial-icon",e.innerText="360°",e})(),this.innerBox.appendChild(this.initialIcon))}showInitialIcon(){this.initialIcon&&(this.initialIcon.style.opacity=1)}hideInitialIcon(){this.initialIcon&&(this.initialIcon.style.opacity=0)}createGlass(){this.hideAllIcons(),this.glass=document.createElement("div"),this.innerBox.appendChild(this.glass),this.innerBox.style.cursor="default"}removeGlass(){this.showAllIcons(),this.innerBox.removeChild(this.glass),this.glass=null,this.magnified=!1}addMagnifierIcon(){this.magnifier&&(this.magnifierIcon=(()=>{const e=document.createElement("div");return e.className="cloudimage-360-button cloudimage-360-magnifier-button",e.innerHTML="<img alt=\"magnifier icon\" src=data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='20px'%20viewBox='0%20-960%20960%20960'%20width='20px'%20fill='%235f6368'%3e%3cpath%20d='M765-144%20526-383q-30%2022-65.79%2034.5-35.79%2012.5-76.18%2012.5Q284-336%20214-406t-70-170q0-100%2070-170t170-70q100%200%20170%2070t70%20170.03q0%2040.39-12.5%2076.18Q599-464%20577-434l239%20239-51%2051ZM384-408q70%200%20119-49t49-119q0-70-49-119t-119-49q-70%200-119%2049t-49%20119q0%2070%2049%20119t119%2049Z'/%3e%3c/svg%3e>",e})(),this.magnifierIcon.onclick=this.magnify.bind(this),this.iconsContainer.appendChild(this.magnifierIcon))}showMagnifierIcon(){this.magnifierIcon&&(this.magnifierIcon.style.visibility="visible",this.magnifierIcon.style.opacity=1)}hideMagnifierIcon(){this.magnifierIcon&&(this.magnifierIcon.style.visibility="hidden",this.magnifierIcon.style.opacity=0)}addFullscreenIcon(){this.fullscreen&&(this.fullscreenIcon=(()=>{const e=document.createElement("div");return e.className="cloudimage-360-button cloudimage-360-fullscreen-button",e.innerHTML="<img alt=\"fullscreen icon\" src=data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='20px'%20viewBox='0%20-960%20960%20960'%20width='20px'%20fill='%235f6368'%3e%3cpath%20d='M144-144v-192h72v120h120v72H144Zm480%200v-72h120v-120h72v192H624ZM144-624v-192h192v72H216v120h-72Zm600%200v-120H624v-72h192v192h-72Z'/%3e%3c/svg%3e>",e})(),this.fullscreenIcon.onclick=this.openFullscreenModal.bind(this),this.iconsContainer.appendChild(this.fullscreenIcon))}addCloseFullscreenIcon(){this.fullscreenCloseIcon=(()=>{const e=document.createElement("div");return e.className="cloudimage-360-button cloudimage-360-close-icon",e.innerHTML="<img alt=\"close icon\" src=data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='20px'%20viewBox='0%20-960%20960%20960'%20width='20px'%20fill='%235f6368'%3e%3cpath%20d='m147-96-51-51%20261-261H192v-72h288v288h-72v-165L147-96Zm333-384v-288h72v165l261-261%2051%2051-261%20261h165v72H480Z'/%3e%3c/svg%3e>",e})(),this.fullscreenCloseIcon.onclick=this.closeFullscreenModal.bind(this),this.iconsContainer.appendChild(this.fullscreenCloseIcon)}showFullscreenIcon(){this.fullscreenIcon&&(this.fullscreenIcon.style.opacity=1)}hideFullscreenIcon(){this.fullscreenIcon&&(this.fullscreenIcon.style.opacity=0)}add360ViewCircleIcon(){this.view360CircleIcon||(this.view360CircleIcon=(e=>{const t=new Image;return t.src="https://scaleflex.cloudimg.io/v7/plugins/js-cloudimage-360-view/assets/img/360.svg",t.style.bottom=`${e}%`,t.className="cloudimage-360-view-360-circle",t})(this.bottomCircleOffset),this.innerBox.appendChild(this.view360CircleIcon))}show360ViewCircleIcon(){this.view360CircleIcon&&(this.view360CircleIcon.style.opacity=1)}hide360ViewCircleIcon(){this.view360CircleIcon&&(this.view360CircleIcon.style.opacity=0)}addLoadingSpinner(){this.loadingSpinner=(()=>{const e=document.createElement("div");return e.className="cloudimage-loading-spinner",e})(),this.innerBox.appendChild(this.loadingSpinner)}showLoadingSpinner(){this.loadingSpinner&&(this.hideAllIcons(),this.loadingSpinner.style.opacity=1)}createTransitionOverlay(){this.transitionOverlay=(()=>{const e=document.createElement("div");return e.className="cloudimage-360-transition-overlay",e})(),this.innerBox.appendChild(this.transitionOverlay)}showTransitionOverlay(){this.transitionOverlay&&(this.hideAllIcons(),this.transitionOverlay.style.opacity=1)}hideTransitionOverlay(){this.transitionOverlay&&(this.transitionOverlay.style.opacity=0)}hideLoadingSpinner(){this.loadingSpinner&&(this.loadingSpinner.style.opacity=0)}remove360ViewCircleIcon(){this.view360CircleIcon&&(this.innerBox.removeChild(this.view360CircleIcon),this.view360CircleIcon=null)}addAllIcons(){this.removeLoader(),this.innerBox.style.cursor="grab",this.pointerZoom&&(this.createTransitionOverlay(),this.addLoadingSpinner()),this.fullscreenView||this.touchDevice||this.addMagnifierIcon(),this.fullscreenView||this.addFullscreenIcon(),this.initialIconShown&&this.addInitialIcon(),this.bottomCircle||this.add360ViewCircleIcon()}showAllIcons(){this.showInitialIcon(),this.show360ViewCircleIcon(),this.showMagnifierIcon(),this.showFullscreenIcon()}hideAllIcons(){this.hideInitialIcon(),this.hide360ViewCircleIcon(),this.hideMagnifierIcon(),this.hideFullscreenIcon()}removeLoader(){this.loader&&(this.innerBox.removeChild(this.loader),this.loader=null)}attachEvents(e,t,i){e&&this.addMouseEvents(),t&&this.addTouchEvents(),i&&this.addKeyboardEvents()}removeEvents(){this.removeMouseEvents(),this.removeTouchEvents(),this.removeKeyboardEvents()}addMouseEvents(){this.boundMouseClick=this.mouseClick.bind(this),this.boundMouseDown=this.mouseDown.bind(this),this.boundMouseMove=w(this.mouseMove.bind(this),10),this.boundMouseUp=this.mouseUp.bind(this),this.innerBox.addEventListener("click",this.boundMouseClick),this.innerBox.addEventListener("mousedown",this.boundMouseDown),document.addEventListener("mousemove",this.boundMouseMove),document.addEventListener("mouseup",this.boundMouseUp)}addTouchEvents(){this.boundTouchOutside=this.touchOutside.bind(this),this.boundTouchStart=this.touchStart.bind(this),this.boundTouchEnd=this.touchEnd.bind(this),this.boundTouchMove=w(this.touchMove.bind(this),10),document.addEventListener("touchstart",this.boundTouchOutside),this.container.addEventListener("touchstart",this.boundTouchStart),this.container.addEventListener("touchend",this.boundTouchEnd),this.container.addEventListener("touchmove",this.boundTouchMove)}addKeyboardEvents(){this.boundKeyDown=this.keyDown.bind(this),this.boundKeyUp=this.keyUp.bind(this),document.addEventListener("keydown",this.boundKeyDown),document.addEventListener("keyup",this.boundKeyUp)}removeMouseEvents(){this.innerBox.removeEventListener("click",this.boundMouseClick),this.innerBox.removeEventListener("mousedown",this.boundMouseDown),document.removeEventListener("mousemove",this.boundMouseMove),document.removeEventListener("mouseup",this.boundMouseUp)}removeTouchEvents(){document.removeEventListener("touchstart",this.boundTouchOutside),this.container.removeEventListener("touchstart",this.boundTouchStart),this.container.removeEventListener("touchend",this.boundTouchEnd),this.container.removeEventListener("touchmove",this.boundTouchMove)}removeKeyboardEvents(){document.removeEventListener("keydown",this.boundKeyDown),document.removeEventListener("keyup",this.boundKeyUp)}createContainers(e){this.iconsContainer=P(this.innerBox),this.canvas=((e,t)=>{const{width:i,height:n}=t,o=document.createElement("canvas");return o.width=i,o.height=n,o.style.width="100%",o.style.height="auto",e.appendChild(o),o})(this.innerBox,e),this.loader=(e=>{const t=document.createElement("div");t.className="cloudimage-initial-icon";const i=document.createElement("span");return i.className="percentage",i.innerText="0%",t.appendChild(i),e.appendChild(t),t})(this.innerBox);const t=this.canvas.transferControlToOffscreen();this.canvasWorker.postMessage({action:"initCanvas",offscreen:t,devicePixelRatio:this.devicePixelRatio},[t]),this.fullscreenView&&this.addCloseFullscreenIcon(),D(this.innerBox,".cloudimage-360-placeholder")}update(e){this.isReady&&(this.stopAutoplay(),D(this.innerBox,".cloudimage-360-icons-container"),this.init(this.container,e,!0),this.iconsContainer=P(this.innerBox),this.onAllImagesLoaded())}init(e,t,i){const n=t?(e=>({folder:e.folder||E.folder,apiVersion:e.apiVersion||E.apiVersion,filenameX:e.filenameX||e.filename||E.filenameX,filenameY:e.filenameY||E.filenameY,imageListX:e.imageListX||E.imageListX,imageListY:e.imageListY||E.imageListY,indexZeroBase:parseInt(e.indexZeroBase??E.indexZeroBase,10),amountX:parseInt(e.amountX??E.amountX,10),amountY:parseInt(e.amountY??E.amountY,10),speed:parseInt(e.speed??E.speed,10),draggable:e.draggable??E.draggable,swipeable:e.swipeable??E.swipeable,dragSpeed:parseInt(e.dragSpeed??E.dragSpeed,10),keys:e.keys??E.keys,keysReverse:e.keysReverse??E.keysReverse,autoplay:e.autoplay??E.autoplay,autoplayBehavior:e.autoplayBehavior||E.autoplayBehavior,playOnce:e.playOnce??E.playOnce,autoplayReverse:e.autoplayReverse??E.autoplayReverse,pointerZoom:parseFloat(e.pointerZoom??E.pointerZoom,10),fullscreen:e.fullscreen??E.fullscreen,magnifier:parseFloat(e.magnifier??E.magnifier,10),bottomCircleOffset:parseInt(e.bottomCircleOffset??E.bottomCircleOffset,10),ciToken:e.ciToken||E.ciToken,ciFilters:e.ciFilters||E.ciFilters,ciTransformation:e.ciTransformation||E.ciTransformation,lazyload:e.lazyload??E.lazyload,dragReverse:e.dragReverse??E.dragReverse,stopAtEdges:e.stopAtEdges??E.stopAtEdges,imageInfo:e.imageInfo??E.imageInfo,initialIconShown:e.initialIconShown??E.initialIconShown,bottomCircle:e.bottomCircle??E.bottomCircle,hotspots:e.hotspots??E.hotspots}))(t):{folder:T(o=e,"folder",E.folder),apiVersion:T(o,"api-version",E.apiVersion),filenameX:T(o,"filename")||T(o,"filename-x")||E.filenameX,filenameY:T(o,"filename-y",E.filenameY),imageListX:T(o,"image-list-x",E.imageListX),imageListY:T(o,"image-list-y",E.imageListY),indexZeroBase:parseInt(T(o,"index-zero-base",E.indexZeroBase),10),amountX:parseInt(T(o,"amount-x",E.amountX),10),amountY:parseInt(T(o,"amount-y",E.amountY),10),speed:parseInt(T(o,"speed",E.speed),10),dragSpeed:parseInt(T(o,"drag-speed",E.dragSpeed),10),draggable:A(o,"draggable",E.draggable),swipeable:A(o,"swipeable",E.swipeable),keys:A(o,"keys",E.keys),keysReverse:A(o,"keys-reverse",E.keysReverse),autoplay:A(o,"autoplay",E.autoplay),autoplayBehavior:T(o,"autoplay-behavior",E.autoplayBehavior),playOnce:A(o,"play-once",E.playOnce),autoplayReverse:A(o,"autoplay-reverse",E.autoplayReverse),pointerZoom:parseFloat(T(o,"pointer-zoom",E.pointerZoom),10),fullscreen:A(o,"fullscreen")||A(o,"full-screen",E.fullscreen),magnifier:parseFloat(T(o,"magnifier",E.magnifier),10),bottomCircleOffset:parseInt(T(o,"bottom-circle-offset",E.bottomCircleOffset),10),ciToken:T(o,"responsive",E.ciToken),ciFilters:T(o,"filters",E.ciFilters),ciTransformation:T(o,"transformation",E.ciTransformation),lazyload:A(o,"lazyload",E.lazyload),dragReverse:A(o,"drag-reverse",E.dragReverse),stopAtEdges:A(o,"stop-at-edges",E.stopAtEdges),imageInfo:A(o,"info",E.imageInfo),initialIconShown:!H(o,"initial-icon"),bottomCircle:!H(o,"bottom-circle")};var o;const{folder:s,apiVersion:a,filenameX:r,filenameY:l,imageListX:c,imageListY:h,indexZeroBase:d,amountX:p,amountY:u,draggable:f=!0,swipeable:m=!0,keys:g,keysReverse:v,bottomCircleOffset:y,autoplay:b,autoplayBehavior:w,playOnce:x,speed:O,autoplayReverse:Y,fullscreen:S,magnifier:R,ciToken:X,ciFilters:Z,ciTransformation:M,lazyload:P,dragSpeed:D,stopAtEdges:V,pointerZoom:j,imageInfo:F="black",initialIconShown:z,bottomCircle:N,hotspots:U,dragReverse:$}=n,K={ciToken:X,ciFilters:Z,ciTransformation:M},q=c?JSON.parse(c):[],Q=h?JSON.parse(h):[];if(this.viewerConfig=n,this.amountX=q.length||p,this.amountY=Q.length||u,this.allowSpinX=!!this.amountX,this.allowSpinY=!!this.amountY,this.activeImageX=Y?this.amountX-1:0,this.activeImageY=Y?this.amountY-1:0,this.bottomCircleOffset=y,this.autoplay=b,this.autoplayBehavior=w,this.playOnce=x,this.speed=O,this.autoplayReverse=Y,this.fullscreen=S,this.magnifier=R>1?Math.min(R,5):0,this.dragSpeed=Math.max(D,50),this.stopAtEdges=V,this.ciParams=K,this.apiVersion=a,this.pointerZoom=j>1?Math.min(j,5):null,this.keysReverse=v,this.info=F,this.keys=g,this.innerBox=this.innerBox??(e=>{const t=document.createElement("div");return t.className="cloudimage-360-inner-box",e.appendChild(t),t})(this.container),this.initialIconShown=z,this.bottomCircle=N,this.spinDirection=((e,t,i)=>{if(!i)return"x";if(!t)return"y";switch(e){case C:return"x";case L:case I:return"y";default:return"x"}})(this.autoplayBehavior,this.allowSpinX,this.allowSpinY),this.dragReverse=$,this.hotspots=U,this.srcXConfig={folder:s,filename:r,imageList:q,container:e,innerBox:this.innerBox,apiVersion:a,ciParams:K,lazyload:P,amount:this.amountX,indexZeroBase:d,autoplayReverse:Y},this.srcYConfig={...this.srcXConfig,filename:l,imageList:Q,orientation:k,amount:this.amountY},i&&this.removeEvents(),this.attachEvents(f,m,g),i)return;const J=(this.fullscreenView?document.body:this.container).offsetWidth,_=this.allowSpinX&&!q.length?W(this.srcXConfig,J):null,ee=this.allowSpinY&&!Q.length?W(this.srcYConfig,J):null,te=e=>{B({cdnPathX:_,cdnPathY:ee,configX:this.srcXConfig,configY:this.srcYConfig,onImageLoad:(e,t,i)=>this.onImageLoad(e,t,i),onFirstImageLoad:t=>this.onFirstImageLoaded(e,t),onAllImagesLoad:this.onAllImagesLoaded.bind(this)})};this.allowSpinX?G(_,this.srcXConfig,te):this.allowSpinY&&G(ee,this.srcYConfig,te)}}class ft{constructor(){this.views=new Map,this.initAll=this.initAll.bind(this),this.getViews=this.getViews.bind(this)}generateId(){return`ci360-${Math.random().toString(36).slice(2,11)}`}init(e,t,i){if(!e)return;const n=e.id||this.generateId();e.id||(e.id=n);const o=new ut(e,t,i);return this.views.set(n,o),o}initAll(e="cloudimage-360"){[...document.querySelectorAll(`.${e}`)].filter(Boolean).forEach((e=>{const t=e.id||this.generateId();e.id||(e.id=t);const i=new ut(e);this.views.set(t,i)}))}destroy(e){const t=this.getViewById(e);t&&(t.destroy(),this.views.delete(e))}destroyAll(){this.views.forEach((e=>{e.destroy()})),this.views.clear()}getViewById(e){return this.views.get(e)}getViews(){return Array.from(this.views.values())}updateView(e,t){const i=this.getViewById(e),n={...i.viewerConfig,...t};if(((e,t,i=S)=>i.some((i=>i in t&&t[i]!==e[i])))(i.viewerConfig,t)){i.destroy();const t=document.getElementById(e);this.init(t,n)}else i.update(n);return i}}return window.CI360=ft,ft}));