"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.default=class{getImageSize(t){let e=t.offsetWidth,l=2;for(;e>>=1;)l<<=1;return l}createStyleElement(){var t;const e=document.head.querySelector("style");if(null===(t=null==e?void 0:e.textContent)||void 0===t?void 0:t.includes(".flwkt-turntable"))return;const l=Object.assign(document.createElement("style"),{textContent:"\n .flwkt-turntable { margin: 0; }\n .flwkt-turntable ul { padding: 0; margin: 0; }\n .flwkt-turntable ul li { list-style: none; display: none; }\n .flwkt-turntable ul li img { width: 100%; }\n .flwkt-turntable ul li.active { display: block; }\n "});document.head.appendChild(l)}isMobile(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}addInteraction(t){const e=t.querySelectorAll("li").length,l=l=>{const n=t.getBoundingClientRect(),a=(l-n.left)/n.width,i=Math.floor((1-a)*e);i>=0&&il(t.touches[0].clientX))):t.addEventListener("mousemove",(t=>l(t.clientX)))}updateActiveImage(t,e){var l;const n=t.querySelectorAll("li");n.forEach((t=>t.classList.remove("active"))),null===(l=n[e])||void 0===l||l.classList.add("active")}addObserver(t){const e=t.getAttribute("data-turntable-file");if(!e)return;new MutationObserver((l=>{l.forEach((l=>{if("attributes"===l.type&&"data-turntable-file"===l.attributeName){const l=t.getAttribute("data-turntable-file");if(l&&l!==e){const e=t.querySelector("ul");e&&e.remove(),this.init(t)}}}))})).observe(t,{attributes:!0,attributeFilter:["data-turntable-file"]})}createImages(t,e,l,n,a){const i=t.appendChild(document.createElement("ul")),r=t.getAttribute("data-turntable-rv"),o=parseInt(r||"15");for(let r=0;r{console.log(t.getAttribute("data-turntable-file"));const e=t.getBoundingClientRect(),l=window.innerHeight;if(e.bottom<0||e.top>l)return;const n=(l-e.top)/(l+e.height),i=Math.max(0,Math.min(360,360*n)),r=Math.floor(i/360*a)%a;this.updateActiveImage(t,r)}))}initAll(){const t=[...document.querySelectorAll("[data-turntable-file]"),...document.querySelectorAll("[data-turntable-short]")];t.length&&t.forEach((t=>{this.init(t)}))}};