(function(){var e=()=>{let e=document.querySelector(`[data-xxdrop]`)||document.querySelector(`script[src^="https://trt."]`);if(!e||!e.src)throw Error(`Script tag with data-xxdrop attribute not found or missing src attribute`);let t=new URL(e.src),n=new URLSearchParams(t.search),r=n.get(`wid`),i=n.get(`src`),a=n.get(`debug`);if(!r)throw Error(`Missing wid query parameter`);if(!i)throw Error(`Missing src query parameter`);return{workspaceId:r,source:(()=>{switch(i){case`shopify`:return`shopify`;case`universal`:return`universal`;default:return`unknown`}})(),debug:a!==null&&a.toLowerCase()===`true`}},t=()=>new URLSearchParams(window.location.search).get(`dropref`),n=()=>{let[e,t]=document.location.host.split(`.`).reverse();return`.${t}.${e.split(`:`)[0]}`},r=e=>{let t=`xx_dropref=${encodeURIComponent(e)}; max-age=604800; Path=/; Domain=${n()}; SameSite=Lax`;document.cookie=t},i=()=>{let e=document.cookie.split(`;`).map(e=>e.split(`=`)).find(([e])=>e.trim()===`xx_dropref`);return e?decodeURIComponent(e[1]):null},a=e=>{localStorage.setItem(`xx_dropref`,e)},o=()=>localStorage.getItem(`xx_dropref`)||null,s=()=>i()||(o()??null),c=e=>{r(e),a(e)},l=!1,u=(e,...t)=>{if(l){if(typeof window.xx_drop_debug==`function`){window.xx_drop_debug(e,...t);return}console[e](...t),window.xx_drop_debug_zone&&(window.xx_drop_debug_zone.innerHTML+=t.map(e=>JSON.stringify(e)).join(` `)+`
`)}},d=(...e)=>u(`debug`,`%c[drop tag]`,`color: #3D3B8E`,...e),f=(...e)=>u(`error`,`%c[drop tag]`,`color: #3D3B8E`,...e),p=e=>l=e,m=e=>fetch(e,{method:`GET`}),h=async(e,t,n)=>m(`https://hbivvpfeok.execute-api.us-west-1.amazonaws.com/production-default/tracking/shopify/cart_token?d=${encodeURIComponent(btoa(JSON.stringify({w:e.workspaceId,ct:t,r:n})))}`),g=async(e,t,n,r,i,a)=>m(`https://hbivvpfeok.execute-api.us-west-1.amazonaws.com/production-default/tracking/shopify/order?d=${encodeURIComponent(btoa(JSON.stringify({w:e.workspaceId,ci:t?`${t}`:void 0,oi:n?`${n}`:void 0,tp:r,cu:i,r:a})))}`),_=async(e,t)=>{if(d(`Executing Shopify source`),window.Shopify?.checkout){d(`Shopify checkout object found, sending order information to the API`);let{customer_id:n,order_id:r,total_price:i,currency:a}=window.Shopify.checkout;return await g(e,n,r,i,a,t),!0}let n=window.location.pathname.match(/^\/checkouts\/c\/([a-f0-9]+)\/(?:thank-you|thank_you)$/);if(n&&n[1]){d(`Shopify thank-you page found, sending cart token to the API`);let r=n[1];return await h(e,r,t),!0}return d(`Execution of Shopify source done, nothing to do`),!1},v=async(e,t,n,r,i,a,o,s,c,l,u)=>m(`https://hbivvpfeok.execute-api.us-west-1.amazonaws.com/production-default/tracking/universal/order?d=${encodeURIComponent(btoa(JSON.stringify({w:e.workspaceId,ci:t?`${t}`:void 0,ce:n,cp:r,cfn:i,cln:a,oi:o?`${o}`:void 0,tp:s?`${s}`:void 0,cu:c?`${c}`:void 0,ca:l?`${l}`:void 0,r:u})))}`),y=async(e,t,n)=>{d(`Sending order to the API`,{order:n,dropref:t});let{created_at:r,customer_id:i,currency:a,order_id:o,total_price:s,customer_email:c,customer_first_name:l,customer_last_name:u,customer_phone:f}=n;return await v(e,i,c,f,l,u,o,s,a,r,t),t!==null},b=e=>{let n=t();if(d(`booting tag`,{droprefFromUrl:n,tag:e,onready:window.xx_drop_onready}),!e)throw f(`tag configuration not found`),Error(`tag configuration not found`);return n||(n=s(),d(n?`dropref found in cookies or local storage`:`no dropref in query params neither in cookies and local storage`)),n&&(d(`keeping dropref`,{dropref:n}),c(n)),n},x=async(e,t,n,r)=>{switch(n){case`order`:switch(e.source){case`shopify`:t&&await _(e,t);break;case`universal`:await y(e,t,r);break;default:f(`unknown source, stopping here`,e.source);return}break}};try{let t=document.location.href.indexOf(`xx_drop_debug`)!==-1;p(t),d(`tag version:`,`2.5.12`);let n=e();if(n.debug=n.debug||t,n.debug){let e=document.createElement(`div`);e.innerHTML=`<div style="position: fixed; top: 0; left: 0; width: 100vw; z-index: 2147483646; background: white"><pre id="xx_drop_debug_zone" style="width: 100%; height: 100%; color: black; padding: 20px; margin: 0;"></pre></div>`;let t=e.children[0];document.body.insertBefore(t,document.body.firstChild)}p(n.debug);let r=typeof window.xx_drop_onready==`function`?window.xx_drop_onready:()=>{},i=b(n);r();let a=window.UseDrop?.commands||[];window.UseDrop=function(e,t){x(n,i,e,t)},a.forEach(e=>{x(n,i,e[0],e[1])}),a.length=0,n.source===`shopify`&&i&&x(n,i,`order`,{}),d(`tag ready`)}catch(e){f(`Critical error during tag execution, stopping.`,e)}})();