{
  "version": 3,
  "sources": ["/cdn/shop/t/12/assets/standard-actions-override.js?cmv=2026.08.25.2"],
  "sourcesContent": ["/**\n * Standard Actions configuration for Dawn.\n *\n * Storefront Renderer injects the Shopify Standard Actions bundle\n * (`window.Shopify.actions.{updateCart,openCart,getCart,\u2026}`). This file\n * overrides the bundle's built-in Dawn refresh path with an explicit,\n * in-theme version so forks that change Dawn's cart contract keep\n * working. Remove this file and the built-in defaults take over.\n *\n *   - openCart   \u2014 opens <cart-drawer>; falls back to /cart.\n *   - updateCart \u2014 after the Storefront API mutation, refreshes the\n *     affected cart sections and publishes `cart-update` so Dawn's\n *     pubsub subscribers react.\n *   - other actions (getCart, etc.) keep the default implementation.\n */\n\n// Cart custom elements that advertise sections via getSectionsToRender().\n// If Dawn adds a new cart custom element, add its tag here.\nconst DAWN_CART_TAGS = ['cart-drawer', 'cart-items', 'cart-drawer-items', 'cart-notification'];\n\n// Sections that Dawn's own pubsub subscribers refresh (cart.js's\n// CartItems#onCartUpdate fetches and replaces these directly when\n// cart-update fires; cart-drawer.js's renderContents handles the\n// drawer body). We skip them here to avoid double-rendering.\n// Format is '<element-tag>:<getSectionsToRender entry id>'.\n// If you change which sections those subscribers refresh, update this set.\nconst DAWN_PUBSUB_REFRESHED_SECTIONS = new Set([\n  'cart-drawer:cart-drawer',\n  'cart-drawer-items:CartDrawer',\n  'cart-items:main-cart-items',\n]);\n\n// Walk every mounted Dawn cart custom element, collect the sections it\n// wants rendered, and dedupe. Returns a Map keyed by section id, each\n// entry pointing at the DOM mount and the selector used to extract the\n// fresh fragment.\nfunction collectCartSections() {\n  const sections = new Map();\n\n  for (const el of document.querySelectorAll(DAWN_CART_TAGS.join(','))) {\n    let entries;\n    try {\n      entries = el.getSectionsToRender?.();\n    } catch {\n      continue;\n    }\n\n    const tag = el.tagName.toLowerCase();\n    for (const entry of entries ?? []) {\n      if (DAWN_PUBSUB_REFRESHED_SECTIONS.has(`${tag}:${entry.id}`)) continue;\n\n      const sectionId = entry.section ?? entry.id;\n      if (!sectionId || sections.has(sectionId)) continue;\n\n      // Two patterns coexist in getSectionsToRender():\n      //   - cart-items style: entry.section is the parent Liquid section\n      //     id, entry.selector is a child node inside it.\n      //   - cart-drawer / cart-notification style: entry.id IS the mount;\n      //     there is no parent wrapper.\n      const root = entry.section ? document.getElementById(entry.id) : document;\n      if (!root) continue;\n\n      const mount = entry.selector\n        ? (root.querySelector(entry.selector) ?? (entry.section ? root : null))\n        : document.getElementById(entry.id);\n      if (!mount) continue;\n\n      sections.set(sectionId, {\n        mount,\n        extractSelector: entry.selector || '.shopify-section',\n      });\n    }\n  }\n\n  return sections;\n}\n\n// After a Storefront API mutation, refresh every Dawn cart section\n// that isn't already refreshed by Dawn's own pubsub subscribers, then\n// publish 'cart-update' so the subscribers run.\n//\n// We always fetch /cart.js (with sections= when we have any) so that\n// `cartData` is defined for subscribers. quick-add-bulk.js reads\n// `event.cartData.items` unconditionally \u2014 publishing without cartData\n// makes it throw.\nasync function refreshDawnCartUI() {\n  const sections = collectCartSections();\n  const sectionsQuery = sections.size\n    ? `?sections=${[...sections.keys()].join(',')}`\n    : '';\n  // `routes` is a Dawn global, but don't assume it's defined.\n  const cartUrl = (typeof routes !== 'undefined' && routes?.cart_url) || '/cart';\n  const url = `${cartUrl}.js${sectionsQuery}`;\n  const cartData = await fetch(url, { headers: { Accept: 'application/json' } })\n    .then((r) => (r.ok ? r.json() : null))\n    .catch(() => null);\n\n  if (cartData?.sections) {\n    for (const [id, { mount, extractSelector }] of sections) {\n      const html = cartData.sections[id];\n      if (!html) continue;\n      const source = new DOMParser()\n        .parseFromString(html, 'text/html')\n        .querySelector(extractSelector);\n      if (source) mount.replaceChildren(...source.childNodes);\n    }\n  }\n\n  // Hand off to Dawn's existing subscribers. cartData is the full\n  // Cart Ajax payload (items, item_count, token, \u2026) plus sections;\n  // quick-add-bulk.js and price-per-item.js read it directly.\n  publish(PUB_SUB_EVENTS.cartUpdate, {\n    source: 'external-refresh',\n    cartData: cartData ?? undefined,\n  });\n}\n\nfunction initStandardActions() {\n  const actions = window.Shopify?.actions;\n  if (!actions) return;\n\n  actions.openCart.configure({\n    async handler(defaultHandler) {\n      const drawer = document.querySelector('cart-drawer');\n      if (drawer && typeof drawer.open === 'function') {\n        drawer.open();\n        return;\n      }\n      return defaultHandler();\n    },\n  });\n\n  actions.updateCart.configure({\n    // Dawn doesn't currently listen for shopify:cart:* events, but the\n    // bundle requires an eventTarget. document is the conventional root.\n    eventTarget: () => document,\n    async handler(defaultHandler) {\n      const result = await defaultHandler();\n      try {\n        await refreshDawnCartUI();\n      } catch (error) {\n        console.error('[Dawn] Standard Actions cart refresh failed; reloading.', error);\n        window.location.reload();\n      }\n      return result;\n    },\n  });\n}\n\n// Run immediately if the standard-actions bundle has already attached\n// `Shopify.actions`; otherwise wait for DOMContentLoaded, which fires after\n// all module scripts have executed regardless of document order.\nif (window.Shopify?.actions) {\n  initStandardActions();\n} else {\n  document.addEventListener('DOMContentLoaded', initStandardActions, { once: true });\n}\n"],
  "mappings": "AAkBA,MAAM,eAAiB,CAAC,cAAe,aAAc,oBAAqB,mBAAmB,EAQvF,+BAAiC,IAAI,IAAI,CAC7C,0BACA,+BACA,4BACF,CAAC,EAMD,SAAS,qBAAsB,CAC7B,MAAM,SAAW,IAAI,IAErB,UAAW,MAAM,SAAS,iBAAiB,eAAe,KAAK,GAAG,CAAC,EAAG,CACpE,IAAI,QACJ,GAAI,CACF,QAAU,GAAG,sBAAsB,CACrC,MAAQ,CACN,QACF,CAEA,MAAM,IAAM,GAAG,QAAQ,YAAY,EACnC,UAAW,SAAS,SAAW,CAAC,EAAG,CACjC,GAAI,+BAA+B,IAAI,GAAG,GAAG,IAAI,MAAM,EAAE,EAAE,EAAG,SAE9D,MAAM,UAAY,MAAM,SAAW,MAAM,GACzC,GAAI,CAAC,WAAa,SAAS,IAAI,SAAS,EAAG,SAO3C,MAAM,KAAO,MAAM,QAAU,SAAS,eAAe,MAAM,EAAE,EAAI,SACjE,GAA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