(()=>{var X=Object.create;var N=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var Q=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var v=(o,e)=>()=>(o&&(e=o(o=0)),e);var B=(o,e)=>()=>(e||o((e={exports:{}}).exports,e),e.exports);var G=(o,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of J(e))!z.call(o,t)&&t!==r&&N(o,t,{get:()=>e[t],enumerable:!(a=j(e,t))||a.enumerable});return o};var H=(o,e,r)=>(r=o!=null?X(Q(o)):{},G(e||!o||!o.__esModule?N(r,"default",{value:o,enumerable:!0}):r,o));var f=(o,e,r)=>new Promise((a,t)=>{var u=_=>{try{s(r.next(_))}catch(m){t(m)}},P=_=>{try{s(r.throw(_))}catch(m){t(m)}},s=_=>_.done?a(_.value):Promise.resolve(_.value).then(u,P);s((r=r.apply(o,e)).next())});var A,I=v(()=>{A="WebPixel::Render"});var E,L=v(()=>{I();E=o=>shopify.extend(A,o)});var D=v(()=>{L()});var R=v(()=>{D()});var F=B(p=>{R();var O="dcode";E(a=>f(null,[a],function*({analytics:o,browser:e,settings:r}){let t=(r==null?void 0:r.first_touch_or_last)==="first_touch"||(r==null?void 0:r.first_touch_or_last)==="first_touch_nonblocking",u=(r==null?void 0:r.first_touch_or_last)==="first_touch",P=r!=null&&r.cookie_duration?Number(r==null?void 0:r.cookie_duration):10080*60,s=P>-1?P:10080*60,_=(r==null?void 0:r.noref_cookie_identifiers)||["noref"],m=(r==null?void 0:r.ignore_ad_clicks)&&(r==null?void 0:r.ignore_ad_clicks)==="true",W=((r==null?void 0:r.goaffpro_identifiers)||"gfp_ref,ref,aff,wpam_id,click_id").split(",").map(c=>c.trim().toLowerCase()),S=r.shop,h={get:c=>f(null,null,function*(){let i=yield e.localStorage.getItem(c);return i||e.cookie.get(c)}),set:(c,i)=>f(null,null,function*(){yield Promise.all([e.localStorage.setItem(c,i),e.cookie.set(c,i)])})},C=(yield h.get("gfp_api_server"))||(r==null?void 0:r.api_server)||"https://api.goaffpro.com",g=()=>f(null,null,function*(){let c=["ref","source",O,"discount_code","sitestripe","gfp_v_id","gfp_ref_expires"];yield Promise.all(c.map(i=>h.set(i,"")))});function d(c){return f(this,null,function*(){if(s){let i=yield h.get("gfp_ref_expires");if(i&&new Date(i).getTime()<Date.now())return yield g(),""}return yield h.get(c)})}function T(c,i){return f(this,null,function*(){if(c==="ref"&&_.indexOf(i)>-1)return yield g();c==="ref"&&s&&(yield h.set("gfp_ref_expires",String(Date.now()+s*1e3))),yield h.set(c,i)})}o.subscribe("page_viewed",c=>f(null,null,function*(){let i=c.context.document.location.href,l=M(i,W,m),w=yield d("ref");l?l!==w&&!t&&(yield T("ref",l)):!w&&u&&(yield T("ref","organic"));let[b,x,y,k]=yield Promise.all([d("sub_id"),d("ref"),d("gfp_v_id"),d(O)]);if(!x&&!k)return;let n=new URL(C+"/shop");b&&n.searchParams.append("sub_id",b),x&&n.searchParams.append("ref",x),k&&n.searchParams.append("discount_code",k),n.searchParams.append("shop",S),n.searchParams.append("location",i),n.searchParams.append("navigator",c.context.navigator.userAgent),n.searchParams.append("referrer",c.context.document.referrer),y&&n.searchParams.append("visit_id",y),n.searchParams.append("from_shopify_pixel","1")})),o.subscribe("checkout_completed",c=>f(null,null,function*(){let i=c.data,l=c.context,w={id:i.checkout.order.id},[b,x,y,k]=yield Promise.all([d("sub_id"),d("ref"),d("gfp_v_id"),d(O)]);fetch(C+"/order_complete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sub_id:b,from_shopify_pixel:!0,ref:x,discount_code:k,visit_id:y,shop:S,location:l.document.location.href,navigator:l.navigator.userAgent,referrer:l.document.referrer,order_id:w.id,data:w})}).then(n=>f(null,null,function*(){if(n.status===420)return g();yield T("gfp_v_id","")}))}))}));function K(o){return o.has("gclid")||o.has("msclkid")}function M(o,e,r=!1){let a=new URL(o);return r&&K(a.searchParams)?null:U(e,a.search)||U(e,a.hash.substring(1))||V(e,a.href)||e.indexOf("hash")>-1&&a.hash.substring(1)||e.indexOf("subdomain")>-1&&a.host.split(".")[0]}function U(o,e){if(!(!o||o.length===0)&&e.length>0){let r=new URLSearchParams(e.toLowerCase());for(let a of o)if(r.get(a))return r.get(a).trim()}}function V(o,e){let r=o.filter(function(a){return a.startsWith("regexp:")}).map(function(a){return a.substring(7)});for(let a=0;a<r.length;a++){let t=r[a],u=e.match(new RegExp(t,"i"));if(u&&u.length>0)return u[1]}}});var nr=H(F());})();
