import{useInteraction as e}from"@gem-sdk/core";let t=t=>{let{element:n,uid:o}=t,{trigger:r}=e(),d=(e,t)=>{n.current&&(r({event:"gp:rollback:item-selected",selector:`[data-id="${o}"]`,element:n.current}),r({event:"gp:item-selected",selector:`[data-id="${o}"]`,data:{selectedOptions:e,inStock:t},element:n.current}))};return{dispatchInteractionChangeOptions:d,dispatchInteractionChangeOptionsInit:(e,t)=>{let n=()=>{d(e,t),window.removeEventListener("gp:flow-actions-loaded",n)};window.interactionLoaded?d(e,t):window.addEventListener("gp:flow-actions-loaded",n)}}};export{t as useVariantInteraction};
