{
  "version": 3,
  "sources": ["/cdn/shop/t/2/assets/twc-dom-reconcile.js?twc_revision=20260819_1"],
  "sourcesContent": ["/*\n * TwcListReconcile \u2014 move a rendered list toward a longer or newer one, with\n * the smallest DOM change that gets there.\n *\n * WHY THIS EXISTS. A page that paints one answer and then swaps it for another\n * moves the ground under the member. The server renders the engine's content\n * digest, so its FIRST PAINT is already the right content in the right order;\n * the island's only job is to reach the entries the digest does not carry,\n * and it must not redraw what already matches.\n *\n * The rule this module owns: COMPARE HANDLES IN ORDER, PATCH ONLY WHAT DIFFERS.\n *\n *   identical   nothing is touched at all\n *   a prefix    the missing tail is appended, and no drawn card moves\n *   otherwise   the list is rebuilt, because the two answers really disagree\n *\n * Every card carries `data-twc-handle`, written by the section and by the\n * island alike, so \"the same card\" is a fact rather than a guess. Items are\n * anything with a `.handle`: the normalized events model and the raw Storefront\n * metaobject nodes both have one.\n *\n * Two consumers:\n *   sections/twc-events-index.liquid    (assets/twc-events.js)\n *   sections/twc-giveaways-index.liquid (assets/twc-giveaways.js)\n *\n * One IIFE, one global, idempotent under duplicate script tags \u2014 the shape\n * assets/twc-geo.js and assets/twc-events-source.js already use.\n */\n(function (global) {\n  'use strict';\n\n  if (global.TwcListReconcile) return;\n\n  function elementsOf(list) {\n    if (!list) return [];\n    return Array.prototype.filter.call(list.children, function (node) {\n      return node.nodeType === 1;\n    });\n  }\n\n  /** The handles a list is showing right now, in DOM order. */\n  function handlesOf(list) {\n    return elementsOf(list).map(function (node) {\n      return node.getAttribute('data-twc-handle') || '';\n    });\n  }\n\n  /**\n   * The complete collection, re-ordered so every entry the SERVER already drew\n   * keeps its position and its order.\n   *\n   * The digest and a browser-side sort both mean \"newest first\", but they\n   * cannot be relied on to break a tie the same way, and a member must never\n   * watch a grid reshuffle itself a second after it painted. Whatever the\n   * server did not draw follows, in the order the caller supplied.\n   */\n  function orderedLike(items, handles) {\n    // Null-prototype maps: a handle slug like \"constructor\" is legal and must\n    // not collide with Object.prototype.\n    var byHandle = Object.create(null);\n    items.forEach(function (item) {\n      byHandle[item.handle] = item;\n    });\n    var taken = Object.create(null);\n    var head = [];\n    handles.forEach(function (handle) {\n      var item = byHandle[handle];\n      if (!item || taken[handle]) return;\n      taken[handle] = true;\n      head.push(item);\n    });\n    var tail = items.filter(function (item) {\n      return !taken[item.handle];\n    });\n    return head.concat(tail);\n  }\n\n  /**\n   * Patch `list` toward `items`.\n   *\n   * `build(item, index, appended)` returns the element for one item; `appended`\n   * is true only when drawn cards stay on the page ahead of the new ones, so a\n   * caller can keep its eager/LCP image on the card that already holds it. A\n   * build from an EMPTY list is not an append \u2014 there is no server card holding\n   * the LCP image, so the island's first card may claim it.\n   *\n   * Returns true when the DOM was touched.\n   */\n  function sync(list, items, build) {\n    if (!list) return false;\n    var current = handlesOf(list);\n    var prefix =\n      current.length <= items.length &&\n      current.every(function (handle, index) {\n        return handle === items[index].handle;\n      });\n    if (prefix && current.length === items.length) return false;\n\n    var from = prefix ? current.length : 0;\n    var appended = prefix && current.length > 0;\n    var fragment = global.document.createDocumentFragment();\n    for (var index = from; index < items.length; index += 1) {\n      fragment.appendChild(build(items[index], index, appended));\n    }\n    if (!prefix) list.textContent = '';\n    list.appendChild(fragment);\n    return true;\n  }\n\n  global.TwcListReconcile = {\n    handlesOf: handlesOf,\n    orderedLike: orderedLike,\n    sync: sync,\n  };\n})(window);\n"],
  "mappings": "CA4BC,SAAU,OAAQ,CACjB,aAEA,GAAI,OAAO,iBAAkB,OAE7B,SAAS,WAAW,KAAM,CACxB,OAAK,KACE,MAAM,UAAU,OAAO,KAAK,KAAK,SAAU,SAAU,KAAM,CAChE,OAAO,KAAK,WAAa,CAC3B,CAAC,EAHiB,CAAC,CAIrB,CAGA,SAAS,UAAU,KAAM,CACvB,OAAO,WAAW,IAAI,EAAE,IAAI,SAAU,KAAM,CAC1C,OAAO,KAAK,aAAa,iBAAiB,GAAK,EACjD,CAAC,CACH,CAWA,SAAS,YAAY,MAAO,QAAS,CAGnC,IAAI,SA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