{"version":3,"sources":["jsdelivr-header.js","/npm/cart-localstorage@1.1.5/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OCNS,KAAM,KAAM,MAAO,WAAc,uBAE1C,MAAM,IAAO,GAAO,OAAO,MAAM,GAAY,EAAQ,KAAO,IAEtD,OAAU,KAAS,IAAI,GAEvB,IAAM,CAAC,EAAS,IAAa,QAAQ,GAAW,OAAO,EAAQ,IAAM,OAAO,EAAQ,GAAI,WAAY,IAAI,EAAQ,IAAI,UAAY,GAAY,IAAM,KAAK,OAAO,OAAO,IAAK,EAAS,SAAU,GAAY,KAAQ,KAEjN,OAAU,GAAO,KAAK,OAAO,QAAQ,GAAY,EAAQ,KAAO,KAEhE,SAAW,CAAC,EAAI,IAAS,OAAO,IAAO,IAAI,GAAI,SAAW,EAAO,EAAI,OAAO,EAAI,WAAY,IAAI,GAAI,SAAW,GAAQ,OAAO,GAE9H,OAAS,CAAC,EAAI,EAAO,IAAU,KAAK,OAAO,KAAK,GAAY,EAAQ,KAAO,EAAK,IAAM,EAAS,CAAC,GAAQ,GAAW,KAEnH,MAAS,GAAO,OAAO,QAAO,CAAC,EAAK,IAAY,WAAW,GAAM,EAAG,EAAK,GAAY,GAAO,SAAS,IAAW,GAEhH,QAAU,IAAM,QAEhB,SAAY,GAAO,WAAW,GAAM,OAAO,GAAM,QAAQ,WAAW,GAGpE,QAAW,GAAY,EAAQ,IAAM,EAAQ,MAE7C,SAAY,GAAY,WAAW,GAAY,EAAQ,MAAQ,EAAQ,SAAY,EAEnF,WAAc,GAAa,GAAW,EAAQ,OAAS,EAAQ,SAE/D,WAAc,GAAO,GAAoB,mBAAP,SAE/B,KAAM,IAAK,IAAK,OAAQ,OAAQ,SAAU,MAAO,QAAS,OAAQ,SAAU","file":"/npm/cart-localstorage@1.1.5/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/cart-localstorage@1.1.5/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import { list, save, clear, listen } from './utils/localstorage'\n\nconst get = (id) => list().find((product) => product.id === id)\n\nconst exists = (id) => !!get(id)\n\nconst add = (product, quantity) => isValid(product) ? exists(product.id) ? update(product.id, 'quantity', get(product.id).quantity + (quantity || 1)) : save(list().concat({ ...product, quantity: quantity || 1 })) : null;\n\nconst remove = (id) => save(list().filter((product) => product.id !== id))\n\nconst quantity = (id, diff) => exists(id) && get(id).quantity + diff > 0 ? update(id, 'quantity', get(id).quantity + diff) : remove(id);\n\nconst update = (id, field, value) => save(list().map((product) => product.id === id ? ({ ...product, [field]: value }) : product))\n\nconst total = (cb) => list().reduce((sum, product) => isCallback(cb) ? cb(sum, product) : (sum += subtotal(product)), 0);\n\nconst destroy = () => clear()\n\nconst onChange = (cb) => isCallback(cb) ? listen(cb) : console.log(typeof cb)\n\n\nconst isValid = (product) => product.id && product.price\n\nconst subtotal = (product) => isCalcable(product) ? (product.price * product.quantity) : 0\n\nconst isCalcable = (product) => (product && product.price && product.quantity)\n\nconst isCallback = (cb) => cb && typeof cb === \"function\"\n\nexport { list, get, add, remove, update, quantity, total, destroy, exists, subtotal, onChange };\n"]}