{
  "version": 3,
  "sources": ["/cdn/shop/t/48/assets/sat-random-sort-patch.js?x=15125"],
  "sourcesContent": ["/*\n * Merchant: \"for the full manifest don't put the newest items first\" \u2014 the\n * default sort (\"Newest Intake\") meant every big Collective import (today\n * it was Books, then Knives, then whatever comes next) briefly buries the\n * whole rest of the catalog at the bottom the moment it lands. Replaces\n * that default with a genuinely random order instead, at the merchant's\n * choice over two other options (oldest-era-first, price-low-to-high) \u2014\n * neither one is safe either: \"Oldest Era\" would put every one of today's\n * new-department items (no custom.era set) at the very front instead,\n * since blank sorts before any real era string.\n *\n * Loads last (after assets/sat-modern-department-patch.js), wrapping\n * whatever SATComponent.prototype.visibleProducts currently resolves to \u2014\n * so this applies to every department's listing, built-in or added by that\n * patch, not just one of them. storeItems (snippets/sat-manifest.liquid's\n * \"Full Manifest\" grid, The Southern Air Import's own grid, and the home\n * page teaser) all read from this same method (see sat-app.js renderVals,\n * `storeItems: ... this.visibleProducts() ...`), so one wrap here covers\n * all three.\n *\n * Renamed the dropdown option itself too (renderVals's sortOptions) \u2014\n * leaving it reading \"Newest Intake\" while it actually shuffles would be\n * lying to whoever opens that dropdown expecting literal newest-first.\n * The three other real sort modes (Price Low-High, Price High-Low, Oldest\n * Era) are untouched and still do exactly what they say.\n *\n * The shuffle order is stable per page load, not re-randomized on every\n * render \u2014 each product's position is decided once (a random key cached\n * the first time that id is seen) and reused for every subsequent render,\n * so the grid doesn't visibly jitter while someone is just typing in the\n * search box or opening the cart. A fresh page load gets a fresh order.\n */\n(function () {\n  'use strict';\n  if (!window.SATComponent) { return; }\n\n  var RANDOM_LABEL = 'Newest Intake'; // kept as the underlying state value on purpose \u2014 nothing else in the app keys off this exact string besides the 3 explicit sort branches this patch and the base build already skip for it; only the dropdown's displayed text changes, below.\n  var DISPLAY_LABEL = 'Random';\n  var EXPLICIT_SORTS = ['Price, Low to High', 'Price, High to Low', 'Oldest Era'];\n\n  var shuffleKeys = {};\n  function shuffleKeyFor(id) {\n    if (!(id in shuffleKeys)) { shuffleKeys[id] = Math.random(); }\n    return shuffleKeys[id];\n  }\n\n  var proto = window.SATComponent.prototype;\n\n  var origVisibleProducts = proto.visibleProducts;\n  proto.visibleProducts = function () {\n    var list = origVisibleProducts.call(this);\n    if (EXPLICIT_SORTS.indexOf(this.state.sortBy) !== -1) { return list; }\n    return list.slice().sort(function (a, b) { return shuffleKeyFor(a.id) - shuffleKeyFor(b.id); });\n  };\n\n  var origRenderVals = proto.renderVals;\n  proto.renderVals = function () {\n    var out = origRenderVals.call(this);\n    if (Array.isArray(out.sortOptions)) {\n      out.sortOptions = out.sortOptions.map(function (label) {\n        return label === RANDOM_LABEL ? DISPLAY_LABEL : label;\n      });\n    }\n    // The <select>'s bound value (snippets/sat-import.liquid) has to match\n    // one of the option values above exactly, or the browser just falls\n    // back to whichever <option> happens to be first in the DOM \u2014 right by\n    // coincidence today (Random still sits first), but not something to\n    // depend on. Normalize it explicitly instead.\n    if (out.sortBy === RANDOM_LABEL) { out.sortBy = DISPLAY_LABEL; }\n    return out;\n  };\n})();\n"],
  "mappings": "CAgCC,UAAY,CACX,aACA,GAAI,CAAC,OAAO,aAAgB,OAE5B,IAAI,aAAe,gBACf,cAAgB,SAChB,eAAiB,CAAC,qBAAsB,qBAAsB,YAAY,EAE1E,YAAc,CAAC,EACnB,SAAS,cAAc,GAAI,CACzB,OAAM,MAAM,cAAgB,YAAY,EAAE,EAAI,KAAK,OAAO,GACnD,YAAY,EAAE,CACvB,CAEA,IAAI,MAAQ,OAAO,aAAa,UAE5B,oBAAsB,MAAM,gBAChC,MAAM,gBAAkB,UAAY,CAClC,IAAI,KAAO,oBAAoB,KAAK,IAAI,EACxC,OAAI,eAAe,QAAQ,KAAK,MAAM,MAAM,IAAM,GAAa,KACxD,KAAK,MAAM,EAAE,KAAK,SAAU,EAAG,EAAG,CAAE,OAAO,cAAc,EAAE,EAAE,EAAI,cAAc,EAAE,EAAE,CAAG,CAAC,CAChG,EAEA,IAAI,eAAiB,MAAM,WAC3B,MAAM,WAAa,UAAY,CAC7B,IAAI,IAAM,eAAe,KAAK,IAAI,EAClC,OAAI,MAAM,QAAQ,IAAI,WAAW,IAC/B,IAAI,YAAc,IAAI,YAAY,IAAI,SAAU,MAAO,CACrD,OAAO,QAAU,aAAe,cAAgB,KAClD,CAAC,GAOC,IAAI,SAAW,eAAgB,IAAI,OAAS,eACzC,GACT,CACF,GAAG",
  "names": []
}
