import*as e from"@wordpress/interactivity";var t,r,o={d:function(e,t){for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},n=(t={getContext:function(){return e.getContext},getElement:function(){return e.getElement},store:function(){return e.store},useEffect:function(){return e.useEffect},useState:function(){return e.useState}},r={},o.d(r,t),r);(0,n.store)("surecart/video",{state:{get showControls(){const e=(0,n.getContext)();return!!e?.controls&&!!e?.loaded}},callbacks:{loadInView(){const e=(()=>{const[e,t]=(0,n.useState)(!1);return(0,n.useEffect)((()=>{const{ref:e}=(0,n.getElement)(),r=new IntersectionObserver((e=>{let[r]=e;t(r.isIntersecting)}));return r.observe(e),()=>e&&r.unobserve(e)}),[]),e})();(0,n.useEffect)((()=>{const{ref:t}=(0,n.getElement)();e?(t.dataset.src&&!t?.src&&(t.src=t.dataset.src),t.readyState<4&&t.load(),t.autoplay&&t.muted&&t.play()):t.pause()}),[e])},handlePlay(){const{ref:e}=(0,n.getElement)(),t=(0,n.getContext)(),r=e?.querySelector("video")??e??null;t.loaded=!0,r?.play(),Array.from(document.querySelectorAll("video")).filter((e=>e!==r)).forEach((e=>{!e.autoplay&&e.pause()}))},play(){const{ref:e}=(0,n.getElement)(),t=e.querySelector("video");t&&(t?.paused?t.play().catch((e=>console.warn("Video autoplay failed:",e))):t.pause())}}});