import{i as e}from"./helpers.CSMFsAnG.js";import{t}from"./gracefulDecodeURIComponent.BfXxWAgf.js";function n(e,t){return Object.keys(t).reduce(function(n,r){if(r.startsWith(e)){var i=r.substr(e.length);n[i]=t[r]}return n},{})}function r(r,i){var a=document.createElement(`a`);a.href=i;var o=a.search.slice(1).split(`&`).reduce(function(e,n){var r=n.split(`=`),i=r[0],a=r[1];return e[i]=t(a),e},{}),s=[],c=o.ajs_uid,l=o.ajs_event,u=o.ajs_aid,d=e(r.options.useQueryString)?r.options.useQueryString:{},f=d.aid,p=f===void 0?/.+/:f,m=d.uid,h=m===void 0?/.+/:m;if(u){var g=Array.isArray(o.ajs_aid)?o.ajs_aid[0]:o.ajs_aid;p.test(g)&&r.setAnonymousId(g)}if(c){var _=Array.isArray(o.ajs_uid)?o.ajs_uid[0]:o.ajs_uid;if(h.test(_)){var v=n(`ajs_trait_`,o);s.push(r.identify(_,v))}}if(l){var y=Array.isArray(o.ajs_event)?o.ajs_event[0]:o.ajs_event,b=n(`ajs_prop_`,o);s.push(r.track(y,b))}return Promise.all(s)}export{r as queryString};