PageSourceSearch

https://www.hydrafacial.com/cdn/shop/t/31/assets/chunk--Video-PMXHSE2N.vbt.js

js hydrafacial.com collected 2026-09-24 10:32:12 UTC 9,989 bytes, 2 lines download raw bytes

1var VideoCircuitBreaker={failureCount:0,maxFailures:3,resetTime:3e5,lastFailureTime:0,isOpen(){return Date.now()-this.lastFailureTime>this.resetTime?(this.failureCount=0,!1):this.failureCount>=this.maxFailures},recordFailure(){this.failureCount++,this.lastFailureTime=Date.now(),console.warn(`VideoOptimized circuit breaker: ${this.failureCount}/${this.maxFailures} failures`)}},Video=class{constructor(element){this.element=element,this.video=element.querySelector("[data-video-element]"),this.poster=element.querySelector("[data-video-poster]"),this.mobilePosterOnly=element.querySelector("[data-mobile-poster-only]"),this.progressBar=element.querySelector("[data-progress-bar]");const videoOpts=JSON.parse(element.getAttribute("data-video")||"{}"),videoOptimizedOpts=JSON.parse(element.getAttribute("data-video-optimized")||"{}");this.options={...videoOpts,...videoOptimizedOpts},this.videoId=element.getAttribute("data-video-id"),this.playBtns=this.element.querySelectorAll("[data-play]"),this.pauseBtns=this.element.querySelectorAll("[data-pause]"),this.isLoaded=!1,this.isPlaying=!1,this.observer=null,this.handlePlayClick=this.handlePlayClick.bind(this),this.handlePauseClick=this.handlePauseClick.bind(this),this.handleVideoClick=this.handleVideoClick.bind(this),this.updateButtons=this.updateButtons.bind(this),this.init()}init(){try{if(VideoCircuitBreaker.isOpen()){console.warn("VideoOptimized: Circuit breaker open, falling back to simple video"),this.fallbackToSimpleVideo();return}if(this.isMobileDevice=this.isMobile(),this.connectionInfo=this.getConnectionInfo(),!this.shouldLoadVideo()){this.handleMobilePosterOnly();return}this.options.lazy&&!this.options.priority?this.setupLazyLoading():this.options.priority?this.loadVideo():requestAnimationFrame(()=>{this.loadVideo()}),this.setupEventListeners(),this.progressBar&&this.initProgressBar(),this.options&&this.options.inView&&this.initInViewObserver(),this.video&&this.dispatchVideoEnd(),(this.playBtns.length||this.pauseBtns.length)&&this.initPausePlay()}catch(error){console.error("VideoOptimized init error:",error),VideoCircuitBreaker.recordFailure(),this.fallbackToSimpleVideo()}}shouldLoadVideo(){if(this.options.mobilePosterOnly&&this.isMobileDevice)return console.log("VideoOptimized: Mobile poster-only mode enabled, skipping video"),!1;const connection=this.connectionInfo;return connection.isVerySlow?(console.log("VideoOptimized: Very slow connection (2G), showing poster only"),!1):connection.isSlow&&!this.options.priority?(console.log("VideoOptimized: Slow connection detected, skipping non-priority video"),!1):connection.hasDataSaver&&!this.options.priority?(console.log("VideoOptimized: Data saver mode detected, skipping non-priority video"),!1):!0}setupLazyLoading(){const observerOptions={root:null,rootMargin:"50px",threshold:.1};this.observer=new IntersectionObserver(entries=>{entries.forEach(entry=>{entry.isIntersecting&&!this.isLoaded&&(this.loadVideo(),this.observer.unobserve(this.element))})},observerOptions),this.observer.observe(this.element)}async loadVideo(){if(!this.isLoaded)try{this.element.setAttribute("data-loading","true"),await this.loadVideoSources(),this.video.preload==="none"&&(this.video.preload="metadata"),this.options.priority?(this.isLoaded=!0,this.element.setAttribute("data-loaded","true"),this.element.removeAttribute("data-loading"),this.progressiveLoad()):(await this.waitForVideoReady(),this.isLoaded=!0,this.element.setAttribute("data-loaded","true"),this.element.removeAttribute("data-loading")),this.options.autoplay&&this.canAutoplay()&&this.playVideo()}catch(error){console.warn("VideoOptimized: Failed to load video",error),VideoCircuitBreaker.recordFailure(),this.handleLoadError()}}loadVideoSources(){return new Promise(resolve=>{const sources=this.video.querySelectorAll("source[data-src]");if(sources.length===0){resolve();return}let loaded=0;sources.forEach(source=>{const src=source.getAttribute("data-src");src&&(source.setAttribute("src",src),source.removeAttribute("data-src")),loaded++,loaded===sources.length&&(this.video.load(),resolve())})})}waitForVideoReady(){return new Promise((resolve,reject)=>{if(this.video.readyState>=1){resolve();return}const timeoutDuration=this.options.priority?5e3:3e3,timeout=setTimeout(()=>{reject(new Error("Video load timeout"))},timeoutDuration),onLoadedMetadata=()=>{clearTimeout(timeout),this.video.removeEventListener("loadedmetadata",onLoadedMetadata),this.video.removeEventListener("error",onError),resolve()},onError=()=>{clearTimeout(timeout),this.video.removeEventListener("loadedmetadata",onLoadedMetadata),this.video.removeEventListener("error",onError),reject(new Error("Video load error"))};this.video.addEventListener("loadedmetadata",onLoadedMetadata,{once:!0}),this.video.addEventListener("error",onError,{once:!0})})}setupEventListeners(){this.video&&(this.video.addEventListener("play",()=>{this.isPlaying=!0,this.element.setAttribute("data-playing","true")}),this.video.addEventListener("pause",()=>{this.isPlaying=!1,this.element.setAttribute("data-playing","false")}),this.video.addEventListener("ended",()=>{this.isPlaying=!1,this.element.setAttribute("data-playing","false"),this.options.loop&&(this.video.currentTime=0,this.playVideo())})),document.addEventListener("visibilitychange",()=>{document.hidden&&this.isPlaying&&this.video?.pause()})}playVideo(){if(!this.video||!this.isLoaded)return;
1const playPromise=this.video.play();playPromise!==void 0&&playPromise.catch(error=>{console.warn("VideoOptimized: Autoplay failed",error),this.playButton&&(this.playButton.style.opacity="1",this.playButton.style.pointerEvents="auto")})}handleMobilePosterOnly(){this.video&&(this.video.style.display="none"),this.mobilePosterOnly&&(this.mobilePosterOnly.style.display="block"),console.log("VideoOptimized: Using poster-only mode for mobile")}handleLoadError(){this.element.setAttribute("data-error","true"),this.video&&(this.video.style.display="none"),this.poster&&(this.poster.style.opacity="1",this.poster.style.pointerEvents="auto")}isMobile(){return window.innerWidth<768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}getConnectionInfo(){const info={isSlow:!1,isVerySlow:!1,hasDataSaver:!1};if("connection"in navigator){const connection=navigator.connection;connection.effectiveType==="slow-2g"||connection.effectiveType==="2g"?(info.isVerySlow=!0,info.isSlow=!0):connection.effectiveType==="3g"&&connection.downlink<1.5&&(info.isSlow=!0),"saveData"in connection&&(info.hasDataSaver=connection.saveData)}return info}isSlowConnection(){return this.connectionInfo?.isSlow||!1}isVerySlowConnection(){return this.connectionInfo?.isVerySlow||!1}hasDataSaverMode(){return this.connectionInfo?.hasDataSaver||!1}canAutoplay(){return this.video.muted}progressiveLoad(){if(!this.video)return;const handleCanPlay=()=>{this.poster&&(this.poster.style.transition="opacity 0.3s ease-out",this.poster.style.opacity="0"),this.options.autoplay&&this.canAutoplay()&&this.playVideo(),this.video.removeEventListener("canplay",handleCanPlay)},handleError=()=>{console.log("VideoOptimized: Video failed to load, keeping poster"),this.video.removeEventListener("error",handleError)};this.video.addEventListener("canplay",handleCanPlay,{once:!0}),this.video.addEventListener("error",handleError,{once:!0})}fallbackToSimpleVideo(){this.video&&(this.video.querySelectorAll("source[data-src]").forEach(source=>{const src=source.getAttribute("data-src");src&&(source.setAttribute("src",src),source.removeAttribute("data-src"))}),this.video.preload="metadata",this.video.load(),this.isLoaded=!0,this.element.setAttribute("data-loaded","true")),(this.playBtns.length||this.pauseBtns.length)&&this.initPausePlay()}initProgressBar(){this.video.addEventListener("play",()=>{this.progressDuration||(this.progressDuration=this.video.duration),this.progressBar.style.transition=`width ${this.progressDuration}s linear`,this.progressBar.style.width="100%"}),this.video.addEventListener("pause",()=>{this.progressBar.style.width=this.video.currentTime/this.video.duration*100+"%",this.progressDuration=this.video.duration-this.video.currentTime}),this.video.addEventListener("ended",()=>{this.progressBar.style.transition="none",this.progressBar.style.width="0%"})}initInViewObserver(){new IntersectionObserver(([entries])=>{entries.isIntersecting?setTimeout(()=>{this.video.play()},500):this.video.pause()}).observe(this.video)}dispatchVideoEnd(){this.video.addEventListener("ended",()=>{document.dispatchEvent(new CustomEvent("video end",{detail:{video:this.video,changeSlide:this.options.changeSlide}}))})}initPausePlay(){this.updateButtons(),this.video.addEventListener("click",this.handleVideoClick),this.playBtns.forEach(btn=>btn.addEventListener("click",this.handlePlayClick)),this.pauseBtns.forEach(btn=>btn.addEventListener("click",this.handlePauseClick)),this.video.addEventListener("play",this.updateButtons),this.video.addEventListener("pause",this.updateButtons)}handlePlayClick(){this.isLoaded?this.playVideo():this.loadVideo().then(()=>{this.playVideo()})}handlePauseClick(){this.video.pause()}handleVideoClick(){this.video.paused?this.playVideo():this.video.pause()}updateButtons(){this.video.paused?(this.pauseBtns?.forEach(btn=>btn.classList.add("hidden")),this.playBtns?.forEach(btn=>btn.classList.remove("hidden"))):(this.pauseBtns?.forEach(btn=>btn.classList.remove("hidden")),this.playBtns?.forEach(btn=>btn.classList.add("hidden")))}destroy(){this.observer&&this.observer.disconnect(),this.video.removeEventListener("click",this.handleVideoClick),this.playBtns.forEach(btn=>btn.removeEventListener("click",this.handlePlayClick)),this.pauseBtns.forEach(btn=>btn.removeEventListener("click",this.handlePauseClick)),this.video.removeEventListener("play",this.updateButtons),this.video.removeEventListener("pause",this.updateButtons)}},Video_default=Video;export{Video_default as default};
2//# sourceMappingURL=/cdn/shop/t/31/assets/chunk--Video-PMXHSE2N.vbt.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.