<!-- 2025-09-12T13:43:03.9314069Z -->
<style>.shoplift-hide { opacity: 0 !important; }</style>
<style id="sl-preview-bar-hide">#preview-bar-iframe, #PBarNextFrameWrapper { display: none !important; }</style>
<script type="text/javascript">(function(rootPath, template, themeRole, themeId, isThemePreview){ /* Generated on 2025-09-22T06:45:00.7844554Z */var tt=Object.defineProperty;var et=(b,S,C)=>S in b?tt(b,S,{enumerable:!0,configurable:!0,writable:!0,value:C}):b[S]=C;var d=(b,S,C)=>et(b,typeof S!="symbol"?S+"":S,C);(function(){"use strict";var b=document.createElement("style");b.textContent=`#shoplift-preview-control{position:fixed;max-width:332px;height:56px;background-color:#141414;z-index:9999;bottom:20px;display:flex;border-radius:8px;box-shadow:13px 22px 7px #0000,9px 14px 7px #00000003,5px 8px 6px #0000000d,2px 4px 4px #00000017,1px 1px 2px #0000001a,0 0 #0000001a;align-items:center;margin:0 auto;left:16px;right:16px;opacity:0;transform:translateY(20px);visibility:hidden;transition:opacity .4s ease-in-out,transform .4s ease-in-out,visibility 0s .4s}#shoplift-preview-control.visible{opacity:1;transform:translateY(0);visibility:visible;transition:opacity .4s ease-in-out,transform .4s ease-in-out,visibility 0s 0s}#shoplift-preview-control *{font-family:Inter,sans-serif;color:#fff;box-sizing:border-box;font-size:16px}#shoplift-preview-variant-title{font-weight:400;line-height:140%;font-size:16px;text-align:start;letter-spacing:-.16px;flex-grow:1;text-wrap:nowrap;overflow:hidden;text-overflow:ellipsis}#shoplift-preview-variant-selector{position:relative;display:block;padding:6px 0;height:100%;min-width:0;flex:1 1 auto}#shoplift-preview-variant-menu-trigger{border:none;cursor:pointer;width:100%;background-color:transparent;padding:0 16px;border-left:1px solid #333;border-right:1px solid #333;height:100%;display:flex;align-items:center;justify-content:start;gap:8px}#shoplift-preview-variant-selector .menu-variant-label{width:24px;height:24px;border-radius:50%;padding:6px;display:flex;justify-content:center;align-items:center;font-size:12px;font-style:normal;font-weight:600;line-height:100%;letter-spacing:-.12px;flex-shrink:0}#shoplift-preview-variant-selector .preview-variant-menu{position:absolute;bottom:110%;transform:translate3d(0,20px,0);visibility:hidden;pointer-events:none;opacity:0;cursor:pointer;background-color:#141414;border:1px solid #141414;border-radius:6px;width:100%;max-height:156px;overflow-y:auto;box-shadow:0 8px 16px #0003;z-index:1;transition:opacity .3s ease-in-out,transform .3s ease-in-out,visibility 0s .3s}#shoplift-preview-variant-selector .preview-variant-menu.preview-variant-menu__visible{visibility:visible;pointer-events:auto;opacity:100;transform:translateZ(0);transition:opacity .3s ease-in-out,transform .3s ease-in-out,visibility 0s 0s}@media screen and (max-width: 400px){#shoplift-preview-variant-selector .preview-variant-menu{position:fixed;left:0;right:0;width:auto;bottom:110%}}#shoplift-preview-variant-selector .preview-variant-menu .preview-variant-menu--item{padding:12px 16px;display:flex;overflow:hidden}#shoplift-preview-variant-selector .preview-variant-menu .preview-variant-menu--item .menu-variant-label{margin-right:6px}#shoplift-preview-variant-selector .preview-variant-menu .preview-variant-menu--item span{overflow:hidden;text-overflow:ellipsis;text-wrap:nowrap;white-space:nowrap;color:#f6f6f6;font-size:14px;font-style:normal;font-weight:500}#shoplift-preview-variant-selector .preview-variant-menu .preview-variant-menu--item:hover{background-color:#545454}#shoplift-preview-variant-selector .preview-variant-menu .preview-variant-menu--item:last-of-type{border-bottom-left-radius:6px;border-bottom-right-radius:6px}#shoplift-preview-variant-selector .preview-variant-menu .preview-variant-menu--item:first-of-type{border-top-left-radius:6px;border-top-right-radius:6px}#shoplift-preview-control div:has(#shoplift-exit-preview-button){padding:0 16px}#shoplift-exit-preview-button{padding:6px 8px;font-weight:500;line-height:75%;border-radius:4px;background-color:transparent;border:none;text-decoration:none}#shoplift-exit-preview-button:hover{cursor:pointer;background-color:#333}`,document.head.appendChild(b);var S=" daum[ /]| deusu/| yadirectfetcher|(?:^|[^g])news(?!sapphire)|(?<! (?:channel/|google/))google(?!(app|/google| pixel))|(?<! cu)bots?(?:\\b|_)|(?<!(?: ya| yandex|^job|inapp;) ?)search|(?<!(?:lib))http|(?<![hg]m)score|@[a-z][\\w-]+\\.|\\(\\)|\\.com|\\b\\d{13}\\b|^<|^[\\w \\.\\-\\(?:\\):]+(?:/v?\\d+(?:\\.\\d+)?(?:\\.\\d{1,10})*?)?(?:,|$)|^[^ ]{50,}$|^\\d+\\b|^\\w+/[\\w\\(\\)]*$|^active|^ad muncher|^amaya|^avsdevicesdk/|^biglotron|^bot|^bw/|^clamav[ /]|^client/|^cobweb/|^custom|^ddg[_-]android|^discourse|^dispatch/\\d|^downcast/|^duckduckgo|^facebook|^getright/|^gozilla/|^hobbit|^hotzonu|^hwcdn/|^jeode/|^jetty/|^jigsaw|^microsoft bits|^movabletype|^mozilla/\\d\\.\\d \\(compatible;?\\)$|^mozilla/\\d\\.\\d \\w*$|^navermailapp|^netsurf|^offline|^owler|^postman|^python|^rank|^read|^reed|^rest|^rss|^snapchat|^space bison|^svn|^swcd |^taringa|^thumbor/|^track|^valid|^w3c|^webbandit/|^webcopier|^wget|^whatsapp|^wordpress|^xenu link sleuth|^yahoo|^yandex|^zdm/\\d|^zoom marketplace/|^{{.*}}$|admin|analyzer|archive|ask jeeves/teoma|bit\\.ly/|bluecoat drtr|browsex|burpcollaborator|capture|catch|check|chrome-lighthouse|chromeframe|classifier|clean|cloud|crawl|cypress/|dareboost|datanyze|dejaclick|detect|dmbrowser|download|evc-batch/|feed|firephp|gomezagent|headless|httrack|hubspot marketing grader|hydra|ibisbrowser|images|insight|inspect|iplabel|ips-agent|java(?!;)|library|mail\\.ru/|manager|measure|neustar wpm|node|nutch|offbyone|optimize|pageburst|pagespeed|parser|perl|phantomjs|pingdom|powermarks|preview|proxy|ptst[ /]\\d|reputation|resolver|retriever|rexx;|rigor|rss\\b|scan|scrape|server|sogou|sparkler/|speedcurve|spider|splash|statuscake|synapse|synthetic|tools|torrent|trace|transcoder|url|virtuoso|wappalyzer|watch|webglance|webkit2png|whatcms/|zgrab",C=/bot|spider|crawl|http|lighthouse/i,x;function q(){if(x instanceof RegExp)return x;try{x=new RegExp(S,"i")}catch{x=C}return x}function H(a){return!!a&&q().test(a)}class I{constructor(){d(this,"timestamp");this.timestamp=new Date}}class $ extends I{constructor(e,i,s){super();d(this,"type");d(this,"testId");d(this,"hypothesisId");this.type=3,this.testId=e,this.hypothesisId=i,this.timestamp=s}}class D extends I{constructor(e){super();d(this,"type");d(this,"path");this.type=4,this.path=e}}class O extends I{constructor(e){super();d(this,"type");d(this,"cart");this.type=5,this.cart=e}}class P extends Error{constructor(){super();d(this,"isBot");this.isBot=!0}}function F(a,t,e){for(const i of t.selectors){const s=a.querySelectorAll(i.cssSelector);for(let r=0;r<s.length;r++)e(t.testId,t.hypothesisId)}V(a,t,(i,s,r,n,o)=>o(s,r),e)}function E(a,t,e){for(const i of t.selectors)L(a,t.testId,t.hypothesisId,i,e??(()=>{}));V(a,t,L,e??(()=>{}))}function M(a){return a.urlPatterns.reduce((t,e)=>{switch(e.operator){case"contains":return t+`.*${e}.*`;case"endsWith":return t+`.*${e}`;case"startsWith":return t+`${e}.*`}},"")}function V(a,t,e,i){new MutationObserver(()=>{for(const r of t.selectors)e(a,t.testId,t.hypothesisId,r,i)}).observe(a.documentElement,{childList:!0,subtree:!0})}function L(a,t,e,i,s){const r=a.querySelectorAll(i.cssSelector);for(let n=0;n<r.length;n++){let o=r.item(n);if(o instanceof HTMLElement&&o.dataset.shoplift!==""){o.dataset.shoplift="";for(const c of i.actions.sort(W))o=N(a,i.cssSelector,o,c)}}return r.length>0&&s?(s(t,e),!0):!1}function N(a,t,e,i){switch(i.type){case"innerHtml":e.innerHTML=i.value;break;case"attribute":z(e,i.scope,i.value);break;case"css":j(a,t,i.value);break;case"js":B(a,e,i);break;case"copy":return G(e);case"remove":J(e);break;case"move":K(e,parseInt(i.value));break}return e}function z(a,t,e){a.setAttribute(t,e)}function j(a,t,e){var s;const i=a.createElement("style");i.innerHTML=`${t} { ${e} }`,(s=a.getElementsByTagName("head")[0])==null||s.appendChild(i)}function B(a,t,e){Function("document","element",`use strict; ${e.value}`)(a,t)}function G(a){const t=a.cloneNode(!0);if(!a.parentNode)throw"Can't copy node outside of DOM";return a.parentNode.insertBefore(t,a.nextSibling),t}function J(a){a.remove()}function K(a,t){if(t===0)return;const e=Array.prototype.slice.call(a.parentElement.children).indexOf(a),i=Math.min(Math.max(e+t,0),a.parentElement.children.length-1);a.parentElement.children.item(i).insertAdjacentElement(t>0?"afterend":"beforebegin",a)}function W(a,t){return _(a)-_(t)}function _(a){return a.type==="copy"||a.type==="remove"?0:1}var y=(a=>(a[a.Template=0]="Template",a[a.Theme=1]="Theme",a[a.UrlRedirect=2]="UrlRedirect",a[a.Script=3]="Script",a[a.Dom=4]="Dom",a[a.Price=5]="Price",a))(y||{});const Z="data:image/svg+xml,%3csvg%20width='12'%20height='12'%20viewBox='0%200%2012%2012'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M9.96001%207.90004C9.86501%207.90004%209.77001%207.86504%209.69501%207.79004L6.43501%204.53004C6.19501%204.29004%205.80501%204.29004%205.56501%204.53004L2.30501%207.79004C2.16001%207.93504%201.92001%207.93504%201.77501%207.79004C1.63001%207.64504%201.63001%207.40504%201.77501%207.26004L5.03501%204.00004C5.56501%203.47004%206.43001%203.47004%206.96501%204.00004L10.225%207.26004C10.37%207.40504%2010.37%207.64504%2010.225%207.79004C10.15%207.86004%2010.055%207.90004%209.96001%207.90004Z'%20fill='white'/%3e%3c/svg%3e",Q="data:image/svg+xml,%3csvg%20width='14'%20height='24'%20viewBox='0%200%2014%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12.3976%2014.5255C12.2833%2013.8788%2012.0498%2013.3024%2011.6952%2012.7961C11.3416%2012.2898%2010.9209%2011.8353%2010.4353%2011.4317C9.94868%2011.0291%209.43546%2010.6488%208.89565%2010.292C8.48487%2010.049%208.09577%209.78565%207.72637%209.50402C7.35697%209.2224%207.08016%208.89503%206.89694%208.51987C6.71273%208.14471%206.67826%207.69533%206.79055%207.1697C6.86345%206.83216%206.97476%206.54647%207.12351%206.31162C7.27324%206.07778%207.47124%205.89986%207.7175%205.77684C7.96377%205.65483%208.21989%205.59383%208.48389%205.59383C8.88087%205.59383%209.17639%205.7016%209.3734%205.91714C9.56943%206.13268%209.68271%206.42345%209.71424%206.78946C9.74576%207.15547%209.72015%207.55401%209.63839%207.98509C9.55663%208.41617%209.43645%208.84724%209.27687%209.27934L13.5127%208.80149C13.9638%207.52656%2014.1017%206.42447%2013.9264%205.49725C13.751%204.56901%2013.2664%203.85122%2012.4724%203.34491C12.239%203.19648%2011.9779%203.07041%2011.6893%202.96569L12.0026%201.50979L9.86397%200L7.3875%201.50979L7.11169%202.78878C6.65166%202.8874%206.21724%203.01957%205.8114%203.19038C4.85292%203.594%204.06684%204.15115%203.45117%204.86385C2.83452%205.57655%202.42571%206.40108%202.22378%207.33847C2.06616%208.06947%202.04942%208.70796%202.17551%209.25087C2.30061%209.7948%202.52028%2010.2828%202.8355%2010.7139C3.14974%2011.145%203.51816%2011.5344%203.93977%2011.881C4.36039%2012.2288%204.782%2012.5521%205.20164%2012.851C5.68334%2013.1702%206.13844%2013.5169%206.56497%2013.8921C6.99052%2014.2672%207.31954%2014.7125%207.55004%2015.228C7.78055%2015.7445%207.81502%2016.3769%207.65347%2017.1262C7.56482%2017.5389%207.43676%2017.8765%207.27028%2018.1388C7.10381%2018.4011%206.89596%2018.5983%206.64772%2018.7295C6.3985%2018.8606%206.12071%2018.9267%205.8114%2018.9267C5.21641%2018.9267%204.79776%2018.6034%204.62833%2018.1632C4.4589%2017.7229%204.47367%2017.2583%204.60075%2016.5639C4.72782%2015.8705%205.05092%2015.1395%205.37107%2014.3699H1.17665C1.17665%2014.3699%200.207341%2016.1115%200.0310135%2017.6762C-0.0655232%2018.5302%200.0635208%2019.2653%200.41519%2019.8844C0.76686%2020.5036%201.33032%2020.9814%202.10655%2021.319C2.39222%2021.443%202.7104%2021.5447%203.05813%2021.623L2.54589%2024H7.17473L7.7047%2021.5386C8.08493%2021.442%208.43857%2021.3231%208.76562%2021.1787C9.73985%2020.7476%2010.52%2020.1427%2011.1071%2019.3649C11.6932%2018.5871%2012.0873%2017.7291%2012.2892%2016.7917C12.4744%2015.9295%2012.5099%2015.1741%2012.3966%2014.5275L12.3976%2014.5255Z'%20fill='white'/%3e%3c/svg%3e";async function Y(a){let t=a.replace(/-/g,"+").replace(/_/g,"/");for(;t.length%4;)t+="=";const e=atob(t),i=Uint8Array.from(e,n=>n.charCodeAt(0)),s=new Blob([i]).stream().pipeThrough(new DecompressionStream("gzip")),r=await new Response(s).text();return JSON.parse(r)}function k(a,t){return typeof t=="string"&&/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d+(?:Z|[+-]\d+)/.test(t)?new Date(t):t}function A(a,t){return t}let R=!1;class X{constructor(t,e,i,s,r,n,o,c,l,h,u){d(this,"temporarySessionKey","Shoplift_Session");d(this,"essentialSessionKey","Shoplift_Essential");d(this,"analyticsSessionKey","Shoplift_Analytics");d(this,"legacySessionKey");d(this,"cssHideClass");d(this,"testConfigs");d(this,"inactiveTestConfigs");d(this,"testsFilteredByAudience");d(this,"sendPageView");d(this,"shopliftDebug");d(this,"gaConfig");d(this,"getCountryTimeout");d(this,"state");d(this,"shopifyAnalyticsId");d(this,"cookie",document.cookie);d(this,"isSyncing",!1);d(this,"isSyncingGA",!1);d(this,"fetch");d(this,"localStorageSet");d(this,"localStorageGet");d(this,"sessionStorageSet",window.sessionStorage.setItem.bind(window.sessionStorage));d(this,"sessionStorageGet",window.sessionStorage.getItem.bind(window.sessionStorage));d(this,"urlParams",new URLSearchParams(window.location.search));d(this,"device");d(this,"logHistory");this.shop=t,this.host=e,this.eventHost=i,this.disableReferrerOverride=c,this.logHistory=[],this.legacySessionKey=`SHOPLIFT_SESSION_${this.shop}`,this.cssHideClass=s?"shoplift-hide":"",this.testConfigs=h.map(m=>({...m,startAt:new Date(m.startAt),statusHistory:m.statusHistory.map(p=>({...p,createdAt:new Date(p.createdAt)}))})),this.inactiveTestConfigs=u,this.sendPageView=!!r,this.shopliftDebug=n===!0,this.gaConfig=o!=={"sendEvents":false,"mode":"gtag"}?o:{sendEvents:!1},this.fetch=window.fetch.bind(window),this.localStorageSet=window.localStorage.setItem.bind(window.localStorage),this.localStorageGet=window.localStorage.getItem.bind(window.localStorage);const g=this.getDeviceType();this.device=g!=="tablet"?g:"mobile",this.state=this.loadState(),this.shopifyAnalyticsId=this.getShopifyAnalyticsId(),this.testsFilteredByAudience=h.filter(m=>m.status=="active"),this.getCountryTimeout=l===1000?1e3:l,this.log("State Loaded",JSON.stringify(this.state))}async init(){var t;try{if(this.log("Shoplift script initializing"),window.Shopify&&window.Shopify.designMode){this.log("Skipping script for design mode");return}if(window.location.href.includes("slScreenshot=true")){this.log("Skipping script for screenshot");return}if(window.location.hostname.endsWith(".edgemesh.com")){this.log("Skipping script for preview");return}if(window.location.href.includes("isShopliftMerchant")){const i=this.urlParams.get("isShopliftMerchant")==="true";this.log("Setting merchant session to %s",i),this.state.temporary.isMerchant=i,this.persistTemporaryState()}if(this.state.temporary.isMerchant){this.log("Setting up preview for merchant"),typeof window.shoplift!="object"&&this.setShopliftStub(),this.state.temporary.previewConfig||this.hidePage(),await this.initPreview(),(t=document.querySelector("#sl-preview-bar-hide"))==null||t.remove();return}if(this.state.temporary.previewConfig=void 0,H(navigator.userAgent))return;if(navigator.userAgent.includes("Chrome/118")){this.log("Random: %o",[Math.random(),Math.random(),Math.random()]);const i=await this.makeRequest({url:`${this.eventHost}/api/v0/events/ip`,method:"get"}).then(s=>s==null?void 0:s.json());this.log(`IP: ${i}`),this.makeRequest({url:`${this.eventHost}/api/v0/logs`,method:"post",data:JSON.stringify(this.debugState(),A)}).catch()}if(this.shopifyAnalyticsId=this.getShopifyAnalyticsId(),this.monitorConsentChange(),this.checkForThemePreview())return;if(!this.disableReferrerOverride&&this.state.temporary.originalReferrer!=null){this.log(`Overriding referrer from '${document.referrer}' to '${this.state.temporary.originalReferrer}'`);const i=this.state.temporary.originalReferrer;delete this.state.temporary.originalReferrer,this.persistTemporaryState(),Object.defineProperty(document,"referrer",{get:()=>i,enumerable:!0,configurable:!0})}if(await this.refreshVisitor(this.shopifyAnalyticsId),await this.handleVisitorTest()){this.log("Redirecting for visitor test");return}this.setShoplift(),this.showPage(),await this.ensureCartAttributesForExistingPriceTests(!1),await this.finalize(),console.log("SHOPLIFT SCRIPT INITIALIZED!")}catch(e){if(e instanceof P)return;throw e}finally{typeof window.shoplift!="object"&&this.setShopliftStub()}}getVariantColor(t){switch(t){case"a":return{text:"#141414",bg:"#E2E2E2"};case"b":return{text:"rgba(255, 255, 255, 1)",bg:"rgba(37, 99, 235, 1)"}}}async initPreview(){const t=this.urlParams.get("previewConfig");if(t){this.state.temporary.previewConfig=void 0,this.log("Setting up the preview"),this.log("Found preview config, writing to temporary state");const e=await Y(t);if(this.state.temporary.previewConfig=e,this.state.temporary.previewConfig.testTypeCategory===y.Price){this.hidePage(!0);const s=this.state.temporary.previewConfig;let r=`${this.host}/api/dom-selectors/${s.storeId}/${s.testId}/${s.isDraft||!1}`;s.shopifyProductId&&(r+=`?productId=${s.shopifyProductId}`);const n=await this.makeJsonRequest({method:"get",url:r}).catch(o=>(this.log("Error getting domSelectors",o),null));s.variants.forEach(o=>{var c;return o.domSelectors=(c=n[o.id])==null?void 0:c.domSelectors})}this.persistTemporaryState();const i=new URL(window.location.toString());i.searchParams.delete("previewConfig"),this.queueRedirect(i)}else if(this.state.temporary.previewConfig){this.showPage();const e=this.state.temporary.previewConfig;e.testTypeCategory===y.Template&&this.handleTemplatePreview(e)&&this.initPreviewControls(e),e.testTypeCategory===y.UrlRedirect&&this.handleUrlPreview(e)&&this.initPreviewControls(e),e.testTypeCategory===y.Script&&this.handleScriptPreview(e)&&this.initPreviewControls(e),e.testTypeCategory===y.Price&&await this.handlePricePreview(e)&&this.initPreviewControls(e)}}initPreviewControls(t){document.addEventListener("DOMContentLoaded",()=>{const e=t.variants.find(p=>p.id===t.currentVariant),i=(e==null?void 0:e.label)||"a",s=t.variants,r=document.createElement("div");r.id="shoplift-preview-control";const n=document.createElement("div"),o=document.createElement("img");o.src=Q,o.height=24,o.width=14,n.style.padding="0 16px",n.style.lineHeight="100%",n.appendChild(o),r.appendChild(n);const c=document.createElement("div");c.id="shoplift-preview-variant-selector";const l=document.createElement("button");l.id="shoplift-preview-variant-menu-trigger";const h=document.createElement("div");h.className="menu-variant-label",h.style.backgroundColor=this.getVariantColor(i).bg,h.style.color=this.getVariantColor(i).text,h.innerText=i.toUpperCase(),l.appendChild(h);const u=document.createElement("span");if(u.id="shoplift-preview-variant-title",u.innerText=e!=null&&e.title?e.title:"Untitled variant "+i.toUpperCase(),l.appendChild(u),s.length>1){const p=document.createElement("img");p.src=Z,p.width=12,p.height=12,l.appendChild(p);const f=document.createElement("div");f.className="preview-variant-menu";for(const v of t.variants.filter(w=>w.id!==t.currentVariant)){const w=document.createElement("div");w.className="preview-variant-menu--item";const T=document.createElement("div");T.className="menu-variant-label",T.style.backgroundColor=this.getVariantColor(v.label).bg,T.style.color=this.getVariantColor(v.label).text,T.style.flexShrink="0",T.innerText=v.label.toUpperCase(),w.appendChild(T);const U=document.createElement("span");U.innerText=v.title?v.title:"Untitled variant "+v.label.toUpperCase(),w.appendChild(U),w.addEventListener("click",()=>{this.pickVariant(v.id)}),f.appendChild(w)}c.appendChild(f),l.addEventListener("click",()=>{f.className!=="preview-variant-menu preview-variant-menu__visible"?f.classList.add("preview-variant-menu__visible"):f.classList.remove("preview-variant-menu__visible")}),document.addEventListener("click",v=>{v.target instanceof Element&&!l.contains(v.target)&&f.className==="preview-variant-menu preview-variant-menu__visible"&&f.classList.remove("preview-variant-menu__visible")})}else l.style.pointerEvents="none",h.style.margin="0";c.appendChild(l),r.appendChild(c);const g=document.createElement("div"),m=document.createElement("button");m.id="shoplift-exit-preview-button",m.innerText="Exit",g.appendChild(m),m.addEventListener("click",()=>{this.exitPreview()}),r.appendChild(g),document.body.appendChild(r),requestAnimationFrame(()=>{r.classList.add("visible")})})}pickVariant(t){var e,i,s,r;if(this.state.temporary.previewConfig){const n=this.state.temporary.previewConfig,o=new URL(window.location.toString());if(n.testTypeCategory===y.UrlRedirect){const c=(e=n.variants.find(l=>l.id===n.currentVariant))==null?void 0:e.redirectUrl;if(o.pathname===c){const l=(i=n.variants.find(h=>h.id===t))==null?void 0:i.redirectUrl;l&&(o.pathname=l)}}if(n.testTypeCategory===y.Template){const c=(s=n.variants.find(l=>l.id===n.currentVariant))==null?void 0:s.pathName;if(c&&o.pathname===c){const l=(r=n.variants.find(h=>h.id===t))==null?void 0:r.pathName;l&&l!==c&&(o.pathname=l)}}n.currentVariant=t,this.persistTemporaryState(),this.queueRedirect(o)}}exitPreview(){var e,i,s,r;const t=new URL(window.location.toString());if(((e=this.state.temporary.previewConfig)==null?void 0:e.testTypeCategory)===y.Template&&t.searchParams.delete("view"),((i=this.state.temporary.previewConfig)==null?void 0:i.testTypeCategory)===y.Script&&t.searchParams.delete("slVariant"),((s=this.state.temporary.previewConfig)==null?void 0:s.testTypeCategory)===y.UrlRedirect){const o=this.state.temporary.previewConfig.variants.filter(l=>l.label!=="a"&&l.redirectUrl!==null).map(l=>l.redirectUrl),c=(r=this.state.temporary.previewConfig.variants.find(l=>l.label==="a"))==null?void 0:r.redirectUrl;o.includes(t.pathname)&&c&&(t.pathname=c)}this.state.temporary.previewConfig=void 0,this.persistTemporaryState(),this.hidePage(),this.queueRedirect(t)}handleTemplatePreview(t){const e=t.currentVariant,i=t.variants.find(n=>n.id===e);if(!i)return!1;this.log("Setting up template preview for type",i.type);const s=new URL(window.location.toString()),r=s.searchParams.get("view");return this.typeFromTemplate()==i.type&&r!==i.affix&&i.affix&&(this.log("Template type matches current variant, redirecting"),s.searchParams.delete("view"),this.log("Setting the new viewParam"),this.hidePage(),s.searchParams.set("view",i.affix),this.queueRedirect(s)),r!==null&&r!==i.affix&&(s.searchParams.delete("view"),this.hidePage(),this.queueRedirect(s)),!0}handleUrlPreview(t){var n;const e=t.currentVariant,i=t.variants.find(o=>o.id===e),s=(n=t.variants.find(o=>o.isControl))==null?void 0:n.redirectUrl;if(!i)return!1;this.log("Setting up URL redirect preview");const r=new URL(window.location.toString());return r.pathname===s&&!i.isControl&&i.redirectUrl!==null&&(this.log("Url matches control, redirecting"),this.hidePage(),r.pathname=i.redirectUrl,this.queueRedirect(r)),!0}handleScriptPreview(t){const e=t.currentVariant,i=t.variants.find(n=>n.id===e);if(!i)return!1;this.log("Setting up script preview");const s=new URL(window.location.toString());return s.searchParams.get("slVariant")!==i.id&&(this.log("current id doesn't match the variant, redirecting"),s.searchParams.delete("slVariant"),this.log("Setting the new slVariantParam"),this.hidePage(),s.searchParams.set("slVariant",i.id),this.queueRedirect(s)),!0}async handlePricePreview(t){const e=t.currentVariant,i=t.variants.find(s=>s.id===e);return i?(this.log("Setting up price preview"),i.domSelectors&&i.domSelectors.length>0&&(E(document,{testId:t.testId,hypothesisId:i.id,selectors:i.domSelectors}),await this.ensureCartAttributesForExistingPriceTests(!0)),!0):!1}async finalize(){const t=await this.getCartState();t!==null&&this.queueCartUpdate(t),this.pruneStateAndSave(),await this.syncAllEvents()}setShoplift(){this.log("Setting up public API");const e=this.urlParams.get("slVariant")==="true",i=e?null:this.urlParams.get("slVariant");window.shoplift={isHypothesisActive:async s=>{if(this.log("Script checking variant for hypothesis '%s'",s),e)return this.log("Forcing variant for hypothesis '%s'",s),!0;if(i!==null)return this.log("Forcing hypothesis '%s'",i),s===i;const r=this.testConfigs.find(o=>o.hypotheses.some(c=>c.id===s));if(!r)return this.log("No test found for hypothesis '%s'",s),!1;const n=this.state.essential.visitorTests.find(o=>o.testId===r.id);return n?(this.log("Active visitor test found",s),n.hypothesisId===s):(await this.manuallySplitVisitor(r),this.testConfigs.some(o=>o.hypotheses.some(c=>c.id===s&&this.state.essential.visitorTests.some(l=>l.hypothesisId===c.id))))},setAnalyticsConsent:async s=>{await this.onConsentChange(s,!0)},getVisitorData:()=>({visitor:this.state.analytics.visitor,visitorTests:this.state.essential.visitorTests.filter(s=>!s.isInvalid).map(s=>{const{shouldSendToGa:r,...n}=s;return n})})}}setShopliftStub(){this.log("Setting up stubbed public API");const e=this.urlParams.get("slVariant")==="true",i=e?null:this.urlParams.get("slVariant");window.shoplift={isHypothesisActive:s=>Promise.resolve(e||s===i),setAnalyticsConsent:()=>Promise.resolve(),getVisitorData:()=>({visitor:null,visitorTests:[]})}}async manuallySplitVisitor(t){this.log("Starting manual split for test '%s'",t.id),await this.handleVisitorTest([t]),this.saveState(),this.syncAllEvents()}async handleVisitorTest(t){await this.filterTestsByAudience(this.testConfigs,this.state.analytics.visitor??this.buildBaseVisitor(),this.state.essential.visitorTests);let e=t?t.filter(i=>this.testsFilteredByAudience.some(s=>s.id===i.id)):[...this.testsForUrl(this.testsFilteredByAudience),...this.domTestsForUrl(this.testsFilteredByAudience)];try{if(e.length===0)return this.log("No tests found"),!1;this.log("Checking for existing visitor test on page");const i=this.getCurrentVisitorHypothesis(e);if(i){this.log("Found current visitor test");const o=this.considerRedirect(i);return o&&(this.log("Redirecting for current visitor test"),this.redirect(i)),o}this.log("No active test relation for test page");const s=this.testsForUrl(this.inactiveTestConfigs.filter(o=>this.testIsPaused(o)&&o.hypotheses.some(c=>this.state.essential.visitorTests.some(l=>l.hypothesisId===c.id)))).map(o=>o.id);if(s.length>0)return this.log("Visitor has paused tests for test page, skipping test assignment: %o",s),!1;if(this.hasThemeAndOtherTestTypes(this.testsFilteredByAudience)){this.log("Store has both theme and non-theme tests");const o=this.visitorActiveTestType();this.log("Current visitor test type is '%s'",o);let c;switch(o){case"templateOrUrlRedirect":this.log("Filtering to non-theme tests"),c=h=>h!=="theme";break;case"theme":this.log("Filtering to theme tests"),c=h=>h==="theme";break;case null:c=Math.random()>.5?(this.log("Filtering to theme tests"),h=>h==="theme"):(this.log("Filtering to non-theme tests"),h=>h!=="theme");break}const l=e.filter(h=>h.hypotheses.every(u=>!u.isControl||!c(u.type)));this.log(`Blocking visitor from being assigned to filtered test IDs: ["${l.map(h=>h.id).join('", "')}"]`),this.state.essential.visitorTests.push(...l.map(h=>({createdAt:new Date,testId:h.id,hypothesisId:null,isThemeTest:h.hypotheses.some(u=>u.type==="theme"),shouldSendToGa:!1,isSaved:!0,isInvalid:!0,themeId:void 0}))),e=e.filter(h=>h.hypotheses.some(u=>u.isControl&&c(u.type)))}if(e.length===0)return this.log("No tests found"),!1;const r=e[Math.floor(Math.random()*e.length)],n=this.pickHypothesis(r);if(n){this.log("Adding local visitor to test '%s', hypothesis '%s'",r.id,n.id),this.queueAddVisitorToTest(r.id,n);const o=this.considerRedirect(n);return o&&(this.log("Redirecting for new test"),this.redirect(n)),o}return this.log("No hypothesis found"),!1}finally{this.includeInDomTests(),this.saveState()}}includeInDomTests(){const t=this.getDomTestsForCurrentUrl(),e=this.getVisitorDomHypothesis(t);for(const i of t){this.log("Evaluating dom test '%s'",i.id);const r=e.find(n=>i.hypotheses.some(o=>n.id===o.id))??this.pickHypothesis(i);if(!r){this.log("Failed to pick hypothesis for test");continue}if(r.isControl){this.log("Control hypothesis - applying DOM selectors and watching for variant selectors");const n=i.hypotheses.filter(o=>o.id!==r.id).flatMap(o=>{var c;return((c=o.domSelectors)==null?void 0:c.map(l=>({...l,testId:i.id})))??[]});n.length>0&&F(document,{testId:i.id,hypothesisId:r.id,selectors:n},o=>{this.queueAddVisitorToTest(o,r),this.syncAllEvents()})}if(!r.domSelectors||r.domSelectors.length===0){this.log("No selectors found, skipping hypothesis");continue}this.log("Watching for selectors"),E(document,{testId:i.id,hypothesisId:r.id,selectors:r.domSelectors},n=>{this.queueAddVisitorToTest(n,r),this.syncAllEvents()})}}considerRedirect(t){if(this.log("Considering redirect for hypothesis '%s'",t.id),t.isControl)return this.log("Skipping redirect for control"),!1;if(t.type==="basicScript"||t.type==="manualScript")return this.log("Skipping redirect for script test"),!1;const e=this.state.essential.visitorTests.find(n=>n.hypothesisId===t.id),i=new URL(window.location.toString()),r=new URLSearchParams(window.location.search).get("view");if(t.type==="theme"){if(!(t.themeId===themeId)){if(this.log("Theme id '%s' is not hypothesis theme ID '%s'",t.themeId,themeId),e&&e.themeId!==t.themeId&&(e.themeId===themeId||!this.isThemePreview()))this.log("On old theme, redirecting and updating local visitor"),e.themeId=t.themeId;else if(this.isThemePreview())return this.log("On non-test theme, skipping redirect"),!1;return this.log("Hiding page to redirect for theme test"),this.hidePage(),!0}return!1}else if(t.type!=="dom"&&t.type!=="price"&&t.affix!==template.suffix&&t.affix!==r||t.redirectPath&&!i.pathname.endsWith(t.redirectPath))return this.log("Hiding page to redirect for template test"),this.hidePage(),!0;return this.log("Not redirecting"),!1}redirect(t){if(this.log("Redirecting to hypothesis '%s'",t.id),t.isControl)return;const e=new URL(window.location.toString());if(e.searchParams.delete("view"),t.redirectPath){const i=RegExp("^(/w{2}-w{2})/").exec(e.pathname);if(i&&i.length>1){const s=i[1];e.pathname=`${s}${t.redirectPath}`}else e.pathname=t.redirectPath}else t.type==="theme"?(e.searchParams.set("_ab","0"),e.searchParams.set("_fd","0"),e.searchParams.set("_sc","1"),e.searchParams.set("preview_theme_id",t.themeId.toString())):t.type!=="urlRedirect"&&e.searchParams.set("view",t.affix);this.queueRedirect(e)}async refreshVisitor(t){if(t===null||!this.state.essential.isFirstLoad||!this.testConfigs.some(i=>i.visitorOption!=="all"))return;this.log("Refreshing visitor"),this.hidePage();const e=await this.getVisitor(t);e&&e.id&&this.updateLocalVisitor(e)}buildBaseVisitor(){return{shopifyAnalyticsId:this.shopifyAnalyticsId,device:this.device,country:null,...this.state.essential.initialState}}getInitialState(){const t=this.getUTMValue("utm_source")??"",e=this.getUTMValue("utm_medium")??"",i=this.getUTMValue("utm_campaign")??"",s=this.getUTMValue("utm_content")??"",r=window.document.referrer,n=this.device;return{createdAt:new Date,utmSource:t,utmMedium:e,utmCampaign:i,utmContent:s,referrer:r,device:n}}checkForThemePreview(){var t,e;return this.log("Checking for theme preview"),window.location.hostname.endsWith(".shopifypreview.com")?(this.log("on shopify preview domain"),this.clearThemeBar(!0,!1,this.state),(t=document.querySelector("#sl-preview-bar-hide"))==null||t.remove(),!1):this.isThemePreview()?this.state.essential.visitorTests.some(i=>i.isThemeTest&&i.hypothesisId!=null&&this.getHypothesis(i.hypothesisId)&&i.themeId===themeId)?(this.log("On active theme test, removing theme bar"),this.clearThemeBar(!1,!0,this.state),!1):this.state.essential.visitorTests.some(i=>i.isThemeTest&&i.hypothesisId!=null&&!this.getHypothesis(i.hypothesisId)&&i.themeId===themeId)?(this.log("Visitor is on an inactive theme test, redirecting to main theme"),this.redirectToMainTheme(),!0):this.state.essential.isFirstLoad?(this.log("No visitor found on theme preview, redirecting to main theme"),this.redirectToMainTheme(),!0):this.inactiveTestConfigs.some(i=>i.hypotheses.some(s=>s.themeId===themeId))?(this.log("Current theme is an inactive theme test, redirecting to main theme"),this.redirectToMainTheme(),!0):this.testConfigs.some(i=>i.hypotheses.some(s=>s.themeId===themeId))?(this.log("Falling back to clearing theme bar"),this.clearThemeBar(!1,!0,this.state),!1):(this.log("No tests on current theme, skipping script"),this.clearThemeBar(!0,!1,this.state),(e=document.querySelector("#sl-preview-bar-hide"))==null||e.remove(),!0):(this.log("Not on theme preview"),this.clearThemeBar(!0,!1,this.state),!1)}redirectToMainTheme(){this.hidePage();const t=new URL(window.location.toString());t.searchParams.set("preview_theme_id",""),this.queueRedirect(t)}testsForUrl(t){const e=new URL(window.location.href),i=this.typeFromTemplate();return t.filter(s=>s.hypotheses.some(r=>r.type!=="dom"&&r.type!=="price"&&(r.isControl&&r.type===i&&r.affix===template.suffix||r.type==="theme"||r.isControl&&r.type==="urlRedirect"&&r.redirectPath&&e.pathname.endsWith(r.redirectPath)||r.type==="basicScript"))&&(s.ignoreTestViewParameterEnforcement||!e.searchParams.has("view")||s.hypotheses.map(r=>r.affix).includes(e.searchParams.get("view")??"")))}domTestsForUrl(t){const e=new URL(window.location.href);return t.filter(i=>i.hypotheses.some(s=>(s.type==="dom"||s.type==="price")&&s.domSelectors&&s.domSelectors.some(r=>new RegExp(M(r)).test(e.toString()))))}async filterTestsByAudience(t,e,i){const s=[];let r=e.country;!r&&t.some(n=>n.requiresCountry&&!i.some(o=>o.testId===n.id))&&(this.log("Hiding page to check geoip"),this.hidePage(),r=await this.makeJsonRequest({method:"get",url:`${this.eventHost}/api/v0/visitors/get-country`,signal:AbortSignal.timeout(this.getCountryTimeout)}).catch(n=>(this.log("Error getting country",n),null)));for(const n of t){if(this.log("Checking audience for test '%s'",n.id),this.state.essential.visitorTests.some(l=>l.testId===n.id&&l.hypothesisId==null)){console.log(`Skipping blocked test '${n.id}'`);continue}const o=this.visitorCreatedDuringTestActive(n.statusHistory);(i.some(l=>l.testId===n.id&&(n.device==="all"||n.device===e.device&&n.device===this.device))||this.isTargetAudience(n,e,o,r))&&(this.log("Visitor is in audience for test '%s'",n.id),s.push(n))}this.testsFilteredByAudience=s}isTargetAudience(t,e,i,s){const r=this.getChannel(e);return(t.device==="all"||t.device===e.device&&t.device===this.device)&&(t.visitorOption==="all"||t.visitorOption==="new"&&i||t.visitorOption==="returning"&&!i)&&(t.targetAudiences.length===0||t.targetAudiences.reduce((n,o)=>n||o.reduce((c,l)=>c&&l(e,i,r,s),!0),!1))}visitorCreatedDuringTestActive(t){let e="";for(const i of t){if(this.state.analytics.visitor!==null&&this.state.analytics.visitor.createdAt<i.createdAt||this.state.essential.initialState.createdAt<i.createdAt)break;e=i.status}return e==="active"}getDomTestsForCurrentUrl(){return this.domTestsForUrl(this.testsFilteredByAudience)}getCurrentVisitorHypothesis(t){return t.flatMap(e=>e.hypotheses).find(e=>e.type!=="dom"&&e.type!=="price"&&this.state.essential.visitorTests.some(i=>i.hypothesisId===e.id))}getVisitorDomHypothesis(t){return t.flatMap(e=>e.hypotheses).filter(e=>(e.type==="dom"||e.type==="price")&&this.state.essential.visitorTests.some(i=>i.hypothesisId===e.id))}getHypothesis(t){return this.testConfigs.filter(e=>e.hypotheses.some(i=>i.id===t)).map(e=>e.hypotheses.find(i=>i.id===t))[0]}hasThemeTest(t){return t.some(e=>e.hypotheses.some(i=>i.type==="theme"))}hasTestThatIsNotThemeTest(t){return t.some(e=>e.hypotheses.some(i=>i.type!=="theme"&&i.type!=="dom"&&i.type!=="price"))}hasThemeAndOtherTestTypes(t){return this.hasThemeTest(t)&&this.hasTestThatIsNotThemeTest(t)}testIsPaused(t){return t.status==="paused"||t.status==="incompatible"||t.status==="suspended"}visitorActiveTestType(){const t=this.state.essential.visitorTests.filter(e=>this.testConfigs.some(i=>i.hypotheses.some(s=>s.id==e.hypothesisId)));return t.length===0?null:t.some(e=>e.isThemeTest)?"theme":"templateOrUrlRedirect"}pickHypothesis(t){let e=Math.random();const i=t.hypotheses.reduce((r,n)=>r+n.visitorCount,0);return t.hypotheses.sort((r,n)=>r.isControl?n.isControl?0:-1:n.isControl?1:0).reduce((r,n)=>{if(r!==null)return r;const c=t.hypotheses.reduce((l,h)=>l&&h.visitorCount>20,!0)?n.visitorCount/i-n.trafficPercentage:0;return e<=n.trafficPercentage-c?n:(e-=n.trafficPercentage,null)},null)}typeFromTemplate(){switch(template.type){case"collection-list":return"collectionList";case"page":return"landing";case"article":case"blog":case"cart":case"collection":case"index":case"product":case"search":return template.type;default:return null}}queueRedirect(t){this.saveState(),this.disableReferrerOverride||(this.log(`Saving temporary referrer override '${document.referrer}'`),this.state.temporary.originalReferrer=document.referrer,this.persistTemporaryState()),window.setTimeout(()=>window.location.assign(t),0),window.setTimeout(()=>void this.syncAllEvents(),2e3)}async syncAllEvents(){const t=async()=>{if(this.isSyncing){window.setTimeout(()=>void(async()=>await t())(),500);return}try{this.isSyncing=!0,await this.syncEvents(),this.syncGAEvents()}finally{this.isSyncing=!1}};await t()}async syncEvents(){var i,s;if(!this.state.essential.consentApproved||!this.shopifyAnalyticsId||this.state.analytics.queue.length===0)return;const t=this.state.analytics.queue.length,e=this.state.analytics.queue.splice(0,t);this.log("Syncing %s events",t);try{const r={shop:this.shop,visitorDetails:{shopifyAnalyticsId:this.shopifyAnalyticsId,device:((i=this.state.analytics.visitor)==null?void 0:i.device)??this.device,country:((s=this.state.analytics.visitor)==null?void 0:s.country)??null,...this.state.essential.initialState},events:this.state.essential.visitorTests.filter(o=>!o.isInvalid&&!o.isSaved&&o.hypothesisId!=null).map(o=>new $(o.testId,o.hypothesisId,o.createdAt)).concat(e)};await this.sendEvents(r);const n=await this.getVisitor(this.shopifyAnalyticsId);n!==null&&this.updateLocalVisitor(n);for(const o of this.state.essential.visitorTests.filter(c=>!c.isInvalid&&!c.isSaved))o.isSaved=!0}catch{this.state.analytics.queue.splice(0,0,...e)}finally{this.saveState()}}syncGAEvents(){if(!this.gaConfig.sendEvents){if(R)return;R=!0,this.log("UseGtag is false — skipping GA Events");return}if(!this.state.essential.consentApproved){this.log("Consent not approved — skipping GA Events");return}if(this.isSyncingGA){this.log("Already syncing GA - skipping GA events");return}const t=this.state.essential.visitorTests.filter(e=>e.shouldSendToGa);if(t.length===0){this.log("No GA Events to sync");return}this.isSyncingGA=!0,this.log("Syncing %s GA Events",t.length),Promise.allSettled(t.map(e=>this.sendGAEvent(e))).then(()=>this.log("All gtag events sent")).finally(()=>this.isSyncingGA=!1)}sendGAEvent(t){return new Promise(e=>{this.log("Sending GA Event for test %s, hypothesis %s",t.testId,t.hypothesisId);const i=()=>{this.log("GA acknowledged event for hypothesis %s",t.hypothesisId),t.shouldSendToGa=!1,this.persistEssentialState(),e()},s={exp_variant_string:`SL-${t.testId}-${t.hypothesisId}`};this.shopliftDebug&&Object.assign(s,{debug_mode:!0});function r(n,o,c){window.dataLayer=window.dataLayer||[],window.dataLayer.push(arguments)}this.gaConfig.mode==="gtag"?r("event","experience_impression",{...s,event_callback:i}):(window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"experience_impression",...s,eventCallback:i}))})}updateLocalVisitor(t){let e;({visitorTests:e,...this.state.analytics.visitor}=t);for(const i of this.state.essential.visitorTests.filter(s=>!e.some(r=>r.testId===s.testId)))i.isSaved=!0,i.isInvalid=!0;for(const i of e){const s=this.state.essential.visitorTests.findIndex(n=>n.testId===i.testId);s!==-1?(i.isInvalid=!1,this.state.essential.visitorTests.splice(s,1,i)):this.state.essential.visitorTests.push(i)}this.state.analytics.visitor.storedAt=new Date}async getVisitor(t){try{return await this.makeJsonRequest({method:"get",url:`${this.eventHost}/api/v0/visitors/by-key/${this.shop}/${t}`})}catch{return null}}async sendEvents(t){await this.makeRequest({method:"post",url:`${this.eventHost}/api/v0/events`,data:JSON.stringify(t)})}getUTMValue(t){const i=decodeURIComponent(window.location.search.substring(1)).split("&");for(let s=0;s<i.length;s++){const r=i[s].split("=");if(r[0]===t)return r[1]||null}return null}hidePage(t){this.log("Hiding page"),this.cssHideClass&&!window.document.documentElement.classList.contains(this.cssHideClass)&&(window.document.documentElement.classList.add(this.cssHideClass),t||setTimeout(this.removeAsyncHide(this.cssHideClass),2e3))}showPage(){this.cssHideClass&&this.removeAsyncHide(this.cssHideClass)()}getDeviceType(){function t(){let i=!1;return function(s){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(s)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(s.substr(0,4)))&&(i=!0)}(navigator.userAgent||navigator.vendor),i}function e(){let i=!1;return function(s){(/android|ipad|playbook|silk/i.test(s)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(s.substr(0,4)))&&(i=!0)}(navigator.userAgent||navigator.vendor),i}return t()?"mobile":e()?"tablet":"desktop"}removeAsyncHide(t){return()=>{t&&window.document.documentElement.classList.remove(t)}}async getCartState(){try{let t=await this.makeJsonRequest({method:"get",url:`${window.location.origin}/cart.js`});return t===null||(t.note===null&&(t=await this.makeJsonRequest({method:"post",url:`${window.location.origin}/cart/update.js`,data:JSON.stringify({note:""})})),t==null)?null:{token:t.token,total_price:t.total_price,total_discount:t.total_discount,currency:t.currency,items_subtotal_price:t.items_subtotal_price,items:t.items.map(e=>({quantity:e.quantity,variant_id:e.variant_id,key:e.key,price:e.price,final_line_price:e.final_line_price,sku:e.sku,product_id:e.product_id}))}}catch(t){return this.log("Error sending cart info",t),null}}async ensureCartAttributesForExistingPriceTests(t){var e;try{if(this.log("Checking visitor assignments for active price tests"),t&&this.state.temporary.previewConfig){const i=this.state.temporary.previewConfig;this.log("Using preview config for merchant:",i.testId);let s="variant";if(i.variants&&i.variants.length>0){const r=i.variants.find(n=>n.id===i.currentVariant);r&&r.isControl&&(s="control")}this.log("Merchant preview - updating hidden inputs:",i.testId,s),this.updatePriceTestHiddenInputs(i.testId,s,!0);return}for(const i of this.state.essential.visitorTests){const s=this.testConfigs.find(n=>n.id===i.testId);if(!s){this.log("Test config not found:",i.testId);continue}const r=s.hypotheses.find(n=>n.id===i.hypothesisId);if(!r||r.type!=="price"){this.log("Skipping non-price hypothesis:",i.hypothesisId);continue}this.log("Found potential price test, validating with server:",i.testId);try{const n=await this.makeJsonRequest({method:"get",url:`${this.eventHost}/api/v0/visitors/price-test/${i.testId}/${(e=this.state.analytics.visitor)==null?void 0:e.id}`});if(!n){this.log("Failed to validate price test with server:",i.testId);continue}if(!n.isActive||!n.isPriceTest||!n.visitorAssigned){this.log("Price test validation failed - Active:",n.isActive,"PriceTest:",n.isPriceTest,"Assigned:",n.visitorAssigned);continue}this.log("Price test validated successfully, updating hidden inputs:",i.testId,n.assignment),this.updatePriceTestHiddenInputs(i.testId,n.assignment,t)}catch(n){this.log("Error validating price test with server:",i.testId,n);const o=r.isControl?"control":"variant";this.updatePriceTestHiddenInputs(i.testId,o,t)}}}catch(i){this.log("Error ensuring cart attributes for existing price tests:",i)}}updatePriceTestHiddenInputs(t,e,i){try{this.log("Updating hidden inputs with price test data:",t,e);const s=`${t}:${e}:${i?"t":"f"}`,r=l=>{const h=l.getAttribute("data-sl-pid");if(this.log(`shouldUpdateInput called with productId: "${h}", isMerchant: ${i}`),!h)return this.log("No product ID on input, returning true"),!0;if(i&&this.state.temporary.previewConfig){const g=this.state.temporary.previewConfig;this.log("Using preview config for merchant");const m=e==="control"?"a":"b",p=g.variants.find(f=>f.label===m);if(!p)return this.log("Target variant not found in preview config for label:",m),!1;this.log(`Checking product ID ${h} against domSelectors for variant ${m}:`,p.domSelectors);for(const f of p.domSelectors||[]){const v=f.cssSelector.match(/data-sl-attribute-(?:p|cap)="(\d+)"/);if(v){const w=v[1];if(this.log(`Extracted ID from selector: ${w}, comparing to: ${h}`),w===h)return this.log("Product ID match found in preview config:",h,"variant:",p.label),!0}else this.log(`Could not extract ID from selector: ${f.cssSelector}`)}return this.log("No product ID match in preview config for:",h,"variant:",m),!1}const u=this.testConfigs.find(g=>g.id===t);if(!u)return this.log("Test config not found for testId:",t),!1;for(const g of u.hypotheses||[])for(const m of g.domSelectors||[]){const p=m.cssSelector.match(/data-sl-attribute-(?:p|cap)="(\d+)"/);if(p&&p[1]===h)return this.log("Product ID match found:",h,"for test:",t),!0}return this.log("No product ID match for:",h,"in test:",t),!1},n=new MutationObserver(l=>{l.forEach(h=>{h.addedNodes.forEach(u=>{if(u.nodeType===Node.ELEMENT_NODE){const g=u,m=g.matches('input[name="properties[_slpt]"]')?[g]:g.querySelectorAll('input[name="properties[_slpt]"]');m.length>0&&this.log(`MutationObserver found ${m.length} new hidden input(s)`),m.forEach(p=>{const f=p.getAttribute("data-sl-pid");this.log(`MutationObserver checking new input with data-sl-pid="${f}"`),r(p)?p.value!==s&&(p.value=s,this.log("Updated newly added hidden input:",s)):(p.remove(),this.log("Removed newly added non-matching hidden input for product ID:",p.getAttribute("data-sl-pid")))})}})})}),o=()=>{const l=document.querySelectorAll('input[name="properties[_slpt]"]');this.log(`Found ${l.length} existing hidden inputs to check`),l.forEach(h=>{const u=h.getAttribute("data-sl-pid");this.log(`Checking existing input with data-sl-pid="${u}"`),r(h)?(h.value=s,this.log("Updated existing hidden input:",s)):(h.remove(),this.log("Removed non-matching hidden input for product ID:",h.getAttribute("data-sl-pid")))})},c=()=>{document.body?(n.observe(document.body,{childList:!0,subtree:!0}),this.log("Started MutationObserver on document.body"),o()):document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{document.body&&(n.observe(document.body,{childList:!0,subtree:!0}),this.log("Started MutationObserver after DOMContentLoaded"),o())}):setTimeout(c,10)};c(),window.__shopliftPriceTestObserver=n,window.__shopliftPriceTestValue=s,this.log("Set up DOM observer for price test hidden inputs")}catch(s){this.log("Error updating price test hidden inputs:",s)}}async makeJsonRequest(t){const e=await this.makeRequest(t);return e===null?null:JSON.parse(await e.text(),k)}async makeRequest(t){const{url:e,method:i,headers:s,data:r,signal:n}=t,o=new Headers;if(s)for(const l in s)o.append(l,s[l]);(!s||!s.Accept)&&o.append("Accept","application/json"),(!s||!s["Content-Type"])&&o.append("Content-Type","application/json"),(this.eventHost.includes("ngrok.io")||this.eventHost.includes("ngrok-free.app"))&&o.append("ngrok-skip-browser-warning","1234");const c=await this.fetch(e,{method:i,headers:o,body:r,signal:n});if(!c.ok){if(c.status===204)return null;if(c.status===422){const l=await c.json();if(typeof l<"u"&&l.isBot)throw new P}throw new Error(`Error sending shoplift request ${c.status}`)}return c}queueAddVisitorToTest(t,e){if(!this.state.essential.visitorTests.some(i=>i.testId===t)&&(this.state.essential.visitorTests.push({createdAt:new Date,testId:t,hypothesisId:e.id,isThemeTest:e.type==="theme",themeId:e.themeId,isSaved:!1,isInvalid:!1,shouldSendToGa:!0}),e.type==="price")){const i=e.isControl?"control":"variant";this.log("Price test assignment detected, updating cart attributes:",t,i),this.updatePriceTestHiddenInputs(t,i,!1)}}queueCartUpdate(t){this.queueEvent(new O(t))}queuePageView(t){this.queueEvent(new D(t))}queueEvent(t){!this.state.essential.consentApproved&&this.state.essential.hasConsentInteraction||this.state.analytics.queue.length>10||this.state.analytics.queue.push(t)}legacyGetLocalStorageVisitor(){const t=this.localStorageGet(this.legacySessionKey);if(t)try{return JSON.parse(t,k)}catch{}return null}pruneStateAndSave(){this.state.essential.visitorTests=this.state.essential.visitorTests.filter(t=>this.testConfigs.some(e=>e.id==t.testId)||this.inactiveTestConfigs.filter(e=>this.testIsPaused(e)).some(e=>e.id===t.testId)),this.saveState()}saveState(){this.persistEssentialState(),this.persistAnalyticsState()}loadState(){const t=this.loadAnalyticsState(),e={analytics:t,essential:this.loadEssentialState(t),temporary:this.loadTemporaryState()},i=this.legacyGetLocalStorageVisitor(),s=this.legacyGetCookieVisitor(),r=[i,s].filter(n=>n!==null).sort((n,o)=>+o.storedAt-+n.storedAt)[0];return e.analytics.visitor===null&&r&&({visitorTests:e.essential.visitorTests,...e.analytics.visitor}=r,e.essential.isFirstLoad=!1,e.essential.initialState={createdAt:r.createdAt,referrer:r.referrer,utmCampaign:r.utmCampaign,utmContent:r.utmContent,utmMedium:r.utmMedium,utmSource:r.utmSource,device:r.device},this.deleteCookie("SHOPLIFT"),this.deleteLocalStorage(this.legacySessionKey)),!e.essential.consentApproved&&e.essential.hasConsentInteraction&&this.deleteLocalStorage(this.analyticsSessionKey),e}loadEssentialState(t){var o;const e=this.loadLocalStorage(this.essentialSessionKey),i=this.loadCookie(this.essentialSessionKey),s=this.getInitialState();(o=t.visitor)!=null&&o.device&&(s.device=t.visitor.device);const r={timestamp:new Date,consentApproved:!1,hasConsentInteraction:!1,debugMode:!1,initialState:s,visitorTests:[],isFirstLoad:!0},n=[e,i].filter(c=>c!==null).sort((c,l)=>+l.timestamp-+c.timestamp)[0]??r;return n.initialState||(t.visitor!==null?n.initialState=t.visitor:(n.initialState=s,n.initialState.createdAt=n.timestamp)),n}loadAnalyticsState(){const t=this.loadLocalStorage(this.analyticsSessionKey),e=this.loadCookie(this.analyticsSessionKey),i={timestamp:new Date,visitor:null,queue:[]},s=[t,e].filter(r=>r!==null).sort((r,n)=>+n.timestamp-+r.timestamp)[0]??i;return s.queue.length===0&&t&&t.queue.length>1&&(s.queue=t.queue),s}loadTemporaryState(){const t=this.sessionStorageGet(this.temporarySessionKey),e=t?JSON.parse(t,k):null,i=this.loadCookie(this.temporarySessionKey);return e??i??{isMerchant:!1,timestamp:new Date}}persistEssentialState(){this.log("Persisting essential state"),this.state.essential.isFirstLoad=!1,this.state.essential.timestamp=new Date,this.persistLocalStorageState(this.essentialSessionKey,this.state.essential),this.persistCookieState(this.essentialSessionKey,this.state.essential)}persistAnalyticsState(){this.log("Persisting analytics state"),this.state.essential.consentApproved&&(this.state.analytics.timestamp=new Date,this.persistLocalStorageState(this.analyticsSessionKey,this.state.analytics),this.persistCookieState(this.analyticsSessionKey,{...this.state.analytics,queue:[]}))}persistTemporaryState(){this.log("Setting temporary session state"),this.state.temporary.timestamp=new Date,this.sessionStorageSet(this.temporarySessionKey,JSON.stringify(this.state.temporary)),this.persistCookieState(this.temporarySessionKey,this.state.temporary,!0)}loadLocalStorage(t){const e=this.localStorageGet(t);if(e===null)return null;try{return JSON.parse(e,k)}catch{return null}}loadCookie(t){const e=this.getCookie(t);if(e===null)return null;try{return JSON.parse(e,k)}catch{return null}}persistLocalStorageState(t,e){this.localStorageSet(t,JSON.stringify(e))}persistCookieState(t,e,i=!1){const s=JSON.stringify(e),r=i?"":`expires=${new Date(new Date().getTime()+864e5*365).toUTCString()};`;document.cookie=`${t}=${s};domain=.${window.location.hostname};path=/;SameSite=Strict;${r}`}deleteCookie(t){const e=new Date(0).toUTCString();document.cookie=`${t}=;domain=.${window.location.hostname};path=/;expires=${e};`}deleteLocalStorage(t){window.localStorage.removeItem(t)}getChannel(t){var i;return((i=[{"name":"cross-network","test":(v) => new RegExp(".*cross-network.*", "i").test(v.utmCampaign)},{"name":"direct","test":(v) => v.utmSource === "" && v.utmMedium === ""},{"name":"paid-shopping","test":(v) => (new RegExp("^(?:Google|IGShopping|aax-us-east\.amazon-adsystem\.com|aax\.amazon-adsystem\.com|alibaba|alibaba\.com|amazon|amazon\.co\.uk|amazon\.com|apps\.shopify\.com|checkout\.shopify\.com|checkout\.stripe\.com|cr\.shopping\.naver\.com|cr2\.shopping\.naver\.com|ebay|ebay\.co\.uk|ebay\.com|ebay\.com\.au|ebay\.de|etsy|etsy\.com|m\.alibaba\.com|m\.shopping\.naver\.com|mercadolibre|mercadolibre\.com|mercadolibre\.com\.ar|mercadolibre\.com\.mx|message\.alibaba\.com|msearch\.shopping\.naver\.com|nl\.shopping\.net|no\.shopping\.net|offer\.alibaba\.com|one\.walmart\.com|order\.shopping\.yahoo\.co\.jp|partners\.shopify\.com|s3\.amazonaws\.com|se\.shopping\.net|shop\.app|shopify|shopify\.com|shopping\.naver\.com|shopping\.yahoo\.co\.jp|shopping\.yahoo\.com|shopzilla|shopzilla\.com|simplycodes\.com|store\.shopping\.yahoo\.co\.jp|stripe|stripe\.com|uk\.shopping\.net|walmart|walmart\.com)$", "i").test(v.utmSource) || new RegExp("^(.*(([^a-df-z]|^)shop|shopping).*)$", "i").test(v.utmCampaign)) && new RegExp("^(.*cp.*|ppc|retargeting|paid.*)$", "i").test(v.utmMedium)},{"name":"paid-search","test":(v) => new RegExp("^(?:360\.cn|alice|aol|ar\.search\.yahoo\.com|ask|at\.search\.yahoo\.com|au\.search\.yahoo\.com|auone|avg|babylon|baidu|biglobe|biglobe\.co\.jp|biglobe\.ne\.jp|bing|br\.search\.yahoo\.com|ca\.search\.yahoo\.com|centrum\.cz|ch\.search\.yahoo\.com|cl\.search\.yahoo\.com|cn\.bing\.com|cnn|co\.search\.yahoo\.com|comcast|conduit|daum|daum\.net|de\.search\.yahoo\.com|dk\.search\.yahoo\.com|dogpile|dogpile\.com|duckduckgo|ecosia\.org|email\.seznam\.cz|eniro|es\.search\.yahoo\.com|espanol\.search\.yahoo\.com|exalead\.com|excite\.com|fi\.search\.yahoo\.com|firmy\.cz|fr\.search\.yahoo\.com|globo|go\.mail\.ru|google|google-play|hk\.search\.yahoo\.com|id\.search\.yahoo\.com|in\.search\.yahoo\.com|incredimail|it\.search\.yahoo\.com|kvasir|lens\.google\.com|lite\.qwant\.com|lycos|m\.baidu\.com|m\.naver\.com|m\.search\.naver\.com|m\.sogou\.com|mail\.rambler\.ru|mail\.yandex\.ru|malaysia\.search\.yahoo\.com|msn|msn\.com|mx\.search\.yahoo\.com|najdi|naver|naver\.com|news\.google\.com|nl\.search\.yahoo\.com|no\.search\.yahoo\.com|ntp\.msn\.com|nz\.search\.yahoo\.com|onet|onet\.pl|pe\.search\.yahoo\.com|ph\.search\.yahoo\.com|pl\.search\.yahoo\.com|play\.google\.com|qwant|qwant\.com|rakuten|rakuten\.co\.jp|rambler|rambler\.ru|se\.search\.yahoo\.com|search-results|search\.aol\.co\.uk|search\.aol\.com|search\.google\.com|search\.smt\.docomo\.ne\.jp|search\.ukr\.net|secureurl\.ukr\.net|seznam|seznam\.cz|sg\.search\.yahoo\.com|so\.com|sogou|sogou\.com|sp-web\.search\.auone\.jp|startsiden|startsiden\.no|suche\.aol\.de|terra|th\.search\.yahoo\.com|tr\.search\.yahoo\.com|tut\.by|tw\.search\.yahoo\.com|uk\.search\.yahoo\.com|ukr|us\.search\.yahoo\.com|virgilio|vn\.search\.yahoo\.com|wap\.sogou\.com|webmaster\.yandex\.ru|websearch\.rakuten\.co\.jp|yahoo|yahoo\.co\.jp|yahoo\.com|yandex|yandex\.by|yandex\.com|yandex\.com\.tr|yandex\.fr|yandex\.kz|yandex\.ru|yandex\.ua|yandex\.uz|zen\.yandex\.ru)$", "i").test(v.utmSource) && new RegExp("^(.*cp.*|ppc|retargeting|paid.*)$", "i").test(v.utmMedium)},{"name":"paid-social","test":(v) => new RegExp("^(?:43things|43things\.com|51\.com|5ch\.net|Hatena|ImageShack|academia\.edu|activerain|activerain\.com|activeworlds|activeworlds\.com|addthis|addthis\.com|airg\.ca|allnurses\.com|allrecipes\.com|alumniclass|alumniclass\.com|ameba\.jp|ameblo\.jp|americantowns|americantowns\.com|amp\.reddit\.com|ancestry\.com|anobii|anobii\.com|answerbag|answerbag\.com|answers\.yahoo\.com|aolanswers|aolanswers\.com|apps\.facebook\.com|ar\.pinterest\.com|artstation\.com|askubuntu|askubuntu\.com|asmallworld\.com|athlinks|athlinks\.com|away\.vk\.com|awe\.sm|b\.hatena\.ne\.jp|baby-gaga|baby-gaga\.com|babyblog\.ru|badoo|badoo\.com|bebo|bebo\.com|beforeitsnews|beforeitsnews\.com|bharatstudent|bharatstudent\.com|biip\.no|biswap\.org|bit\.ly|blackcareernetwork\.com|blackplanet|blackplanet\.com|blip\.fm|blog\.com|blog\.feedspot\.com|blog\.goo\.ne\.jp|blog\.naver\.com|blog\.yahoo\.co\.jp|blogg\.no|bloggang\.com|blogger|blogger\.com|blogher|blogher\.com|bloglines|bloglines\.com|blogs\.com|blogsome|blogsome\.com|blogspot|blogspot\.com|blogster|blogster\.com|blurtit|blurtit\.com|bookmarks\.yahoo\.co\.jp|bookmarks\.yahoo\.com|br\.pinterest\.com|brightkite|brightkite\.com|brizzly|brizzly\.com|business\.facebook\.com|buzzfeed|buzzfeed\.com|buzznet|buzznet\.com|cafe\.naver\.com|cafemom|cafemom\.com|camospace|camospace\.com|canalblog\.com|care\.com|care2|care2\.com|caringbridge\.org|catster|catster\.com|cbnt\.io|cellufun|cellufun\.com|centerblog\.net|chat\.zalo\.me|chegg\.com|chicagonow|chicagonow\.com|chiebukuro\.yahoo\.co\.jp|classmates|classmates\.com|classquest|classquest\.com|co\.pinterest\.com|cocolog-nifty|cocolog-nifty\.com|copainsdavant\.linternaute\.com|couchsurfing\.org|cozycot|cozycot\.com|cross\.tv|crunchyroll|crunchyroll\.com|cyworld|cyworld\.com|cz\.pinterest\.com|d\.hatena\.ne\.jp|dailystrength\.org|deluxe\.com|deviantart|deviantart\.com|dianping|dianping\.com|digg|digg\.com|diigo|diigo\.com|discover\.hubpages\.com|disqus|disqus\.com|dogster|dogster\.com|dol2day|dol2day\.com|doostang|doostang\.com|dopplr|dopplr\.com|douban|douban\.com|draft\.blogger\.com|draugiem\.lv|drugs-forum|drugs-forum\.com|dzone|dzone\.com|edublogs\.org|elftown|elftown\.com|epicurious\.com|everforo\.com|exblog\.jp|extole|extole\.com|facebook|facebook\.com|faceparty|faceparty\.com|fandom\.com|fanpop|fanpop\.com|fark|fark\.com|fb|fb\.me|fc2|fc2\.com|feedspot|feministing|feministing\.com|filmaffinity|filmaffinity\.com|flickr|flickr\.com|flipboard|flipboard\.com|folkdirect|folkdirect\.com|foodservice|foodservice\.com|forums\.androidcentral\.com|forums\.crackberry\.com|forums\.imore\.com|forums\.nexopia\.com|forums\.webosnation\.com|forums\.wpcentral\.com|fotki|fotki\.com|fotolog|fotolog\.com|foursquare|foursquare\.com|free\.facebook\.com|friendfeed|friendfeed\.com|fruehstueckstreff\.org|fubar|fubar\.com|gaiaonline|gaiaonline\.com|gamerdna|gamerdna\.com|gather\.com|geni\.com|getpocket\.com|glassboard|glassboard\.com|glassdoor|glassdoor\.com|godtube|godtube\.com|goldenline\.pl|goldstar|goldstar\.com|goo\.gl|gooblog|goodreads|goodreads\.com|google\+|googlegroups\.com|googleplus|govloop|govloop\.com|gowalla|gowalla\.com|gree\.jp|groups\.google\.com|gulli\.com|gutefrage\.net|habbo|habbo\.com|hi5|hi5\.com|hootsuite|hootsuite\.com|houzz|houzz\.com|hoverspot|hoverspot\.com|hr\.com|hu\.pinterest\.com|hubculture|hubculture\.com|hubpages\.com|hyves\.net|hyves\.nl|ibibo|ibibo\.com|id\.pinterest\.com|identi\.ca|ig|imageshack\.com|imageshack\.us|imvu|imvu\.com|in\.pinterest\.com|insanejournal|insanejournal\.com|instagram|instagram\.com|instapaper|instapaper\.com|internations\.org|interpals\.net|intherooms|intherooms\.com|irc-galleria\.net|is\.gd|italki|italki\.com|jammerdirect|jammerdirect\.com|jappy\.com|jappy\.de|kaboodle\.com|kakao|kakao\.com|kakaocorp\.com|kaneva|kaneva\.com|kin\.naver\.com|l\.facebook\.com|l\.instagram\.com|l\.messenger\.com|last\.fm|librarything|librarything\.com|lifestream\.aol\.com|line|line\.me|linkedin|linkedin\.com|listal|listal\.com|listography|listography\.com|livedoor\.com|livedoorblog|livejournal|livejournal\.com|lm\.facebook\.com|lnkd\.in|m\.blog\.naver\.com|m\.cafe\.naver\.com|m\.facebook\.com|m\.kin\.naver\.com|m\.vk\.com|m\.yelp\.com|mbga\.jp|medium\.com|meetin\.org|meetup|meetup\.com|meinvz\.net|meneame\.net|menuism\.com|messages\.google\.com|messages\.yahoo\.co\.jp|messenger|messenger\.com|mix\.com|mixi\.jp|mobile\.facebook\.com|mocospace|mocospace\.com|mouthshut|mouthshut\.com|movabletype|movabletype\.com|mubi|mubi\.com|my\.opera\.com|myanimelist\.net|myheritage|myheritage\.com|mylife|mylife\.com|mymodernmet|mymodernmet\.com|myspace|myspace\.com|netvibes|netvibes\.com|news\.ycombinator\.com|newsshowcase|nexopia|ngopost\.org|niconico|nicovideo\.jp|nightlifelink|nightlifelink\.com|ning|ning\.com|nl\.pinterest\.com|odnoklassniki\.ru|odnoklassniki\.ua|okwave\.jp|old\.reddit\.com|oneworldgroup\.org|onstartups|onstartups\.com|opendiary|opendiary\.com|oshiete\.goo\.ne\.jp|out\.reddit\.com|over-blog\.com|overblog\.com|paper\.li|partyflock\.nl|photobucket|photobucket\.com|pinboard|pinboard\.in|pingsta|pingsta\.com|pinterest|pinterest\.at|pinterest\.ca|pinterest\.ch|pinterest\.cl|pinterest\.co\.kr|pinterest\.co\.uk|pinterest\.com|pinterest\.com\.au|pinterest\.com\.mx|pinterest\.de|pinterest\.es|pinterest\.fr|pinterest\.it|pinterest\.jp|pinterest\.nz|pinterest\.ph|pinterest\.pt|pinterest\.ru|pinterest\.se|pixiv\.net|pl\.pinterest\.com|playahead\.se|plurk|plurk\.com|plus\.google\.com|plus\.url\.google\.com|pocket\.co|posterous|posterous\.com|pro\.homeadvisor\.com|pulse\.yahoo\.com|qapacity|qapacity\.com|quechup|quechup\.com|quora|quora\.com|qzone\.qq\.com|ravelry|ravelry\.com|reddit|reddit\.com|redux|redux\.com|renren|renren\.com|researchgate\.net|reunion|reunion\.com|reverbnation|reverbnation\.com|rtl\.de|ryze|ryze\.com|salespider|salespider\.com|scoop\.it|screenrant|screenrant\.com|scribd|scribd\.com|scvngr|scvngr\.com|secondlife|secondlife\.com|serverfault|serverfault\.com|shareit|sharethis|sharethis\.com|shvoong\.com|sites\.google\.com|skype|skyrock|skyrock\.com|slashdot\.org|slideshare\.net|smartnews\.com|snapchat|snapchat\.com|social|sociallife\.com\.br|socialvibe|socialvibe\.com|spaces\.live\.com|spoke|spoke\.com|spruz|spruz\.com|ssense\.com|stackapps|stackapps\.com|stackexchange|stackexchange\.com|stackoverflow|stackoverflow\.com|stardoll\.com|stickam|stickam\.com|studivz\.net|suomi24\.fi|superuser|superuser\.com|sweeva|sweeva\.com|t\.co|t\.me|tagged|tagged\.com|taggedmail|taggedmail\.com|talkbiznow|talkbiznow\.com|taringa\.net|techmeme|techmeme\.com|tencent|tencent\.com|tiktok|tiktok\.com|tinyurl|tinyurl\.com|toolbox|toolbox\.com|touch\.facebook\.com|tr\.pinterest\.com|travellerspoint|travellerspoint\.com|tripadvisor|tripadvisor\.com|trombi|trombi\.com|trustpilot|tudou|tudou\.com|tuenti|tuenti\.com|tumblr|tumblr\.com|tweetdeck|tweetdeck\.com|twitter|twitter\.com|twoo\.com|typepad|typepad\.com|unblog\.fr|urbanspoon\.com|ushareit\.com|ushi\.cn|vampirefreaks|vampirefreaks\.com|vampirerave|vampirerave\.com|vg\.no|video\.ibm\.com|vk\.com|vkontakte\.ru|wakoopa|wakoopa\.com|wattpad|wattpad\.com|web\.facebook\.com|web\.skype\.com|webshots|webshots\.com|wechat|wechat\.com|weebly|weebly\.com|weibo|weibo\.com|wer-weiss-was\.de|weread|weread\.com|whatsapp|whatsapp\.com|wiki\.answers\.com|wikihow\.com|wikitravel\.org|woot\.com|wordpress|wordpress\.com|wordpress\.org|xanga|xanga\.com|xing|xing\.com|yahoo-mbga\.jp|yammer|yammer\.com|yelp|yelp\.co\.uk|yelp\.com|youroom\.in|za\.pinterest\.com|zalo|zoo\.gr|zooppa|zooppa\.com)$", "i").test(v.utmSource) && new RegExp("^(.*cp.*|ppc|retargeting|paid.*)$", "i").test(v.utmMedium)},{"name":"paid-video","test":(v) => new RegExp("^(?:blog\.twitch\.tv|crackle|crackle\.com|curiositystream|curiositystream\.com|d\.tube|dailymotion|dailymotion\.com|dashboard\.twitch\.tv|disneyplus|disneyplus\.com|fast\.wistia\.net|help\.hulu\.com|help\.netflix\.com|hulu|hulu\.com|id\.twitch\.tv|iq\.com|iqiyi|iqiyi\.com|jobs\.netflix\.com|justin\.tv|m\.twitch\.tv|m\.youtube\.com|music\.youtube\.com|netflix|netflix\.com|player\.twitch\.tv|player\.vimeo\.com|ted|ted\.com|twitch|twitch\.tv|utreon|utreon\.com|veoh|veoh\.com|viadeo\.journaldunet\.com|vimeo|vimeo\.com|wistia|wistia\.com|youku|youku\.com|youtube|youtube\.com)$", "i").test(v.utmSource) && new RegExp("^(.*cp.*|ppc|retargeting|paid.*)$", "i").test(v.utmMedium)},{"name":"display","test":(v) => new RegExp("^(?:display|banner|expandable|interstitial|cpm)$", "i").test(v.utmMedium)},{"name":"paid-other","test":(v) => new RegExp("^(.*cp.*|ppc|retargeting|paid.*)$", "i").test(v.utmMedium)},{"name":"organic-shopping","test":(v) => new RegExp("^(?:360\.cn|alice|aol|ar\.search\.yahoo\.com|ask|at\.search\.yahoo\.com|au\.search\.yahoo\.com|auone|avg|babylon|baidu|biglobe|biglobe\.co\.jp|biglobe\.ne\.jp|bing|br\.search\.yahoo\.com|ca\.search\.yahoo\.com|centrum\.cz|ch\.search\.yahoo\.com|cl\.search\.yahoo\.com|cn\.bing\.com|cnn|co\.search\.yahoo\.com|comcast|conduit|daum|daum\.net|de\.search\.yahoo\.com|dk\.search\.yahoo\.com|dogpile|dogpile\.com|duckduckgo|ecosia\.org|email\.seznam\.cz|eniro|es\.search\.yahoo\.com|espanol\.search\.yahoo\.com|exalead\.com|excite\.com|fi\.search\.yahoo\.com|firmy\.cz|fr\.search\.yahoo\.com|globo|go\.mail\.ru|google|google-play|hk\.search\.yahoo\.com|id\.search\.yahoo\.com|in\.search\.yahoo\.com|incredimail|it\.search\.yahoo\.com|kvasir|lens\.google\.com|lite\.qwant\.com|lycos|m\.baidu\.com|m\.naver\.com|m\.search\.naver\.com|m\.sogou\.com|mail\.rambler\.ru|mail\.yandex\.ru|malaysia\.search\.yahoo\.com|msn|msn\.com|mx\.search\.yahoo\.com|najdi|naver|naver\.com|news\.google\.com|nl\.search\.yahoo\.com|no\.search\.yahoo\.com|ntp\.msn\.com|nz\.search\.yahoo\.com|onet|onet\.pl|pe\.search\.yahoo\.com|ph\.search\.yahoo\.com|pl\.search\.yahoo\.com|play\.google\.com|qwant|qwant\.com|rakuten|rakuten\.co\.jp|rambler|rambler\.ru|se\.search\.yahoo\.com|search-results|search\.aol\.co\.uk|search\.aol\.com|search\.google\.com|search\.smt\.docomo\.ne\.jp|search\.ukr\.net|secureurl\.ukr\.net|seznam|seznam\.cz|sg\.search\.yahoo\.com|so\.com|sogou|sogou\.com|sp-web\.search\.auone\.jp|startsiden|startsiden\.no|suche\.aol\.de|terra|th\.search\.yahoo\.com|tr\.search\.yahoo\.com|tut\.by|tw\.search\.yahoo\.com|uk\.search\.yahoo\.com|ukr|us\.search\.yahoo\.com|virgilio|vn\.search\.yahoo\.com|wap\.sogou\.com|webmaster\.yandex\.ru|websearch\.rakuten\.co\.jp|yahoo|yahoo\.co\.jp|yahoo\.com|yandex|yandex\.by|yandex\.com|yandex\.com\.tr|yandex\.fr|yandex\.kz|yandex\.ru|yandex\.ua|yandex\.uz|zen\.yandex\.ru)$", "i").test(v.utmSource) || new RegExp("^(.*(([^a-df-z]|^)shop|shopping).*)$", "i").test(v.utmCampaign)},{"name":"organic-social","test":(v) => new RegExp("^(?:43things|43things\.com|51\.com|5ch\.net|Hatena|ImageShack|academia\.edu|activerain|activerain\.com|activeworlds|activeworlds\.com|addthis|addthis\.com|airg\.ca|allnurses\.com|allrecipes\.com|alumniclass|alumniclass\.com|ameba\.jp|ameblo\.jp|americantowns|americantowns\.com|amp\.reddit\.com|ancestry\.com|anobii|anobii\.com|answerbag|answerbag\.com|answers\.yahoo\.com|aolanswers|aolanswers\.com|apps\.facebook\.com|ar\.pinterest\.com|artstation\.com|askubuntu|askubuntu\.com|asmallworld\.com|athlinks|athlinks\.com|away\.vk\.com|awe\.sm|b\.hatena\.ne\.jp|baby-gaga|baby-gaga\.com|babyblog\.ru|badoo|badoo\.com|bebo|bebo\.com|beforeitsnews|beforeitsnews\.com|bharatstudent|bharatstudent\.com|biip\.no|biswap\.org|bit\.ly|blackcareernetwork\.com|blackplanet|blackplanet\.com|blip\.fm|blog\.com|blog\.feedspot\.com|blog\.goo\.ne\.jp|blog\.naver\.com|blog\.yahoo\.co\.jp|blogg\.no|bloggang\.com|blogger|blogger\.com|blogher|blogher\.com|bloglines|bloglines\.com|blogs\.com|blogsome|blogsome\.com|blogspot|blogspot\.com|blogster|blogster\.com|blurtit|blurtit\.com|bookmarks\.yahoo\.co\.jp|bookmarks\.yahoo\.com|br\.pinterest\.com|brightkite|brightkite\.com|brizzly|brizzly\.com|business\.facebook\.com|buzzfeed|buzzfeed\.com|buzznet|buzznet\.com|cafe\.naver\.com|cafemom|cafemom\.com|camospace|camospace\.com|canalblog\.com|care\.com|care2|care2\.com|caringbridge\.org|catster|catster\.com|cbnt\.io|cellufun|cellufun\.com|centerblog\.net|chat\.zalo\.me|chegg\.com|chicagonow|chicagonow\.com|chiebukuro\.yahoo\.co\.jp|classmates|classmates\.com|classquest|classquest\.com|co\.pinterest\.com|cocolog-nifty|cocolog-nifty\.com|copainsdavant\.linternaute\.com|couchsurfing\.org|cozycot|cozycot\.com|cross\.tv|crunchyroll|crunchyroll\.com|cyworld|cyworld\.com|cz\.pinterest\.com|d\.hatena\.ne\.jp|dailystrength\.org|deluxe\.com|deviantart|deviantart\.com|dianping|dianping\.com|digg|digg\.com|diigo|diigo\.com|discover\.hubpages\.com|disqus|disqus\.com|dogster|dogster\.com|dol2day|dol2day\.com|doostang|doostang\.com|dopplr|dopplr\.com|douban|douban\.com|draft\.blogger\.com|draugiem\.lv|drugs-forum|drugs-forum\.com|dzone|dzone\.com|edublogs\.org|elftown|elftown\.com|epicurious\.com|everforo\.com|exblog\.jp|extole|extole\.com|facebook|facebook\.com|faceparty|faceparty\.com|fandom\.com|fanpop|fanpop\.com|fark|fark\.com|fb|fb\.me|fc2|fc2\.com|feedspot|feministing|feministing\.com|filmaffinity|filmaffinity\.com|flickr|flickr\.com|flipboard|flipboard\.com|folkdirect|folkdirect\.com|foodservice|foodservice\.com|forums\.androidcentral\.com|forums\.crackberry\.com|forums\.imore\.com|forums\.nexopia\.com|forums\.webosnation\.com|forums\.wpcentral\.com|fotki|fotki\.com|fotolog|fotolog\.com|foursquare|foursquare\.com|free\.facebook\.com|friendfeed|friendfeed\.com|fruehstueckstreff\.org|fubar|fubar\.com|gaiaonline|gaiaonline\.com|gamerdna|gamerdna\.com|gather\.com|geni\.com|getpocket\.com|glassboard|glassboard\.com|glassdoor|glassdoor\.com|godtube|godtube\.com|goldenline\.pl|goldstar|goldstar\.com|goo\.gl|gooblog|goodreads|goodreads\.com|google\+|googlegroups\.com|googleplus|govloop|govloop\.com|gowalla|gowalla\.com|gree\.jp|groups\.google\.com|gulli\.com|gutefrage\.net|habbo|habbo\.com|hi5|hi5\.com|hootsuite|hootsuite\.com|houzz|houzz\.com|hoverspot|hoverspot\.com|hr\.com|hu\.pinterest\.com|hubculture|hubculture\.com|hubpages\.com|hyves\.net|hyves\.nl|ibibo|ibibo\.com|id\.pinterest\.com|identi\.ca|ig|imageshack\.com|imageshack\.us|imvu|imvu\.com|in\.pinterest\.com|insanejournal|insanejournal\.com|instagram|instagram\.com|instapaper|instapaper\.com|internations\.org|interpals\.net|intherooms|intherooms\.com|irc-galleria\.net|is\.gd|italki|italki\.com|jammerdirect|jammerdirect\.com|jappy\.com|jappy\.de|kaboodle\.com|kakao|kakao\.com|kakaocorp\.com|kaneva|kaneva\.com|kin\.naver\.com|l\.facebook\.com|l\.instagram\.com|l\.messenger\.com|last\.fm|librarything|librarything\.com|lifestream\.aol\.com|line|line\.me|linkedin|linkedin\.com|listal|listal\.com|listography|listography\.com|livedoor\.com|livedoorblog|livejournal|livejournal\.com|lm\.facebook\.com|lnkd\.in|m\.blog\.naver\.com|m\.cafe\.naver\.com|m\.facebook\.com|m\.kin\.naver\.com|m\.vk\.com|m\.yelp\.com|mbga\.jp|medium\.com|meetin\.org|meetup|meetup\.com|meinvz\.net|meneame\.net|menuism\.com|messages\.google\.com|messages\.yahoo\.co\.jp|messenger|messenger\.com|mix\.com|mixi\.jp|mobile\.facebook\.com|mocospace|mocospace\.com|mouthshut|mouthshut\.com|movabletype|movabletype\.com|mubi|mubi\.com|my\.opera\.com|myanimelist\.net|myheritage|myheritage\.com|mylife|mylife\.com|mymodernmet|mymodernmet\.com|myspace|myspace\.com|netvibes|netvibes\.com|news\.ycombinator\.com|newsshowcase|nexopia|ngopost\.org|niconico|nicovideo\.jp|nightlifelink|nightlifelink\.com|ning|ning\.com|nl\.pinterest\.com|odnoklassniki\.ru|odnoklassniki\.ua|okwave\.jp|old\.reddit\.com|oneworldgroup\.org|onstartups|onstartups\.com|opendiary|opendiary\.com|oshiete\.goo\.ne\.jp|out\.reddit\.com|over-blog\.com|overblog\.com|paper\.li|partyflock\.nl|photobucket|photobucket\.com|pinboard|pinboard\.in|pingsta|pingsta\.com|pinterest|pinterest\.at|pinterest\.ca|pinterest\.ch|pinterest\.cl|pinterest\.co\.kr|pinterest\.co\.uk|pinterest\.com|pinterest\.com\.au|pinterest\.com\.mx|pinterest\.de|pinterest\.es|pinterest\.fr|pinterest\.it|pinterest\.jp|pinterest\.nz|pinterest\.ph|pinterest\.pt|pinterest\.ru|pinterest\.se|pixiv\.net|pl\.pinterest\.com|playahead\.se|plurk|plurk\.com|plus\.google\.com|plus\.url\.google\.com|pocket\.co|posterous|posterous\.com|pro\.homeadvisor\.com|pulse\.yahoo\.com|qapacity|qapacity\.com|quechup|quechup\.com|quora|quora\.com|qzone\.qq\.com|ravelry|ravelry\.com|reddit|reddit\.com|redux|redux\.com|renren|renren\.com|researchgate\.net|reunion|reunion\.com|reverbnation|reverbnation\.com|rtl\.de|ryze|ryze\.com|salespider|salespider\.com|scoop\.it|screenrant|screenrant\.com|scribd|scribd\.com|scvngr|scvngr\.com|secondlife|secondlife\.com|serverfault|serverfault\.com|shareit|sharethis|sharethis\.com|shvoong\.com|sites\.google\.com|skype|skyrock|skyrock\.com|slashdot\.org|slideshare\.net|smartnews\.com|snapchat|snapchat\.com|social|sociallife\.com\.br|socialvibe|socialvibe\.com|spaces\.live\.com|spoke|spoke\.com|spruz|spruz\.com|ssense\.com|stackapps|stackapps\.com|stackexchange|stackexchange\.com|stackoverflow|stackoverflow\.com|stardoll\.com|stickam|stickam\.com|studivz\.net|suomi24\.fi|superuser|superuser\.com|sweeva|sweeva\.com|t\.co|t\.me|tagged|tagged\.com|taggedmail|taggedmail\.com|talkbiznow|talkbiznow\.com|taringa\.net|techmeme|techmeme\.com|tencent|tencent\.com|tiktok|tiktok\.com|tinyurl|tinyurl\.com|toolbox|toolbox\.com|touch\.facebook\.com|tr\.pinterest\.com|travellerspoint|travellerspoint\.com|tripadvisor|tripadvisor\.com|trombi|trombi\.com|trustpilot|tudou|tudou\.com|tuenti|tuenti\.com|tumblr|tumblr\.com|tweetdeck|tweetdeck\.com|twitter|twitter\.com|twoo\.com|typepad|typepad\.com|unblog\.fr|urbanspoon\.com|ushareit\.com|ushi\.cn|vampirefreaks|vampirefreaks\.com|vampirerave|vampirerave\.com|vg\.no|video\.ibm\.com|vk\.com|vkontakte\.ru|wakoopa|wakoopa\.com|wattpad|wattpad\.com|web\.facebook\.com|web\.skype\.com|webshots|webshots\.com|wechat|wechat\.com|weebly|weebly\.com|weibo|weibo\.com|wer-weiss-was\.de|weread|weread\.com|whatsapp|whatsapp\.com|wiki\.answers\.com|wikihow\.com|wikitravel\.org|woot\.com|wordpress|wordpress\.com|wordpress\.org|xanga|xanga\.com|xing|xing\.com|yahoo-mbga\.jp|yammer|yammer\.com|yelp|yelp\.co\.uk|yelp\.com|youroom\.in|za\.pinterest\.com|zalo|zoo\.gr|zooppa|zooppa\.com)$", "i").test(v.utmSource) || new RegExp("^(?:social|social-network|social-media|sm|social network|social media)$", "i").test(v.utmMedium)},{"name":"organic-video","test":(v) => new RegExp("^(?:blog\.twitch\.tv|crackle|crackle\.com|curiositystream|curiositystream\.com|d\.tube|dailymotion|dailymotion\.com|dashboard\.twitch\.tv|disneyplus|disneyplus\.com|fast\.wistia\.net|help\.hulu\.com|help\.netflix\.com|hulu|hulu\.com|id\.twitch\.tv|iq\.com|iqiyi|iqiyi\.com|jobs\.netflix\.com|justin\.tv|m\.twitch\.tv|m\.youtube\.com|music\.youtube\.com|netflix|netflix\.com|player\.twitch\.tv|player\.vimeo\.com|ted|ted\.com|twitch|twitch\.tv|utreon|utreon\.com|veoh|veoh\.com|viadeo\.journaldunet\.com|vimeo|vimeo\.com|wistia|wistia\.com|youku|youku\.com|youtube|youtube\.com)$", "i").test(v.utmSource) || new RegExp("^(.*video.*)$", "i").test(v.utmMedium)},{"name":"organic-search","test":(v) => new RegExp("^(?:360\.cn|alice|aol|ar\.search\.yahoo\.com|ask|at\.search\.yahoo\.com|au\.search\.yahoo\.com|auone|avg|babylon|baidu|biglobe|biglobe\.co\.jp|biglobe\.ne\.jp|bing|br\.search\.yahoo\.com|ca\.search\.yahoo\.com|centrum\.cz|ch\.search\.yahoo\.com|cl\.search\.yahoo\.com|cn\.bing\.com|cnn|co\.search\.yahoo\.com|comcast|conduit|daum|daum\.net|de\.search\.yahoo\.com|dk\.search\.yahoo\.com|dogpile|dogpile\.com|duckduckgo|ecosia\.org|email\.seznam\.cz|eniro|es\.search\.yahoo\.com|espanol\.search\.yahoo\.com|exalead\.com|excite\.com|fi\.search\.yahoo\.com|firmy\.cz|fr\.search\.yahoo\.com|globo|go\.mail\.ru|google|google-play|hk\.search\.yahoo\.com|id\.search\.yahoo\.com|in\.search\.yahoo\.com|incredimail|it\.search\.yahoo\.com|kvasir|lens\.google\.com|lite\.qwant\.com|lycos|m\.baidu\.com|m\.naver\.com|m\.search\.naver\.com|m\.sogou\.com|mail\.rambler\.ru|mail\.yandex\.ru|malaysia\.search\.yahoo\.com|msn|msn\.com|mx\.search\.yahoo\.com|najdi|naver|naver\.com|news\.google\.com|nl\.search\.yahoo\.com|no\.search\.yahoo\.com|ntp\.msn\.com|nz\.search\.yahoo\.com|onet|onet\.pl|pe\.search\.yahoo\.com|ph\.search\.yahoo\.com|pl\.search\.yahoo\.com|play\.google\.com|qwant|qwant\.com|rakuten|rakuten\.co\.jp|rambler|rambler\.ru|se\.search\.yahoo\.com|search-results|search\.aol\.co\.uk|search\.aol\.com|search\.google\.com|search\.smt\.docomo\.ne\.jp|search\.ukr\.net|secureurl\.ukr\.net|seznam|seznam\.cz|sg\.search\.yahoo\.com|so\.com|sogou|sogou\.com|sp-web\.search\.auone\.jp|startsiden|startsiden\.no|suche\.aol\.de|terra|th\.search\.yahoo\.com|tr\.search\.yahoo\.com|tut\.by|tw\.search\.yahoo\.com|uk\.search\.yahoo\.com|ukr|us\.search\.yahoo\.com|virgilio|vn\.search\.yahoo\.com|wap\.sogou\.com|webmaster\.yandex\.ru|websearch\.rakuten\.co\.jp|yahoo|yahoo\.co\.jp|yahoo\.com|yandex|yandex\.by|yandex\.com|yandex\.com\.tr|yandex\.fr|yandex\.kz|yandex\.ru|yandex\.ua|yandex\.uz|zen\.yandex\.ru)$", "i").test(v.utmSource) || v.utmMedium.toLowerCase() === "organic"},{"name":"referral","test":(v) => new RegExp("^(?:referral|app|link)$", "i").test(v.utmMedium)},{"name":"email","test":(v) => new RegExp("^(?:email|e-mail|e_mail|e mail)$", "i").test(v.utmMedium) || new RegExp("^(?:email|e-mail|e_mail|e mail)$", "i").test(v.utmSource)},{"name":"affiliate","test":(v) => v.utmMedium.toLowerCase() === "affiliate"},{"name":"audio","test":(v) => v.utmMedium.toLowerCase() === "audio"},{"name":"sms","test":(v) => v.utmSource.toLowerCase() === "sms" || v.utmMedium.toLowerCase() === "sms"},{"name":"mobile-push-notification","test":(v) => v.utmSource.toLowerCase() === "firebase" || new RegExp("(?:.*mobile.*|.*notification.*|push$)", "i").test(v.utmMedium)}].find(s=>s.test(t)))==null?void 0:i.name)??"other"}getShopifyAnalyticsId(){return this.getCookie("_shopify_y")}legacyGetCookieVisitor(){const t=this.getCookie("SHOPLIFT");return t===null?null:JSON.parse(t,k)}getCookie(t){const e=this.cookie.split("; ").filter(i=>i.split("=").at(0)===t).at(0);return e===void 0?null:e.split("=").slice(1).join("=")}monitorConsentChange(){document.addEventListener("visitorConsentCollected",t=>void(async()=>await this.onConsentChange(t.detail.analyticsAllowed,!0))()),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>this.loadShopifyConsentApiWithRetry()):this.loadShopifyConsentApiWithRetry()}loadShopifyConsentApiWithRetry(){let t=0;const e=()=>{this.loadShopifyConsentApi()||t++<10&&window.setTimeout(e,100)};e()}loadShopifyConsentApi(){if(window.Shopify){this.log("Loading Shopify features");const t=async()=>{if(!window.Shopify){this.log("Shopify object missing... suddenly?");return}if(window.Shopify.customerPrivacy===void 0){this.log("Shopify CustomerPrivacy api still missing, trying again in 1000ms"),e=window.setTimeout(()=>void(async()=>await t())(),1e3);return}const i=window.Shopify.customerPrivacy.getTrackingConsent();await this.onConsentChange(window.Shopify.customerPrivacy.analyticsProcessingAllowed(),i==="yes")};let e=window.setTimeout(()=>void(async()=>await t())(),5e3);return window.Shopify.loadFeatures([{name:"consent-tracking-api",version:"0.1"}],i=>{(async()=>{if(window.clearTimeout(e),i){this.log("Error loading consent tracking",i);return}await t()})()}),!0}return!1}async onConsentChange(t,e){try{if(this.log("Consent change detected"),this.state.essential.consentApproved=t,this.state.essential.hasConsentInteraction=e,!this.state.essential.consentApproved){this.state.essential.hasConsentInteraction&&(this.state.analytics.queue.length=0),this.saveState();return}this.cookie=document.cookie,this.shopifyAnalyticsId=this.getShopifyAnalyticsId();for(const i of this.state.analytics.queue.filter(s=>s.type===1||s.type===2)){const s=i;s.shopifyAnalyticsId=this.shopifyAnalyticsId}this.saveState(),await this.syncAllEvents()}catch(i){this.log("Error syncing on consent change",i)}}isThemePreview(){return isThemePreview||themeRole!=="main"}clearThemeBar(t,e,i){const s=structuredClone(i);this.log("Looking for theme bar"),this.waitForElement(null,"body").then(r=>this.waitForElement(r,"#preview-bar-iframe, #PBarNextFrameWrapper").then(n=>(this.log("Found theme bar"),e&&(this.log("Removing theme bar"),n.remove()),t?this.makeRequest({url:`${this.eventHost}/api/v0/logs`,method:"post",data:JSON.stringify({...this.debugState(),stateAtEvaluation:s},A)}):Promise.resolve(null)))).catch(r=>console.error(r))}waitForElement(t,e){return new Promise(i=>{const s=document.querySelector(e);if(s){i(s);return}const r=new MutationObserver(n=>{const o=document.querySelector(e);if(o){r.disconnect(),i(o);return}});r.observe(t??document.documentElement,{childList:!0})})}setDebug(t){this.state.essential.debugMode=t,this.saveState()}log(t,...e){this.logHistory.push([`[SL] ${t}`,...e.map(i=>JSON.stringify(i))].join(" ")),!(!this.state.essential.debugMode&&!this.shopliftDebug)&&console.debug(`[SL] ${t}`,...e)}debugState(){return{state:this.state,storage:{essential:this.loadLocalStorage(this.essentialSessionKey),analytics:this.loadLocalStorage(this.analyticsSessionKey)},params:{shop:this.shop,host:this.host,eventHost:this.eventHost,cssHideClass:this.cssHideClass,testConfigs:this.testConfigs,inactiveTestConfigs:this.inactiveTestConfigs,sendPageView:this.sendPageView,isShopifyMerchantCookie:this.getCookie("is_shopify_merchant"),themeId,url:window.location.href,isThemePreview,themeRole,gaConfig:this.gaConfig},logHistory:this.logHistory}}debug(){const t=this.debugState();console.log(JSON.stringify(t,A,2))}}(async function(){window.shopliftInstance||(window.shopliftInstance=new X("devshopsimplenursing.myshopify.com","https://app.shoplift.ai","https://events.shoplift.ai",false,false,false,{"sendEvents":false,"mode":"gtag"},false,1000,[],[]),await window.shopliftInstance.init())})()})(); })("/en-in", { suffix: "nursing-care-plans-inner", type: "page" }, "main", 176946676008, false)</script>
Risk of Electrolyte Imbalance Nursing Diagnosis & Care Plan – devshopsimplenursing
Skip to content
Electrolyte Imbalance Nursing Diagnosis & Care Plan
Why trust SimpleNursing
Over 125 Years of Healthcare Expertise: 125+ years of combined healthcare experience with a focus in nursing education.
Exceptional User Satisfaction: 4.9/5 average rating from 3,500+ reviews across TrustPilot , WorthePenny , and other trusted review sites.
Proven Success: Over 1 million nurses served since 2012 with a 99% NCLEX pass rate (2024 NCLEX average pass rate = 73.26%).
Team Composition: Staff includes RNs, MSNs, DHSs, nursing professors, and current/former NCLEX question writers.
Jump to Sections
Electrolytes are the body’s backstage crew, making sure every system hits its mark.
From muscle movement to heart rhythm, they run the show behind the scenes. But when things go off script, it’s the nurse’s job to step in fast.
That’s where the electrolyte imbalance nursing diagnosis comes in — helping catch the chaos before it steals the spotlight.
What is Electrolyte Imbalance?
When electrolytes are out of whack, so is everything else — think fluid overload, muscle cramps, or even cardiac issues.
A solid understanding of the nursing diagnosis for imbalanced electrolytes is key to catching problems early and keeping the body’s balance in check.
VIDEO
Definition and Overview
Electrolyte imbalance occurs when there is an abnormal level of electrolytes in the body, disrupting physiological processes.
Electrolytes, including sodium, potassium, calcium, magnesium, phosphate, and chloride, play crucial roles in maintaining:
Fluid balance
Nerve conduction
Muscle contraction
Acid-base balance
Importance of Electrolytes in Body Function
Sodium (Na+): Maintains extracellular fluid balance, nerve conduction, and muscle function
Potassium (K+): Regulates intracellular fluid balance, cardiac rhythm, and neuromuscular function
Calcium (Ca2+): Essential for bone health, muscle contraction, nerve signaling, and blood clotting
Magnesium (Mg2+): Supports enzyme function, neuromuscular activity, and cardiac rhythm
Phosphate (PO4³⁻): Vital for bone structure, energy production (adenosine triphosphate or ATP), and acid-base balance
Chloride (Cl⁻): Maintains osmotic pressure, fluid balance, and acid-base balance
Causes of Electrolyte Imbalance (Related To)
From heavy fluid loss to chronic illnesses and certain meds, there are plenty of ways electrolytes can get thrown off.
Understanding the causes behind a nursing diagnosis for imbalanced electrolytes helps connect the dots and guide the right interventions before things spiral out of control.
Fluid Loss
Vomiting and diarrhea: Loss of sodium, potassium, and chloride
Excessive sweating: Sodium and chloride loss
Hemorrhage: Loss of all electrolytes due to blood loss
Burns: Fluid and electrolyte loss through damaged skin
Chronic Conditions
Renal disease: Impaired excretion or reabsorption of electrolytes (e.g., hyperkalemia, hyperphosphatemia)
Medication-induced imbalances
Diuretics: Loop diuretics (e.g., furosemide) cause hypokalemia and hyponatremia.
Corticosteroids: Sodium and water retention leads to hypernatremia and hypokalemia.
Angiotensin-converting enzyme (ACE) inhibitors and angiotensin II receptor blockers (ARBs): These medications can cause hyperkalemia by reducing aldosterone levels.
Dietary deficiencies or excesses
Poor nutritional intake: Malnutrition leading to hypokalemia, hypocalcemia, or hypomagnesemia
Excessive supplementation: Overuse of supplements causing hyperkalemia or hypercalcemia
Alcohol abuse: Hypomagnesemia and hypophosphatemia
Signs and Symptoms of Electrolyte Imbalance (As Evidenced By)
Electrolyte shifts can affect nearly every system in the body — nerves, muscles, the heart, and more.
Each imbalance has a unique set of signs, and recognizing them early helps guide faster, safer interventions.
VIDEO
Sodium Imbalances
Hypernatremia
Causes
Dehydration
Excessive sodium intake
Hyperaldosteronism
Signs and Symptoms
Neurological: Thirst, restlessness, irritability, confusion, seizures, coma.
Muscle weakness and twitching
Increased blood pressure (BP) and edema
Hyponatremia
Causes
Signs and Symptoms
Neurological: Headache, nausea, lethargy, confusion, seizures, coma
Muscle cramps and weakness
Hypotension and tachycardia
Potassium Imbalances
Hyperkalemia
Causes
Renal failure
Potassium-sparing diuretics
Acidosis
Tissue injury
Signs and Symptoms
Cardiac: Irregular heartbeat, bradycardia, arrhythmias, cardiac arrest
Neuromuscular: Muscle weakness, flaccid paralysis
Gastrointestinal (GI) symptoms: Nausea, vomiting, diarrhea
Hypokalemia
Causes
Diuretics
Vomiting
Diarrhea
Alkalosis
Insulin overdose
Signs and Symptoms
Cardiac: Arrhythmias , palpitations, hypotension
Neuromuscular: Fatigue, muscle cramps, paresthesia, paralysis
GI symptoms: Constipation, ileus
Calcium Imbalances
Hypercalcemia (Bone Pain, Kidney Stones, Weakness)
Causes
Hyperparathyroidism
Malignancies
Excessive vitamin D
Calcium intake
Signs and Symptoms
Muscle weakness and hyporeflexia
GI symptoms: Constipation, nausea, vomiting
Kidney stones and polyuria
Neurological: Confusion, lethargy, coma
Hypocalcemia
Causes
Hypoparathyroidism
Vitamin D deficiency
Renal failure
Signs and Symptoms
Magnesium Imbalances
Hypermagnesemia
Causes
Renal failure
Excessive magnesium intake (e.g., antacids, laxatives)
Signs and Symptoms
Hypotension and bradycardia
Muscle weakness and hyporeflexia
Confusion and respiratory depression
Hypomagnesemia
Causes
Malnutrition
Chronic alcoholism
Diuretics
Diarrhea
Signs and Symptoms
Neuromuscular excitability: Tremors, hyperreflexia, tetany, seizures
Cardiac arrhythmias and palpitations
Mood changes: Depression, irritability
Phosphate Imbalances
Hyperphosphatemia
Causes
Signs and symptoms
Muscle cramps and spasms
Numbness and tingling
Tetany (with concurrent hypocalcemia)
Hypophosphatemia
Causes
Signs and Symptoms
Weakness and bone pain
Mental status changes: Irritability, confusion, seizures
Respiratory muscle weakness
Chloride Imbalances
Hyperchloremia
Causes
Dehydration
Metabolic acidosis
Respiratory alkalosis
Signs and Symptoms
Dehydration and thirst
Metabolic acidosis symptoms: Rapid breathing, confusion
Hypochloremia
Causes
Vomiting
Diarrhea
Metabolic alkalosis
Diuretics
Signs and Symptoms:
Muscle twitching and tetany
Hypotension and dehydration
Shallow respirations
Risk Factors for Electrolyte Imbalance
Some patients are more prone to electrolyte imbalances than others.
Here are common risk factors.
Age-related risks (infants, older adults)
1. Infants and Young Children
Higher Fluid Turnover and Immature Renal Function
Infants have a higher body water content (70% to 80%) than adults, leading to a higher risk of dehydration and electrolyte imbalances.
Immature kidneys have a limited ability to concentrate urine, increasing the risk of sodium and potassium imbalances.
Causes of Imbalance in Infants
Gastroenteritis: Vomiting and diarrhea leading to hyponatremia and hypokalemia
Inadequate fluid intake: Can cause hypernatremia due to dehydration
Overhydration or diluted formula: May lead to hyponatremia (water intoxication)
Signs and Symptoms in Infants
Sunken fontanelles
Dry mucous membranes
Irritability
Lethargy
Poor feeding
Decreased urine output
2. Older Adults
Decreased Thirst Mechanism and Renal Function
Age-related decline in the thirst mechanism increases the risk of dehydration and hypernatremia.
Reduced renal function impairs the ability to excrete excess electrolytes (e.g., potassium and phosphate).
Chronic Medication Use
Diuretics, laxatives, ACE inhibitors, and antacids can lead to electrolyte imbalances.
Polypharmacy increases the risk of drug interactions affecting electrolyte balance.
Chronic Illnesses and Comorbidities
Diabetes, hypertension, heart failure, and chronic kidney disease (CKD) are more prevalent in older adults, increasing the risk of imbalances.
Decreased Nutritional Intake and Mobility
The patient has inadequate dietary intake of essential electrolytes (e.g., calcium, potassium, and magnesium).
Limited mobility may contribute to dehydration and muscle wasting.
Chronic disease considerations
1. Renal Disease
Chronic Kidney Disease (CKD) and Acute Kidney Injury:
Impaired excretion of potassium, phosphorus, and magnesium leads to hyperkalemia, hyperphosphatemia, and hypermagnesemia.
Inability to concentrate urine can cause hyponatremia or hypernatremia.
Metabolic acidosis is common due to impaired hydrogen ion excretion.
2. Cardiovascular Disease
Activation of the renin-angiotensin-aldosterone system leads to sodium and water retention, causing hypernatremia and edema.
Diuretic use (e.g., furosemide) increases the risk of hypokalemia and hypomagnesemia.
Thiazide and loop diuretics promote sodium and potassium excretion, leading to hyponatremia and hypokalemia.
ACE inhibitors and ARBs can cause hyperkalemia by decreasing aldosterone production.
3. Endocrine Disorders
Diabetic ketoacidosis (DKA) causes hyperkalemia and hyperphosphatemia due to acidosis and insulin deficiency.
HHS leads to severe dehydration and hypernatremia.
Adrenal Disorders
Addison’s disease: Decreased aldosterone production causes hyponatremia and hyperkalemia.
Cushing’s syndrome: Excess cortisol causes sodium and fluid retention, which leads to hypernatremia and hypokalemia.
4. Gastrointestinal Disorders
Vomiting and Diarrhea
Loss of sodium, potassium, and chloride leads to hyponatremia, hypokalemia, and metabolic alkalosis.
Malabsorption Syndromes (e.g., Celiac Disease, Crohn’s Disease):
Impaired absorption of calcium, magnesium, and potassium
Risk of hypocalcemia, hypomagnesemia, and hypokalemia
Nasogastric Suctioning or Fistulas
Loss of gastric acid and electrolytes leading to hypokalemia, hyponatremia, and metabolic alkalosis
Lifestyle and Dietary Influences
1. Nutritional Deficiencies and Excesses
Inadequate Dietary Intake
Low potassium intake (e.g., from fruits and vegetables) leads to hypokalemia.
Calcium and vitamin D deficiencies increase the risk of hypocalcemia.
Excessive Supplementation
Excessive potassium or magnesium supplementation can lead to hyperkalemia or hypermagnesemia.
High calcium intake increases the risk of hypercalcemia and kidney stones.
Alcohol Abuse
Chronic alcoholism causes hypomagnesemia, hypokalemia, and hypophosphatemia.
2. Dehydration and Overhydration
Dehydration: Causes hypernatremia and hyperchloremia due to fluid loss.
Overhydration (water Intoxication): Excessive water intake or intravenous hypotonic solutions can cause hyponatremia.
3. Physical Activity and Environmental Factors
Excessive sweating: Loss of sodium and chloride through perspiration during intense exercise or heat exposure
Nursing Assessment for Electrolyte Imbalance
A solid nursing assessment for imbalanced electrolytes helps spot the warning signs early.
Subjective vs. Objective Data Collection
Subjective Data Collection
History of Present Illness:
Onset, duration, and severity of symptoms (e.g., fatigue, muscle cramps, confusion)
Recent vomiting, diarrhea, excessive sweating, or fluid intake
Use of diuretics, laxatives, or other medications affecting electrolytes
Past Medical History
History of renal disease, diabetes, cardiovascular disease, or endocrine disorders
Recent surgery, burns, or trauma affecting fluid and electrolyte balance
Dietary and Lifestyle History
Dietary intake of fluids, sodium, potassium, calcium, and magnesium
Alcohol consumption, physical activity level, and environmental exposure
Vital Signs
BP, heart rate, respiratory rate, and temperature
Hypotension and tachycardia: Indicate dehydration or hypovolemia.
Hypertension: May indicate hypernatremia or fluid overload.
Physical Examination
Neurological assessment: Confusion, seizures, lethargy, or altered mental status
Muscle strength and reflexes: Hyperreflexia (hypocalcemia or hypomagnesemia) or hyporeflexia (hypermagnesemia)
Cardiac assessment: Irregular heartbeat, arrhythmias, or palpitations
Edema and fluid status: Peripheral edema or dehydration signs (dry mucous membranes, poor skin turgor)
Monitoring vital signs, lab values, and symptoms
1. Electrolyte Panel
Abnormal Findings
Hyponatremia: < 135 milliequivalents per liter (mEq/L) – Confusion, seizures, coma
Hypernatremia: > 145 mEq/L – Thirst, irritability, lethargy, seizures
Hypokalemia: < 3.5 mEq/L – Muscle cramps, arrhythmias, fatigue
Hyperkalemia: > 5 mEq/L – Cardiac arrhythmias, muscle weakness, paralysis
Hypocalcemia: < 8.5 mg/dL – Tetany, muscle spasms, seizures, arrhythmias
Hypercalcemia: > 10.5 mg/dL – Muscle weakness, confusion, kidney stones
Arterial Blood Gases (ABGs)
Purpose: To assess acid-base balance and respiratory compensation.
Frequency: As ordered for patients with acid-base disturbances.
Interpretation:
Metabolic acidosis: Low pH, low HCO3⁻ (e.g., hyperkalemia, renal failure)
Metabolic alkalosis: High pH, high HCO3⁻ (e.g., hypokalemia, vomiting)
Respiratory acidosis: Low pH, high PaCO2 (e.g., hyperkalemia, respiratory depression)
Respiratory alkalosis: High pH, low PaCO2 (e.g., hypocalcemia, hyperventilation)
3. Renal Function Tests
Purpose: To assess renal excretion of electrolytes.
Key tests:
Blood urea nitrogen (BUN): 7-20 mg/dL
Serum creatinine: 0.6-1.2 mg/dL
Urine specific gravity: 1.005-1.030
Abnormal findings:
Elevated BUN and creatinine: Indicate renal impairment or dehydration
Low urine specific gravity: Suggests diluted urine (e.g., diabetes insipidus, overhydration)
High urine specific gravity: Indicates concentrated urine (e.g., dehydration, SIADH)
Symptom Monitoring and Physical Assessment
1. Neurological Assessment
Abnormal Findings
Confusion, disorientation, or lethargy: Hyponatremia, hypernatremia, hypocalcemia, or hypomagnesemia
Seizures: Hyponatremia, hypocalcemia, hypomagnesemia
Coma: Severe hypernatremia, hypercalcemia, or hypoglycemia
2. Musculoskeletal Assessment
Abnormal Findings
Muscle cramps and weakness: Hypokalemia, hyperkalemia, hypocalcemia, or hypomagnesemia
Tetany and muscle spasms: Hypocalcemia or hypomagnesemia
Hyperreflexia or hyporeflexia: Hyperreflexia in hypocalcemia and hypomagnesemia; hyporeflexia in hypermagnesemia
Electrolyte panel interpretation
Basic Metabolic Panel or Comprehensive Metabolic Panel
Sodium (Na+): 135-145 mEq/L
Potassium (K+): 3.5-5 mEq/L
Calcium (Ca2+): 8.5-10.5 mg/dL
Magnesium (Mg2+): 1.5-2.5 mEq/L
Phosphate (PO4³⁻): 2.5-4.5 mg/dL
Chloride (Cl⁻): 96-106 mEq/L
ABG analysis: To evaluate acid-base imbalances associated with electrolyte disturbances
Electrocardiogram (ECG) monitoring: To detect cardiac arrhythmias related to potassium, calcium, or magnesium imbalances
Nursing Diagnosis for Electrolyte Imbalance
A clear nursing diagnosis for electrolyte imbalance keeps care focused, timely, and clinically effective.
Risk for Electrolyte Imbalance (General Nursing Diagnosis)
Risk for changes in serum electrolyte levels that may compromise health and function
Related To:
Acute illness (e.g., gastroenteritis, surgical procedures)
Chronic conditions (e.g., renal disease, heart failure, diabetes)
Medications (e.g., diuretics, corticosteroids, laxatives, ACE inhibitors)
Inadequate or excessive intake of electrolytes (e.g., dietary deficiencies, supplements)
Fluid imbalances (e.g., dehydration, fluid overload)
Electrolyte Imbalance Nursing Diagnoses
Hyponatremia:
Serum sodium level < 135 mEq/L, leading to neurological and cardiovascular changes
Related To:
Diuretics (e.g., thiazides, loop diuretics)
Excessive water intake or hypotonic IV fluids
SIADH
GI losses (e.g., vomiting, diarrhea)
As Evidenced By:
Headache, nausea, vomiting, and lethargy
Confusion, seizures, and coma in severe cases
Muscle cramps and weakness
Hyperkalemia
Serum potassium level > 5 mEq/L, affecting cardiac and neuromuscular function
Related To:
Renal failure or decreased renal excretion
Potassium-sparing diuretics (e.g., spironolactone)
Metabolic acidosis (e.g., DKA)
Tissue injury or hemolysis (e.g., burns, trauma)
As Evidenced By:
Cardiac arrhythmias (e.g., bradycardia, ventricular fibrillation)
Muscle weakness, flaccid paralysis
Nausea, vomiting, diarrhea
Hypocalcemia
Serum calcium level < 8.5 mg/dL, causing neuromuscular excitability and cardiac changes
Related To:
Hypoparathyroidism or vitamin D deficiency
Chronic kidney disease or malabsorption syndromes
Massive blood transfusions (citrate binds calcium)
As Evidenced By:
Neuromuscular excitability: Tetany, muscle spasms, paresthesia
Positive Chvostek’s and Trousseau’s signs
Cardiac arrhythmias (prolonged QT interval)
Expected Outcomes & Nursing Goals
Nursing goals for electrolyte imbalance focus on stabilizing lab values and preventing complications.
Restoring electrolyte balance
Maintain serum electrolyte levels within normal ranges:
Sodium (Na+): 135-145 mEq/L
Potassium (K+): 3.5-5 mEq/L
Calcium (Ca2+): 8.5-10.5 mg/dL
Magnesium (Mg2+): 1.5-2.5 mEq/L
Phosphate (PO4³⁻): 2.5-4.5 mg/dL
Achieve and maintain fluid balance
Resolution of symptoms (e.g., muscle cramps, confusion, arrhythmias)
Preventing complications
Prevent cardiac complications (e.g., arrhythmias, cardiac arrest)
Prevent neurological complications (e.g., seizures, altered mental status)
Prevent renal complications (e.g., acute kidney injury, fluid overload)
Patient education and lifestyle modifications
Educate on the causes and prevention of electrolyte imbalances.
Teach dietary modifications to maintain electrolyte balance.
Emphasize medication adherence and monitoring for side effects.
Instruct on signs and symptoms of electrolyte imbalances to seek early intervention.
Nursing Interventions for Electrolyte Imbalance
These nursing interventions are key to spotting changes early and restoring balance.
Assessment & Monitoring Interventions
1. Regular Electrolyte and Fluid Status Checks
Frequency: Daily or as ordered for critical patients
Parameters monitored:
Serum electrolyte levels (Na+, K+, Ca2+, Mg2+, PO4³⁻, Cl⁻)
Fluid intake and output
Weight monitoring for fluid balance
Nursing actions:
Notify the health care provider about abnormal electrolyte values.
Monitor for signs of dehydration or fluid overload.
ECG monitoring for potassium imbalances
Purpose: To detect cardiac arrhythmias associated with hyperkalemia or hypokalemia
Key ECG changes:
Hyperkalemia: Peaked T waves, widened QRS complex, ventricular fibrillation
Hypokalemia: Flattened T waves, U waves, premature ventricular contractions
Nursing actions:
Continue ECG monitoring for high-risk patients.
Notify the health care provider immediately about new-onset arrhythmias.
Fluid and Medication Management
1. IV Therapy for Severe Cases
Purpose: To correct electrolyte imbalances rapidly
IV solutions used:
Hyponatremia: Hypertonic saline (3% NaCl) for severe cases
Hyperkalemia: IV insulin with glucose, calcium gluconate, or sodium bicarbonate
Hypocalcemia: IV calcium gluconate or calcium chloride
Nursing actions:
Monitor for complications (e.g., fluid overload, rapid electrolyte shifts).
Frequent electrolyte monitoring during IV therapy
Medications
Diuretics:
Loop diuretics: For hypercalcemia or hyperkalemia
Potassium-sparing diuretics: For hypokalemia prevention
Electrolyte supplements: Oral potassium, calcium, and magnesium supplements for deficiencies
Dialysis: Hemodialysis or peritoneal dialysis for severe renal impairment
Dietary & Lifestyle Modifications
Increasing/Decreasing Specific Electrolytes Through Diet
High potassium foods: Consume bananas, oranges, spinach, and potatoes (for hypokalemia).
Low potassium diet: Avoid bananas, oranges, and potatoes (for hyperkalemia).
Calcium-rich foods: Consume dairy products and green leafy vegetables (for hypocalcemia).
Low sodium diet: Avoid processed foods and table salt (for hypernatremia).
Education on hydration and medication effects
Hydration: Maintain adequate hydration to prevent imbalances.
Medication education: Educate on medications affecting electrolytes (e.g., diuretics, ACE inhibitors).
Lifestyle changes: Encourage a balanced diet and regular exercise.
Electrolyte Imbalance Nursing Care Plan Examples
Check out these care plan examples to see how a nursing diagnosis for imbalanced electrolytes is implemented in real-life clinical settings.
Care Plan #1: Hyponatremia in a Post-Operative Patient
Nursing Diagnosis
Risk for Electrolyte Imbalance
Related To:
Excessive administration of hypotonic IV fluids
Surgical stress response leading to increased ADH secretion (SIADH)
Loss of sodium through wound drainage or nasogastric suction
As Evidenced By:
Confusion, headache, lethargy, and nausea
Muscle cramps and weakness
Serum sodium < 135 mEq/L
Expected Outcomes
Short-Term Goals
Maintain serum sodium levels between 135 and 145 mEq/L within 24 to 48 hours.
Demonstrate improved neurological status (e.g., alert, oriented).
Report reduced symptoms of headache, nausea, and muscle cramps.
Long-Term Goals
Maintain electrolyte balance through appropriate fluid and dietary intake.
Prevent recurrence of hyponatremia during hospitalization.
Assessment
Neurological Assessment
Monitor level of consciousness (LOC), orientation, and behavior changes.
Assess for confusion, agitation, seizures, and coma in severe hyponatremia.
Vital Signs and Fluid Balance
Monitor BP, heart rate, and respiratory rate
Record intake and output (I&O) to assess fluid balance
Monitor for signs of fluid overload (e.g., edema, dyspnea)
Laboratory Assessment
Serum sodium (Na+): Monitor every four to six hours until stabilized.
Serum osmolality and urine specific gravity: Evaluate fluid status and SIADH.
Interventions
1. Fluid and Electrolyte Management
Restrict free water intake: Limit to 800 to 1,000 mL/day to prevent dilutional hyponatremia.
Administer hypertonic saline (3% NaCl):
Use hypertonic saline for severe hyponatremia (< 120 mEq/L) with neurological symptoms.
Administer cautiously to avoid osmotic demyelination syndrome.
Monitor serum sodium every 4 hours during infusion.
Discontinue hypotonic IV fluids: Switch to isotonic or hypertonic solutions as needed.
2. Neurological Monitoring and Safety Precautions
Monitor LOC, orientation, and neurological status every two to four hours.
Implement seizure precautions: Use padded side rails, oxygen, and suction at the bedside.
Maintain a quiet, low-stimulation environment to minimize confusion and agitation.
3. Patient Education
Educate the patient on fluid restrictions and the importance of adhering to the prescribed fluid intake.
Instruct the patient on recognizing early symptoms of hyponatremia (e.g., headache, nausea, and confusion).
Educate the patient on dietary sources of sodium (e.g., salt, cheese, and processed foods).
Care Plan #2: Hyperkalemia in a Dialysis Patient
Nursing Diagnosis
Related To:
Impaired renal excretion of potassium due to CKD
High potassium intake (dietary or medications such as ACE inhibitors)
Missed or inadequate dialysis sessions
As Evidenced By:
ECG changes: Peaked T waves, widened QRS complex
Muscle weakness and flaccid paralysis
Serum potassium > 5 mEq/L
Expected Outcomes
Short-Term Goals
Restore serum potassium levels to 3.5 to 5 mEq/L within 24 hours.
Maintain stable cardiac rhythm and normal ECG findings.
Report relief from muscle weakness and paresthesia.
Long-Term Goals
Maintain potassium levels within the normal range through dietary and medication management.
Prevent recurrence of hyperkalemia by adhering to the dialysis schedule and dietary restrictions.
Assessment
Cardiac and ECG Monitoring
Continuously monitor ECG for dysrhythmias (e.g., bradycardia, ventricular fibrillation).
Monitor pulse rate and rhythm for irregularities.
Neuromuscular Assessment
Assess muscle strength and reflexes for flaccid paralysis or hyporeflexia.
Monitor for paresthesia (tingling) or muscle cramps.
Laboratory Assessment
Serum potassium (K+): Every four to six hours until stabilized
BUN and creatinine: To assess renal function and dialysis effectiveness
Interventions
1. Potassium Lowering Therapies
Calcium gluconate IV: To stabilize the cardiac membrane
IV insulin and dextrose: To drive potassium into cells and lower serum levels
Sodium polystyrene sulfonate (kayexalate): To promote potassium excretion through the GI tract
Dialysis: Emergency hemodialysis for severe hyperkalemia or renal failure.
2. Dietary and Medication Management
Potassium-restricted diet: Limit intake of potassium-rich foods (e.g., bananas, oranges, spinach).
Discontinue potassium-sparing medications: Temporarily stop ACE inhibitors or spironolactone.
3. Patient Education
Educate on adhering to dialysis schedules and potassium-restricted diets
Instruct on recognizing symptoms of hyperkalemia (e.g., palpitations, muscle weakness)
Educate on medication compliance and avoiding potassium supplements
Care Plan #3: Hypocalcemia in a Post-thyroidectomy Patient
Nursing Diagnosis
Related To:
Hypocalcemia secondary to hypoparathyroidism after thyroidectomy
Decreased serum calcium leading to neuromuscular excitability and laryngospasm
As Evidenced By:
Positive Chvostek’s and Trousseau’s signs
Muscle cramps, tetany, and seizures
Serum calcium < 8.5 mg/dL
Expected Outcomes
Short-Term Goals
Restore serum calcium levels to 8.5-10.5 mg/dL within 24 to 48 hours.
Prevent neuromuscular excitability and respiratory complications.
Report relief from muscle cramps and paresthesia.
Long-Term Goals
Maintain serum calcium within normal range through supplementation.
Prevent the recurrence of hypocalcemia by adhering to prescribed medications and dietary intake.
Assessment
1. Subjective Data Collection
Patient History
Recent surgery or medical procedures (e.g., use of hypotonic IV fluids)
History of chronic conditions affecting fluid balance (e.g., heart failure, renal disease)
Medications that can cause hyponatremia (e.g., diuretics, SSRIs)
Reported Symptoms
Headache, nausea, and vomiting
Fatigue, irritability, or restlessness
Dizziness or a feeling of imbalance
Difficulty concentrating or memory loss
2. Objective Data Collection
Neurological Assessment
LOC: Assess for confusion, disorientation, lethargy, or coma in severe cases.
Mental status examination: Assess orientation to person, place, and time.
Neuromuscular assessment:
Muscle cramps, twitching, or weakness
Tremors or hyperreflexia
Seizure activity: Monitor for seizure onset in severe hyponatremia.
Vital Signs and Fluid Balance
BP: Monitor for hypotension or orthostatic hypotension in hypovolemic hyponatremia.
Heart rate (pulse): Monitor for tachycardia due to hypovolemia or bradycardia in severe cases.
Respiratory rate: Monitor for an increased rate if neurological compromise is present.
I&O: Monitor fluid balance to detect fluid overload or deficit.
Daily weight: Monitor for rapid weight changes indicating fluid shifts.
3. Laboratory and Diagnostic Assessment
Serum sodium (Na+): < 135 mEq/L confirms hyponatremia
Serum osmolality:
Hypotonic hyponatremia: Low serum osmolality, < 280 milliosmoles per kilogram (mOsm/kg)
Isotonic or hypertonic hyponatremia: Normal or high osmolality (e.g., hyperglycemia).
Urine osmolality and sodium:
High urine sodium (> 20 mEq/L): SIADH or renal salt wasting
Low urine sodium (< 20 mEq/L): Extrarenal losses (e.g., vomiting, diarrhea)
ECG monitoring: Monitor for arrhythmias, particularly in severe hyponatremia.
Interventions
1. Calcium and Vitamin D Supplementation
IV calcium gluconate or calcium chloride: For severe hypocalcemia with tetany
Oral calcium and vitamin D supplements: For long-term management
2. Neuromuscular and Respiratory Monitoring
Monitor for tetany, muscle spasms, and laryngospasm.
Maintain airway patency and have emergency equipment ready.
3. Patient Education
Educate on recognizing symptoms of hypocalcemia (e.g., numbness, tingling, muscle cramps).
Instruct on dietary sources of calcium (e.g., dairy, leafy greens) and vitamin D.
Prevention of Electrolyte Imbalance and Complications
Staying ahead of electrolyte imbalances isn’t just about reacting. It’s about being proactive.
By teaching patients how to manage fluids, food, and meds wisely, nurses can help them dodge serious complications before they even start.
Patient education on fluid and electrolyte management
1. Importance of Electrolyte Balance
Educate patients on the role of electrolytes in maintaining fluid balance, nerve conduction, muscle contraction, and acid-base balance.
Explain how imbalances can lead to serious complications such as cardiac arrhythmias, seizures, and renal dysfunction.
2. Dietary Education and Modifications
Sodium intake:
Hyponatremia prevention: Educate patients on incorporating moderate sodium intake through balanced foods (e.g., dairy, eggs, and salted nuts).
Hypernatremia prevention: Limit sodium intake by avoiding processed foods, canned soups, and high-sodium snacks.
Potassium intake:
Hypokalemia prevention: Encourage potassium-rich foods (e.g., bananas, oranges, potatoes, and spinach).
Hyperkalemia prevention: Limit high-potassium foods for patients with renal impairment.
Calcium and vitamin D intake:
Promote calcium-rich foods (e.g., dairy products, leafy greens) and vitamin D supplements to enhance calcium absorption.
Educate patients on avoiding excessive calcium supplements to prevent hypercalcemia.
Magnesium and phosphate balance:
Encourage magnesium-rich foods (e.g., nuts, seeds, and whole grains) for hypomagnesemia.
Limit phosphate intake in patients with renal disease (e.g., avoiding processed foods and cola).
3. Medication Education and Management
Diuretics:
Educate on the risk of electrolyte imbalances (e.g., hypokalemia, hyponatremia) with loop and thiazide diuretics.
Advise regular monitoring of serum electrolytes and potassium supplements if needed.
ACE inhibitors and ARBs: Instruct on the risk of hyperkalemia and the importance of avoiding potassium-rich foods and supplements.
Laxatives and antacids: Educate on avoiding overuse, which can lead to hypokalemia and hypomagnesemia.
4. Lifestyle Modifications
Regular physical activity:
Encourage moderate exercise to maintain electrolyte balance and overall health.
Educate on replacing lost electrolytes during intense exercise or sweating with electrolyte drinks.
Alcohol and caffeine moderation: Limit alcohol and caffeine intake to reduce diuresis and electrolyte loss.
Managing chronic conditions to prevent imbalances
Here’s how to manage common diseases to keep electrolyte levels steady and patients safe.
1. Renal Disease and Dialysis Management
Regular monitoring:
Encourage routine serum electrolyte monitoring in patients with CKD or on dialysis.
Monitor potassium, calcium, phosphate, and magnesium levels closely.
Dietary adjustments:
Educate the patient on a renal-friendly diet to manage hyperkalemia, hyperphosphatemia, and fluid overload.
Low potassium diet: Limit high-potassium foods (e.g., potatoes, bananas, and citrus fruits).
Phosphate binders: Instruct the patient on using phosphate binders with meals to manage hyperphosphatemia.
2. Cardiovascular Disease
Hypertension and heart failure:
Monitor electrolyte levels when using diuretics or ACE inhibitors.
Encourage a low-sodium, balanced diet to prevent hypernatremia and fluid overload.
Educate on daily weight monitoring to detect fluid imbalances.
3. Endocrine Disorders
Diabetes mellitus:
Educate on preventing hyperglycemia-induced osmotic diuresis leading to hyponatremia and hypokalemia.
Encourage regular blood glucose monitoring and adherence to antidiabetic medications.
Adrenal insufficiency (Addison’s disease): Educate on maintaining sodium intake and medication adherence to prevent hyponatremia and hyperkalemia.
Patient Education & Discharge Planning
Preventing electrolyte imbalances starts with effective patient education.
Recognizing Symptoms Early
Hyponatremia: Headache, nausea, confusion, lethargy, seizures, and coma
Hypernatremia: Thirst, irritability, lethargy, seizures, and muscle twitching
Hypokalemia: Muscle cramps, weakness, palpitations, arrhythmias, and fatigue
Hyperkalemia: Muscle weakness, paresthesia, palpitations, bradycardia, and cardiac arrest
Hypocalcemia: Numbness, tingling, muscle cramps, tetany, and seizures
Hypercalcemia: Muscle weakness, bone pain, nausea, confusion, and kidney stones
Hypomagnesemia: Tremors, hyperreflexia, seizures, and arrhythmias
Hypermagnesemia: Hypotension, bradycardia, respiratory depression, and muscle weakness
Long-term Electrolyte Monitoring Strategies
Regular Blood Tests
Educate patients on the importance of regular blood tests to monitor electrolyte levels.
The frequency of monitoring depends on underlying conditions (e.g., CKD and heart failure).
Home Monitoring
Educate patients on using home blood pressure monitors and weight scales to detect fluid imbalances.
Encourage daily weight monitoring to detect early signs of fluid retention.
Recommended Resources for Electrolyte Imbalance
These resources break down the must-know info for managing imbalances like a pro — straight from the experts.
Nursing Care Plan Resources
Staying in Balance with Electrolyte Care
Electrolyte imbalances can cause serious disruptions, but with the right knowledge and tools, they’re manageable.
A strong understanding of the nursing diagnosis for imbalanced electrolytes helps build clinical confidence and ensures safer, more effective patient care.
References and Sources
Brunner & Suddarth’s Textbook of Medical-Surgical Nursing. 15th ed., Wolters Kluwer, 2021.
National Kidney Foudnation. Electrolyte Imbalances in Chronic Kidney Disease. Accessed February 24, 2025.
American Heart Association. Hypertension Management Guidelines. Accessed February 24, 2025.
Academy of Nutrition and Dietetics. Electrolyte Balance and Nutrition Guidelines. Accessed February 24, 2025.
Centers for Disease Control and Prevention. Chronic Disease Management and Prevention. Accessed February 24, 2025.