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