import{useInteraction as t}from"@gem-sdk/core";import{useCallback as e}from"react";let r=r=>{let{trigger:a}=t();return e(()=>{let t=document.querySelector(`[data-id="${r}"]`);if(!t)return;let e=JSON.parse(t?.getAttribute("gp-interaction-after-submit")??"{}");Object.keys(e).length<=0||Object.entries(e).forEach(([e])=>{a({event:"gp:after-submit",selector:`[data-id="${r}"]`,data:Number(e),element:t})})},[r,a])},a=({product:t,currentVariant:r,quantity:a})=>e(()=>{let e=new CustomEvent("gp:add-to-cart-success",{detail:{data:{product:t,variant:r,quantity:a}}});window.dispatchEvent(e)},[t,r,a]);export{a as useDispatchCustomEvent,r as useDispatchInteractionEvent};
