// version: 977e4f914dd2b3eca85ad01dee81c2c96eb1b2e5 (function(){let e=`gid://shopify/`,t=`?cart=`,n=/^gid:\/\/shopify\/CartLine\/[-A-Za-z0-9\?=]+$/;function r(t,n){return`${e}${t}/${n}`}function i(t,n){let i=String(n);return i.startsWith(e)?i:r(t,i)}function a(){if(typeof document>`u`)return null;let e=document.cookie.match(/(?:^|;\s*)cart=([^;]*)/);return e&&decodeURIComponent(e[1])||null}let o=e=>e?.replace(r(`Cart`,``),``)??``;function s(e){let t=e??a();return t?i(`Cart`,t):null}let c=(e,t)=>l(e)?u(e,t):String(e),l=e=>n.test(String(e));function u(e,n){let r=String(e);if(!l(r))throw Error(`Expected CartLine GID, received "${r}"`,{cause:{id:e}});if(!r.includes(t)){let e=o(String(n??a()??``)).split(`?`,1)[0];e&&(r=r+t+e)}return r}var d=class extends Error{constructor(e,t){super(e,{cause:t}),this.name=`CartActionError`}},f=class extends Error{constructor(e){super(e),this.name=`ValidationError`}};let p=`update`,m=`removeLineIds`,h=`removeViewKeys`;function g(e){let t=window.Shopify;return{...e,c:t?.country??`US`,l:t?.locale?.replace(/-/g,`_`).toUpperCase()||`EN`}}let _=`fragment f on Cart{id totalQuantity cost{totalAmount{amount currencyCode}} lines(first:250){nodes{id quantity cost{totalAmount{amount currencyCode}}}} discountCodes{applicable code}}`,v=`$c:CountryCode!,$l:LanguageCode!`,y=`@inContext(country:$c,language:$l)`,b=`query($i:ID!,${v})${y}{cart(id:$i){...f}}${_}`,x=`cart{...f}userErrors{code field message}warnings{code message target}`,S=`mutation($i:CartInput!,${v})${y}{cartCreate(input:$i){${x}}}${_}`;async function C(e,t){let n=(await O(b,g({i:e}),t)).data.cart;return n?E(n):null}function w(e){let t={add:[],[p]:[],[m]:[],[h]:[]};for(let n of e){let e=n.id?n.quantity===0?l(n.id)?m:h:n.quantity>0?p:null:`add`;e&&t[e].push(n)}return t}function T(e,t){return!e||!t?.length?e:e.map(e=>{let n=e.field;if(!n)return e;let r=n.findIndex((e,t)=>(e===`lines`||e===`lineIds`||e===`viewKeys`)&&/^\d+$/.test(n[t+1]??``));if(r===-1)return e;let i=t[Number(n[r+1])]?.index;if(i===void 0)return e;let a=[...n];return a[r+1]=String(i),{...e,field:a}})}function ee(e,t){let n=[],r={i:e},i=[`$i:ID!`,v],a=(e,t,a,o,s)=>{i.push(`$${e}:${o}`),r[e]=s,n.push(`${e}:${t}(cartId:$i,${a}:$${e}){${x}}`)};if(t.lines?.length){let{add:e,update:n,removeLineIds:r,removeViewKeys:i}=w(t.lines);e.length&&a(`add`,`cartLinesAdd`,`lines`,`[CartLineInput!]!`,e),n.length&&a(p,`cartLinesUpdate`,`lines`,`[CartLineUpdateInput!]!`,n.map(({id:e,...t})=>l(e)?{id:e,...t}:{viewKey:e,...t})),r.length&&a(m,`cartLinesRemove`,`lineIds`,`[ID!]!`,r.map(e=>e.id)),i.length&&a(h,`cartLinesRemove`,`viewKeys`,`[String!]!`,i.map(e=>e.id))}return t.note!==void 0&&a(`note`,`cartNoteUpdate`,`note`,`String!`,t.note),t.discountCodes!==void 0&&a(`discount`,`cartDiscountCodesUpdate`,`discountCodes`,`[String!]!`,t.discountCodes),t.attributes!==void 0&&a(`attributes`,`cartAttributesUpdate`,`attributes`,`[AttributeInput!]!`,t.attributes),n.length?{query:`mutation(${i.join(`,`)})${y}{${n.join(``)}}${_}`,variables:g(r)}:null}function te(e,t){let n={cart:null};for(let[r,{cart:i,warnings:a,userErrors:o}]of Object.entries(e.data)){i&&(n.cart=E(i));let e=T(o,t?.[r]);e&&(n.userErrors??=[]).push(...e),a&&(n.warnings??=[]).push(...a)}return n}function E(e){return{id:e.id,totalQuantity:e.totalQuantity,cost:e.cost,lines:{nodes:e.lines.nodes},discountCodes:e.discountCodes}}function D(e){if(e.cart)return{cart:E(e.cart),...e.userErrors?.length?{userErrors:e.userErrors}:{},...e.warnings?.length?{warnings:e.warnings}:{}};throw e.userErrors?.length?new d(e.userErrors.map(e=>e.message).join(`, `),{userErrors:e.userErrors,warnings:e.warnings}):Error(`cartCreate: no cart`)}async function O(e,t,n){let r=await fetch(`/api/2026-07/graphql.json`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({query:e,variables:t}),signal:n});if(!r.ok)throw Error(`SFAPI ${r.status} ${r.statusText}`,{cause:r});let i=await r.json();if(!i.data||i.errors?.length)throw Error(i.errors?.map(e=>e.message).join(`, `)||`No SFAPI data`,{cause:i});return i}let k=`AbortError`,A=()=>new DOMException(`The operation was aborted.`,k),j=e=>{if(e?.aborted)throw A()};function M(e,t){return t?(j(t),new Promise((n,r)=>{let i=()=>r(A());t.addEventListener(`abort`,i,{once:!0}),e.finally(()=>t.removeEventListener(`abort`,i)).then(n,r)})):e}function N(e){let t=o(e);document.cookie=`cart=${encodeURIComponent(t)}; path=/; SameSite=Lax`}let P=(e,t)=>O(S,g({i:e}),t).then(e=>e.data.cartCreate);async function F(e,t){if(j(t),I)return{cartId:(await M(I,t)).id};let n=P(e).then(e=>{let t=D(e);return N(t.cart.id),t});return I=n.then(e=>e.cart).finally(()=>{I=null}),I.catch(()=>{}),M(n,t)}let I=null;async function ne(e){let t=s();if(t)return t;let n=await F({},e);return`cartId`in n?n.cartId:n.cart.id}function re(e){if(!(e instanceof Error)||e.name===k||e.name===`ValidationError`)return null;let t=e.cause?.userErrors?.[0];return t?.message?{code:t.code??`SERVICE_UNAVAILABLE`,message:t.message}:{code:`SERVICE_UNAVAILABLE`,message:e.message}}let L=()=>{let e=new Map,t=t=>{let n=e.get(t);if(n)return n;let r=C(t).finally(()=>e.delete(t));return e.set(t,r),r.catch(()=>{}),r};return async(e,n)=>{let r=s(e?.cartId);return r?(j(n?.signal),{cart:await M(t(r),n?.signal)}):{cart:null}}},R=()=>L(),z=()=>import(`./standard-events.js`),B=(e,t)=>{(t??document).dispatchEvent(e)},V=e=>{let t=null;return Object.assign((...n)=>e(t,...n),{isDefault:()=>t===null,configure(e){return t||!e||typeof e!=`object`?!1:(t=e,!0)}})},H=[`cart-drawer`,`cart-items`,`cart-drawer-items`,`cart-notification`],U=()=>{let e=document.querySelector(`cart-icon`),t=document.querySelector(`cart-items-component`);return typeof e?.renderCartBubble==`function`&&typeof t?.updateQuantity==`function`},W=()=>H.some(e=>typeof window.customElements?.get(e)?.prototype?.getSectionsToRender==`function`),G=e=>{try{return document.dispatchEvent(new CustomEvent(`cart:update`,{bubbles:!0,detail:{resource:null,sourceId:`external`,data:{source:`external`,itemCount:e}}})),!0}catch{return!1}},K=async()=>{let e=window,t=typeof e.publish==`function`?new Set([`cart-drawer:cart-drawer`,`cart-drawer-items:CartDrawer`,`cart-items:main-cart-items`]):new Set,n=new Map;for(let e of document.querySelectorAll(H.join(`,`))){let r;try{r=e.getSectionsToRender?.()}catch{continue}let i=e.tagName.toLowerCase();for(let e of r??[]){if(t.has(`${i}:${e.id}`))continue;let r=e.section??e.id;if(!r||n.has(r))continue;let a=e.section?document.getElementById(e.id):document;if(!a)continue;let o=e.selector?a.querySelector(e.selector)??(e.section?a:null):document.getElementById(e.id);o&&n.set(r,{mount:o,extractSelector:e.selector||`.shopify-section`})}}let r=e.routes?.cart_url||`/cart`,i=n.size?`?sections=${[...n.keys()].join(`,`)}`:``,a=await fetch(`${r}.js${i}`,{headers:{Accept:`application/json`}}).then(e=>e.ok?e.json():null).catch(()=>null);for(let[e,{mount:t,extractSelector:r}]of n){let n=a?.sections?.[e];if(!n)continue;let i=new DOMParser().parseFromString(n,`text/html`).querySelector(r);i&&t.replaceChildren(...Array.from(i.childNodes))}try{await e.publish?.(e.PUB_SUB_EVENTS?.cartUpdate??`cart-update`,{source:`external-refresh`,cartData:a??void 0})}catch{}return!0},q=async e=>{U()&&G(e)||W()&&await K()||window.location.reload()},J=({id:e,merchandiseId:t,quantity:n})=>!!(e?.trim()&&n>=0||t&&n>0),Y=e=>{let t=``;if(typeof e.note==`string`||e.discountCodes!==void 0||e.attributes!==void 0||e.lines?.length?e.lines?.some(e=>!J(e))&&(t=`updateCart lines must add, update, or remove at least one item.`):t=`updateCart requires at least one of: lines, note, discountCodes, or attributes.`,t)throw new f(t)},X=async(e,{input:t,signal:n,sfapiLines:r,syncCartCookie:i})=>{let a=ee(e,t),o=te(await O(a.query,a.variables,n),r&&w(r)),s=o.cart??await C(e,n);if(!s)throw new d(`Cart mutation did not return a cart`,{cartId:e,userErrors:o.userErrors,warnings:o.warnings});return i&&N(s.id),{...o,cart:s}},ie=async e=>{let{input:t,signal:n,sfapiLines:r}=e,i=await F(t,n).catch(async e=>{if(e instanceof Error&&e.cause?.userErrors?.length)return{cartId:await ne(n)};throw e});return`cartId`in i?X(i.cartId,e):(i.userErrors&&=T(i.userErrors,r),i)},ae=(e,t)=>{let n={...e};return e.cartId!==void 0&&(n.cartId=t??e.cartId),e.lines&&(n.lines=e.lines.map(e=>({...e,...e.id&&{id:c(e.id,t)},...e.merchandiseId&&{merchandiseId:i(`ProductVariant`,e.merchandiseId)},...e.sellingPlanId&&{sellingPlanId:i(`SellingPlan`,e.sellingPlanId)}}))),n},oe=async(e,t,n)=>{let r=t?.signal,i=(e.lines??[]).map((e,t)=>({...e,index:t})),a={input:{lines:e.lines,note:e.note,discountCodes:e.discountCodes,attributes:e.attributes},signal:r,sfapiLines:i,syncCartCookie:e.cartId===void 0};return n?X(n,a):ie(a)},se=async(e,t,n)=>{let r=await z(),i=n?.event?.detail,a=i?{detail:i}:{},o=n?.event?.context??`standard-action`,s=[],{add:c,update:l,removeLineIds:u,removeViewKeys:d}=w(t.lines??[]),f=[...u,...d],p=(t,n,r)=>{B(n,e?.eventTarget?.(r)),s.push(t)};if(c.length||l.length||f.length){let e=e=>{let{promise:t,...n}=r.CartLinesUpdateEvent.createPromise();p(n,new r.CartLinesUpdateEvent({...e,promise:t,...a}),{type:r.CartLinesUpdateEvent.eventName,action:e.action})};c.length&&e({action:`add`,context:o,lines:c.map(e=>({merchandiseId:e.merchandiseId,quantity:e.quantity}))});for(let[t,n]of[[`update`,l],[`remove`,f]])n.length&&e({action:t,context:o,lines:n.map(e=>({id:e.id,quantity:e.quantity}))})}let m=t.note;if(m!==void 0){let{promise:e,...t}=r.CartNoteUpdateEvent.createPromise();p(t,new r.CartNoteUpdateEvent({context:o,note:m,promise:e,...a}),{type:r.CartNoteUpdateEvent.eventName})}let h=t.attributes;if(h!==void 0){let{promise:e,...t}=r.CartAttributesUpdateEvent.createPromise();p(t,new r.CartAttributesUpdateEvent({context:o,attributes:h,promise:e,...a}),{type:r.CartAttributesUpdateEvent.eventName})}let g=t.discountCodes;if(g!==void 0){let{promise:e,...t}=r.CartDiscountUpdateEvent.createPromise();p(t,new r.CartDiscountUpdateEvent({discountCodes:g.map(e=>({code:e})),promise:e,...a}),{type:r.CartDiscountUpdateEvent.eventName})}return s},ce=({cart:e,userErrors:t,warnings:n,detail:r})=>({cart:e,...t!==void 0&&{userErrors:t},...n!==void 0&&{warnings:n},...r!==void 0&&{detail:r}}),Z=e=>({...e,cart:{...e.cart,lines:e.cart.lines.nodes}}),le=()=>{let e=0,t=!1,n=null,r,i=()=>{!t||n||e>0||(n=setTimeout(()=>{n=null,!(!t||e>0)&&(t=!1,q(r))},0))};return V(async(n,a,o,...c)=>{Y(a);let l=!n,u=s(a.cartId),d=ae(a,u),f=oe.bind(null,d,o,u);l&&(e+=1);let p=await se(n,d,o);try{let e=ce(await(n?.handler?n.handler(f,d,o,...c):f())),i=Z(e);for(let e of p)e.resolve(i);return l&&(t=!0,r=e.cart?.totalQuantity),e}catch(e){for(let t of p)t.reject(e);let t=re(e);if(t){let e=await z(),r=o?.event?.detail;B(new e.CartErrorEvent({error:t.message,code:t.code,...r&&{detail:r}}),n?.eventTarget?.({type:e.CartErrorEvent.eventName}))}throw e}finally{l&&(--e,i())}})},Q=e=>{let t=document.querySelector(e);if(typeof t?.open!=`function`)return!1;try{return t.open(),!0}catch{return!1}},$=async()=>{Q(`cart-drawer-component`)||Q(`cart-drawer`)||(window.location.href=`/cart`)},ue=Object.freeze({getCart:R(),updateCart:le(),openCart:V((e,...t)=>e?.handler?e.handler($,...t):$())});Object.defineProperty(window.Shopify??={},`actions`,{value:ue,writable:!1,configurable:!1,enumerable:!0})})();