import{yieldToMainThread}from"@theme/utilities";import{Component}from"@theme/component";class FlyToCart extends Component{source;useSourceSize=!1;destination;connectedCallback(){super.connectedCallback();const intersectionObserver=new IntersectionObserver(entries=>{let sourceRect=null,destinationRect=null;entries.forEach(entry=>{entry.target===this.source?sourceRect=entry.boundingClientRect:entry.target===this.destination&&(destinationRect=entry.boundingClientRect)}),sourceRect&&destinationRect&&this.#animate(sourceRect,destinationRect),intersectionObserver.disconnect()});intersectionObserver.observe(this.source),intersectionObserver.observe(this.destination)}#animate=async(sourceRect,destinationRect)=>{const startPoint={x:sourceRect.left+sourceRect.width/2,y:sourceRect.top+sourceRect.height/2},endPoint={x:destinationRect.left+destinationRect.width/2,y:destinationRect.top+destinationRect.height/2};this.useSourceSize&&(this.style.setProperty("--width",`${sourceRect.width}px`),this.style.setProperty("--height",`${sourceRect.height}px`)),this.style.setProperty("--start-x",`${startPoint.x}px`),this.style.setProperty("--start-y",`${startPoint.y}px`),this.style.setProperty("--travel-x",`${endPoint.x-startPoint.x}px`),this.style.setProperty("--travel-y",`${endPoint.y-startPoint.y}px`),await yieldToMainThread(),await Promise.allSettled(this.getAnimations().map(a=>a.finished)),this.remove()}}customElements.get("fly-to-cart")||customElements.define("fly-to-cart",FlyToCart);
//# sourceMappingURL=/s/files/1/0677/1399/0759/t/1/assets/fly-to-cart.js.map?v=1783078800
