import{gt as t}from"./vendor-all-1-BfXMvJfI.js";function n(n,e,r,o){var i=this;return n?((n instanceof Element?[n]:"toArray"in n?n.toArray():n).forEach(function(n){n.addEventListener("click",function(u){var a,c,l=e instanceof Function?e(n):e,s=r instanceof Function?r(n):r,f=n.getAttribute("href")||n.getAttributeNS("http://www.w3.org/1999/xlink","href")||n.getAttribute("xlink:href")||(null===(a=n.getElementsByTagName("a")[0])||void 0===a?void 0:a.getAttribute("href")),h=t(i.track(l,s,null!=o?o:{}),null!==(c=i.settings.timeout)&&void 0!==c?c:500);(function(t,n){return!("_blank"!==t.target||!n)})(n,f)||function(t){var n=t;return!!(n.ctrlKey||n.shiftKey||n.metaKey||n.button&&1==n.button)}(u)||f&&(u.preventDefault?u.preventDefault():u.returnValue=!1,h.catch(console.error).then(function(){window.location.href=f}).catch(console.error))},!1)}),this):this}function e(n,e,r,o){var i=this;return n?(n instanceof HTMLFormElement&&(n=[n]),n.forEach(function(n){if(!(n instanceof Element))throw new TypeError("Must pass HTMLElement to trackForm/trackSubmit.");var u=function(u){var a;u.preventDefault?u.preventDefault():u.returnValue=!1;var c=e instanceof Function?e(n):e,l=r instanceof Function?r(n):r;t(i.track(c,l,null!=o?o:{}),null!==(a=i.settings.timeout)&&void 0!==a?a:500).catch(console.error).then(function(){n.submit()}).catch(console.error)},a=window.jQuery||window.Zepto;a?a(n).submit(u):n.addEventListener("submit",u,!1)}),this):this}export{e as form,n as link};