{"version":3,"file":"rebuy-translation.js","sources":["../../dev/js/rebuy-translation.js"],"sourcesContent":["document.addEventListener('DOMContentLoaded', (event) => {\n const translations = {\n fr: {\n smart_cart: {\n bmsm_discount_message:\n \"Achetez , économisez \",\n cart_title: 'Votre panier de goût',\n checking_out_label: 'Traitement de la commande...',\n checkout_label: 'Passer à la caisse',\n continue_shopping_label: 'Continuer vos achats',\n discount_button_label: 'Carte cadeau ou code promo',\n discount_code_label: 'Carte cadeau ou code promo',\n discount_invalid_message: 'Carte cadeau ou code promo invalide',\n discount_label: 'Carte cadeau ou code promo',\n empty_cart:\n \"

Votre panier est vide!

Commencer vos achats\",\n free_shipping_reached: '🎉 Félicitations! Vous avez LIVRAISON GRATUITE!',\n free_shipping_remaining:\n \"Il ne reste que pour la livraison gratuite\",\n free_product_tier_remaining:\n \"Dépensez obtenez \",\n notes_label: 'Ajouter une note (facultatif)',\n notes_placeholder: 'Écrivez votre note ici',\n notes_remaining_characters: 'Caractères restants',\n subtotal_plural_text: 'Total',\n subtotal_singular_text: 'Total',\n view_cart_label: 'Voir le panier',\n view_cart_working_label: 'Ouverture du panier...',\n },\n widget: {\n add_to_cart: 'Ajouter',\n added_to_cart: 'Ajouté',\n adding_to_cart: 'Ajout au panier',\n cart_switch_to_onetime: \"Passer à l'achat unique\",\n cart_switch_to_subscription: 'Abonnez-vous et économisez',\n cart_switch_to_subscription_footer: 'Abonnez-vous et économisez',\n continue: 'Continuer',\n decline: 'Refuser',\n delivery_frequency_label: 'Fréquence de livraison',\n learn_more_label: 'En savoir plus',\n remove_body: 'Êtes-vous sûr de vouloir supprimer cet article?',\n remove_confirm: 'Oui, supprimer',\n remove_deny: 'Non, garder',\n remove_from_cart: 'Supprimer du panier',\n remove_title: 'Supprimer cet article',\n removed_from_cart: 'Supprimé',\n removing_from_cart: 'Suppression en cours...',\n sold_out_label: 'Épuisé',\n thank_you_button: 'Merci',\n thank_you_description: 'Merci pour votre achat!',\n thank_you_title: 'Merci!',\n title: 'Découvrez celui-ci...',\n upgrade_to_subscription: \"Passer à l'abonnement\",\n variant_option: 'Taille',\n variant_options: 'Options',\n total_price_label: 'Votre prix :',\n reviews: 'Avis',\n pay_full_price: 'Payer le plein prix',\n subscribe_and_save_20: 'Abonnez-vous pour économiser 20%',\n one_time_only: 'Une seule fois',\n stock_guaranteed_6_weeks: 'Stock garanti, livraison tous les 6 semaines',\n stock_guaranteed_8_weeks: 'Stock garanti, livraison tous les 8 semaines',\n stock_guaranteed_10_weeks: 'Stock garanti, livraison tous les 10 semaines',\n },\n 73936: {\n add_to_cart: 'Ajouter',\n super_title: '',\n title: 'Découvrez plus à aimer',\n description: '',\n },\n 99302: {\n add_to_cart: 'Ajouter au panier',\n super_title: '',\n title: 'Bundles Recommandés par des Experts',\n description: '',\n total_price_label: 'Prix du Bundle',\n },\n },\n at: {\n smart_cart: {\n bmsm_discount_message:\n \"Kaufe , spare \",\n cart_title: 'Ihr geschmackvoller Warenkorb',\n checking_out_label: 'Bestellung wird bearbeitet...',\n checkout_label: 'Zur Kasse gehen',\n continue_shopping_label: 'Weiter einkaufen',\n discount_button_label: 'Geschenkkarte oder Rabattcode',\n discount_code_label: 'Geschenkkarte oder Rabattcode',\n discount_invalid_message: 'Ungültige Geschenkkarte oder Rabattcode',\n discount_label: 'Geschenkkarte oder Rabattcode',\n empty_cart:\n \"

Ihr Warenkorb ist leer!

Einkauf beginnen\",\n free_shipping_reached: '🎉 Herzlichen Glückwunsch! Sie haben VERSANDKOSTENFREI!',\n free_shipping_remaining:\n \"Nur noch bis versandkostenfrei\",\n free_product_tier_remaining:\n \"Geben Sie aus und erhalten Sie \",\n notes_label: 'Eine Notiz hinzufügen (optional)',\n notes_placeholder: 'Schreiben Sie Ihre Notiz hier',\n notes_remaining_characters: 'Verbleibende Zeichen',\n subtotal_plural_text: 'Gesamt',\n subtotal_singular_text: 'Gesamt',\n view_cart_label: 'Warenkorb ansehen',\n view_cart_working_label: 'Warenkorb wird geöffnet...',\n },\n widget: {\n add_to_cart: 'Hinzufügen',\n added_to_cart: 'Hinzugefügt',\n adding_to_cart: 'Wird dem Warenkorb hinzugefügt',\n cart_switch_to_onetime: 'Einmalig kaufen',\n cart_switch_to_subscription: 'Abonnieren und sparen',\n cart_switch_to_subscription_footer: 'Abonnieren und sparen',\n continue: 'Weiter',\n decline: 'Ablehnen',\n delivery_frequency_label: 'Lieferhäufigkeit',\n learn_more_label: 'Mehr erfahren',\n remove_body: 'Möchten Sie diesen Artikel wirklich entfernen?',\n remove_confirm: 'Ja, entfernen',\n remove_deny: 'Nein, behalten',\n remove_from_cart: 'Aus dem Warenkorb entfernen',\n remove_title: 'Diesen Artikel entfernen',\n removed_from_cart: 'Entfernt',\n removing_from_cart: 'Wird entfernt...',\n sold_out_label: 'Ausverkauft',\n thank_you_button: 'Danke',\n thank_you_description: 'Vielen Dank für Ihren Einkauf!',\n thank_you_title: 'Danke!',\n title: 'Schauen Sie sich das an...',\n upgrade_to_subscription: 'Zum Abonnement wechseln',\n variant_option: 'Größe',\n variant_options: 'Optionen',\n total_price_label: 'Ihr Preis:',\n reviews: 'Bewertungen',\n pay_full_price: 'Vollpreis bezahlen',\n subscribe_and_save_20: 'Abonnieren und 20% sparen',\n one_time_only: 'Nur einmal',\n stock_guaranteed_6_weeks: 'Vorrätig, Lieferung alle 6 Wochen',\n stock_guaranteed_8_weeks: 'Vorrätig, Lieferung alle 8 Wochen',\n stock_guaranteed_10_weeks: 'Vorrätig, Lieferung alle 10 Wochen',\n },\n 73936: {\n add_to_cart: 'Hinzufügen',\n super_title: '',\n title: 'Entdecken Sie mehr zum Verlieben',\n description: '',\n },\n 99302: {\n add_to_cart: 'In den Warenkorb',\n super_title: '',\n title: 'Expertenempfohlene Bündel',\n description: '',\n total_price_label: 'Bündelpreis',\n },\n },\n de: {\n smart_cart: {\n bmsm_discount_message:\n \"Kaufe , spare \",\n cart_title: 'Ihr geschmackvoller Warenkorb',\n checking_out_label: 'Bestellung wird bearbeitet...',\n checkout_label: 'Zur Kasse gehen',\n continue_shopping_label: 'Weiter einkaufen',\n discount_button_label: 'Geschenkkarte oder Rabattcode',\n discount_code_label: 'Geschenkkarte oder Rabattcode',\n discount_invalid_message: 'Ungültige Geschenkkarte oder Rabattcode',\n discount_label: 'Geschenkkarte oder Rabattcode',\n empty_cart:\n \"

Ihr Warenkorb ist leer!

Einkauf beginnen\",\n free_shipping_reached: '🎉 Herzlichen Glückwunsch! Sie haben VERSANDKOSTENFREI!',\n free_shipping_remaining:\n \"Nur noch bis versandkostenfrei\",\n free_product_tier_remaining:\n \"Geben Sie aus und erhalten Sie \",\n notes_label: 'Eine Notiz hinzufügen (optional)',\n notes_placeholder: 'Schreiben Sie Ihre Notiz hier',\n notes_remaining_characters: 'Verbleibende Zeichen',\n subtotal_plural_text: 'Gesamt',\n subtotal_singular_text: 'Gesamt',\n view_cart_label: 'Warenkorb ansehen',\n view_cart_working_label: 'Warenkorb wird geöffnet...',\n },\n widget: {\n add_to_cart: 'Hinzufügen',\n added_to_cart: 'Hinzugefügt',\n adding_to_cart: 'Wird dem Warenkorb hinzugefügt',\n cart_switch_to_onetime: 'Einmalig kaufen',\n cart_switch_to_subscription: 'Abonnieren und sparen',\n cart_switch_to_subscription_footer: 'Abonnieren und sparen',\n continue: 'Weiter',\n decline: 'Ablehnen',\n delivery_frequency_label: 'Lieferhäufigkeit',\n learn_more_label: 'Mehr erfahren',\n remove_body: 'Möchten Sie diesen Artikel wirklich entfernen?',\n remove_confirm: 'Ja, entfernen',\n remove_deny: 'Nein, behalten',\n remove_from_cart: 'Aus dem Warenkorb entfernen',\n remove_title: 'Diesen Artikel entfernen',\n removed_from_cart: 'Entfernt',\n removing_from_cart: 'Wird entfernt...',\n sold_out_label: 'Ausverkauft',\n thank_you_button: 'Danke',\n thank_you_description: 'Vielen Dank für Ihren Einkauf!',\n thank_you_title: 'Danke!',\n title: 'Schauen Sie sich das an...',\n upgrade_to_subscription: 'Zum Abonnement wechseln',\n variant_option: 'Größe',\n variant_options: 'Optionen',\n total_price_label: 'Ihr Preis:',\n reviews: 'Bewertungen',\n pay_full_price: 'Vollpreis bezahlen',\n subscribe_and_save_20: 'Abonnieren und 20% sparen',\n one_time_only: 'Nur einmal',\n stock_guaranteed_6_weeks: 'Vorrätig, Lieferung alle 6 Wochen',\n stock_guaranteed_8_weeks: 'Vorrätig, Lieferung alle 8 Wochen',\n stock_guaranteed_10_weeks: 'Vorrätig, Lieferung alle 10 Wochen',\n },\n 73936: {\n add_to_cart: 'Hinzufügen',\n super_title: '',\n title: 'Entdecken Sie mehr zum Verlieben',\n description: '',\n },\n 99302: {\n add_to_cart: 'In den Warenkorb',\n super_title: '',\n title: 'Expertenempfohlene Bündel',\n description: '',\n total_price_label: 'Bündelpreis',\n },\n },\n en: {\n smart_cart: {\n bmsm_discount_message:\n \"Buy , save \",\n cart_title: 'Your tasteful basket',\n checking_out_label: 'Processing order...',\n checkout_label: 'Go to Checkout',\n continue_shopping_label: 'Continue shopping',\n discount_button_label: 'Gift card or discount code',\n discount_code_label: 'Gift card or discount code',\n discount_invalid_message: 'Invalid gift card or discount code',\n discount_label: 'Gift card or discount code',\n empty_cart:\n '

Your cart is empty!

Start shopping',\n free_shipping_reached: '🎉 Congratulations! You have FREE SHIPPING!',\n free_shipping_remaining:\n \"Only left for free shipping\",\n free_product_tier_remaining:\n \"Spend get \",\n notes_label: 'Add a note (optional)',\n notes_placeholder: 'Write your note here',\n notes_remaining_characters: 'Remaining characters',\n subtotal_plural_text: 'Total',\n subtotal_singular_text: 'Total',\n view_cart_label: 'View cart',\n view_cart_working_label: 'Opening cart...',\n },\n widget: {\n add_to_cart: 'Add',\n added_to_cart: 'Added',\n adding_to_cart: 'Adding to cart',\n cart_switch_to_onetime: 'Switch to one-time',\n cart_switch_to_subscription: 'Subscribe and save',\n cart_switch_to_subscription_footer: 'Subscribe and save',\n continue: 'Continue',\n decline: 'Decline',\n delivery_frequency_label: 'Delivery frequency',\n learn_more_label: 'Learn more',\n remove_body: 'Are you sure you want to remove this item?',\n remove_confirm: 'Yes, remove',\n remove_deny: 'No, keep',\n remove_from_cart: 'Remove from cart',\n remove_title: 'Remove this item',\n removed_from_cart: 'Removed',\n removing_from_cart: 'Removing...',\n sold_out_label: 'Sold out',\n thank_you_button: 'Thank you',\n thank_you_description: 'Thank you for your purchase!',\n thank_you_title: 'Thank you!',\n title: 'Check this one out...',\n upgrade_to_subscription: 'Upgrade to subscription',\n variant_option: 'Size',\n variant_options: 'Options',\n total_price_label: 'Your price:',\n reviews: 'Reviews',\n pay_full_price: 'Pay full price',\n subscribe_and_save_20: 'Subscribe to save 20%',\n one_time_only: 'One-time only',\n stock_guaranteed_6_weeks: 'Stock guaranteed, delivery every 6 weeks',\n stock_guaranteed_8_weeks: 'Stock guaranteed, delivery every 8 weeks',\n stock_guaranteed_10_weeks: 'Stock guaranteed, delivery every 10 weeks',\n },\n 73936: {\n add_to_cart: 'Add',\n super_title: '',\n title: 'Discover more to love',\n description: '',\n },\n 99302: {\n add_to_cart: 'Add to cart',\n super_title: '',\n title: 'Expert-Recommended Bundles',\n description: '',\n total_price_label: 'Bundle Price',\n },\n },\n };\n const getLocaleFromDomain = () => {\n const { host, pathname } = window.location;\n const subdomain = host.split('.');\n const pathSegments = pathname.split('/').filter(Boolean);\n\n if (subdomain.includes('be')) {\n if (pathSegments.includes('fr')) {\n return 'fr';\n } else {\n return null;\n }\n } else if (subdomain.includes('fr')) {\n if (pathSegments.includes('fr')) {\n return 'fr';\n } else {\n return null;\n }\n } else {\n return subdomain[subdomain.length - 1];\n }\n };\n\n updateSmartCartLanguage = () => {\n const locale = getLocaleFromDomain();\n const translation = translations[locale]?.smart_cart;\n\n if (locale && translation) {\n Object.assign(Rebuy.SmartCart.settings.language, translation);\n if (translations[locale]?.announcement_bar) {\n Object.assign(\n Rebuy.SmartCart.settings.announcement_bar,\n translations[locale].announcement_bar\n );\n }\n }\n };\n\n updateWidgetLanguage = (widget) => {\n const locale = getLocaleFromDomain();\n const widgetTranslation = translations[locale]?.[widget.id];\n const globalTranslation = translations[locale]?.widget;\n\n if (locale && widgetTranslation) {\n Object.assign(widget.data.settings.language, widgetTranslation);\n widget.compileConfig();\n } else if (locale && globalTranslation) {\n Object.assign(widget.data.settings.language, globalTranslation);\n widget.compileConfig();\n }\n };\n\n const updateElementText = (selector, text, replaceText) => {\n const elements = document.querySelectorAll(selector);\n\n if (elements && text) {\n elements.forEach((el) => {\n if (replaceText) {\n let innerText = el.innerText || el.textContent;\n el.innerHTML = innerText.replace(replaceText, text);\n } else {\n el.innerHTML = text;\n }\n });\n }\n };\n\n const updateElementAttribute = (selector, attr, value) => {\n const elements = document.querySelectorAll(selector);\n\n if (elements && attr && value) {\n elements.forEach((el) => {\n el.setAttribute(attr, value);\n });\n }\n };\n\n const updateDOMText = () => {\n const locale = getLocaleFromDomain();\n updateElementText(\n '.rebuy-cart__flyout-item-subscription button span',\n translations[locale]?.widget?.cart_switch_to_subscription,\n 'Upgrade to Subscription & Save'\n );\n updateElementText(\n '.rebuy-bundle__actions-price-label',\n translations[locale]?.widget?.total_price_label\n );\n updateElementText('.rebuy-review-count-label', translations[locale]?.widget?.reviews);\n\n updateElementAttribute(\n '.rebuy-cart__flyout-item-subscription select optgroup[label=\"Pay Full Price\"]',\n 'label',\n translations[locale]?.widget?.pay_full_price\n );\n updateElementAttribute(\n '.rebuy-cart__flyout-item-subscription select optgroup[label^=\"Subscribe and Save 20%\"]',\n 'label',\n translations[locale]?.widget?.subscribe_and_save_20\n );\n\n updateElementText(\n '.rebuy-cart__flyout-item-subscription select option[value=\"onetime\"]',\n translations[locale]?.widget?.one_time_only\n );\n updateElementText(\n '.rebuy-cart__flyout-item-subscription select option[value=\"Stock guaranteed, ships every 6 weeks\"]',\n translations[locale]?.widget?.stock_guaranteed_6_weeks\n );\n updateElementText(\n '.rebuy-cart__flyout-item-subscription select option[value=\"Stock guaranteed, ships every 8 weeks\"]',\n translations[locale]?.widget?.stock_guaranteed_8_weeks\n );\n updateElementText(\n '.rebuy-cart__flyout-item-subscription select option[value=\"Stock guaranteed, ships every 10 weeks\"]',\n translations[locale]?.widget?.stock_guaranteed_10_weeks\n );\n };\n\n const updateRemaining = () => {\n const locale = getLocaleFromDomain();\n if (translations[locale]) {\n const remainingAmount = document.querySelector(\n '.rebuy-cart__flyout-subtotal-label .item-count'\n );\n\n if (remainingAmount) {\n remainingAmount.innerHTML = Rebuy.Cart.cart.item_count;\n }\n\n const tiers = Rebuy.SmartCart?.settings?.buy_more_save_more?.tiers;\n if (tiers) {\n tiers.forEach((tier, index) => {\n if (\n document.querySelectorAll('.rebuy-cart__flyout-item-buy-more-save-more-button').length >\n 0\n ) {\n document.querySelectorAll(\n '.rebuy-cart__flyout-item-buy-more-save-more-button .bmsm-discount'\n )[index].innerHTML = tier.discount + '%';\n document.querySelectorAll(\n '.rebuy-cart__flyout-item-buy-more-save-more-button .bmsm-quantity'\n )[index].innerHTML = tier.quantity;\n }\n });\n }\n\n if (!Rebuy.SmartCart?.progressBar) {\n return;\n }\n const bar = Rebuy.SmartCart.getCurrentTier(Rebuy.SmartCart?.progressBar);\n const barEl = document.getElementById('rebuy-cart__progress-bar-meter-label');\n const helperShipping = barEl.querySelector('.helper-shipping');\n const helperProduct = barEl.querySelector('.helper-product');\n if (bar && barEl) {\n if (bar.type === 'shipping') {\n if (!helperShipping) {\n barEl.innerHTML = translations[locale]?.smart_cart?.free_shipping_remaining;\n }\n barEl.querySelector('.helper-shipping').innerHTML = Rebuy.SmartCart.formatMoney(\n -Math.round(-bar.minimum * 100) - Rebuy.SmartCart.shippingExcludedSubtotal()\n );\n } else {\n if (!helperProduct) {\n barEl.innerHTML = translations[locale]?.smart_cart?.free_product_tier_remaining;\n }\n barEl.querySelector('.helper-amount').innerHTML = Rebuy.SmartCart.formatMoney(\n -Math.round(-bar.minimum * 100) - Rebuy.SmartCart.shippingExcludedSubtotal()\n );\n barEl.querySelector('.helper-product').innerHTML =\n bar.products[0].title ?? 'Produit gratuit';\n }\n }\n }\n };\n\n // Update Smart Cart with locale translations\n document.addEventListener('rebuy:smartcart.ready', () => {\n updateSmartCartLanguage();\n setTimeout(updateRemaining, 0);\n setTimeout(updateDOMText, 0);\n });\n\n document.addEventListener('rebuy:cart.change', () => {\n setTimeout(updateRemaining, 0);\n setTimeout(updateDOMText, 0);\n });\n\n // Update widgets with locale translations\n document.addEventListener('rebuy.ready', (event) => {\n const widget = event.detail.widget;\n\n updateWidgetLanguage(widget);\n setTimeout(updateRemaining, 0);\n setTimeout(updateDOMText, 0);\n });\n\n /**\n * Translate the Rebuy widgets with the correct language based on the localisation\n */\n class translateWidgets {\n constructor() {\n // Return if localization object not is found\n if (!localization) {\n return;\n }\n\n // Return is localization is the primary market\n if (localization.primary) {\n return;\n }\n\n // Listen for the Rebuy ready event to get the products to translate\n document.addEventListener('rebuy.productsChange', async (e) => {\n const widget = e.detail.widget;\n const products = widget.data.products || [];\n\n // Return if there are no products\n if (!products.length) {\n return;\n }\n\n await Promise.all(\n products.map(async (product) => {\n await this.updateProduct(product);\n })\n );\n\n // Update the widget with thçe new product\n widget.render();\n });\n }\n\n /**\n * Update the product translation in the Rebuy widget\n * @param {object} product object from Rebuy\n * @returns {void}\n */\n async updateProduct(product) {\n const storefrontHelper = new ShopifyStorefrontHelper();\n\n try {\n let translation = await this.fetchTranslation(product);\n translation = this.mapTranslation(product, translation);\n\n if (!translation) {\n return true;\n }\n\n // Update the product with the new translation\n product.body_html = translation.body_html;\n product.description = translation.description;\n product.handle = translation.handle;\n product.link = translation.link;\n product.product_type = translation.product_type;\n product.title = translation.title;\n product.tags = translation.tags.join(', ');\n product.vendor = translation.vendor;\n product.options = translation.options;\n product.variants = translation.variants;\n product.selected_variant = translation.selected_variant;\n\n // Update the product JSON with the new translation\n storefrontHelper.updateProductJSON(product);\n } catch (error) {\n console.error(error);\n }\n }\n\n /**\n * Fetch the product from Shopify by id to use as translation\n * @param {object} product object from Rebuy\n * @returns {object} product object from Shopify\n */\n async fetchTranslation(product) {\n if (!product?.id) {\n return;\n }\n\n const query = `\n query productDetails @inContext(country: ${localization.country}, language: ${localization.language}) {\n product(id: \"gid://shopify/Product/${product.id}\") {\n body_html: descriptionHtml\n description\n handle\n link: onlineStoreUrl\n product_type: productType\n title\n tags\n vendor\n options(first: 3) {\n id\n name\n values\n }\n variants(first: 99) {\n nodes {\n id\n title\n price {\n amount\n }\n }\n }\n selected_variant: selectedOrFirstAvailableVariant {\n id\n title\n price {\n amount\n }\n }\n }\n }\n `;\n\n const response = await fetch(\n 'https://oil-vinegar-store.myshopify.com/api/2024-10/graphql.json',\n {\n async: true,\n crossDomain: true,\n method: 'POST',\n headers: {\n 'X-Shopify-Storefront-Access-Token': localization.token,\n 'Content-Type': 'application/graphql',\n 'Accept-Language': localization.language,\n },\n body: query,\n }\n );\n\n const data = await response.json();\n const productData = data.data.product;\n\n return productData;\n }\n\n /**\n * Map the shopify product object to the Rebuy product object to use as translation\n * @param {*} product object from Rebuy\n * @param {*} translation product object from Shopify\n * @returns\n */\n mapTranslation(product, translation) {\n if (!product?.id || !translation?.title) {\n return;\n }\n\n // Update the product options to match the Rebuy format\n translation.options = translation.options.map((option, index) => {\n const id = parseInt(option.id.split('/').reverse()[0]);\n return {\n id: id,\n name: option.name,\n position: index + 1,\n product_id: product.id,\n values: option.values,\n };\n });\n\n // Update the product variants to match the Rebuy format\n translation.variants = translation.variants.nodes.map((variant, index) => {\n const id = parseInt(variant.id.split('/').reverse()[0]);\n const rebuyVariant = product.variants.find((v) => v.id == id);\n rebuyVariant.title = variant.title;\n rebuyVariant.price = variant.price.amount;\n return rebuyVariant;\n });\n\n // Update the selected variant to match the Rebuy format\n const selectedVariantId = parseInt(translation.selected_variant.id.split('/').reverse()[0]);\n const selectedVariant = translation.variants.find((v) => v.id == selectedVariantId);\n selectedVariant.title = translation.selected_variant.title;\n selectedVariant.price = translation.selected_variant.price.amount;\n translation.selected_variant = selectedVariant;\n\n // Fill in option1, option2, option3 based on the options\n translation.option1 = translation.options[0]?.name || '';\n translation.option2 = translation.options[1]?.name || '';\n translation.option3 = translation.options[2]?.name || '';\n\n return translation;\n }\n }\n new translateWidgets();\n});\n"],"names":["document","addEventListener","event","translations","fr","smart_cart","bmsm_discount_message","cart_title","checking_out_label","checkout_label","continue_shopping_label","discount_button_label","discount_code_label","discount_invalid_message","discount_label","empty_cart","free_shipping_reached","free_shipping_remaining","free_product_tier_remaining","notes_label","notes_placeholder","notes_remaining_characters","subtotal_plural_text","subtotal_singular_text","view_cart_label","view_cart_working_label","widget","add_to_cart","added_to_cart","adding_to_cart","cart_switch_to_onetime","cart_switch_to_subscription","cart_switch_to_subscription_footer","continue","decline","delivery_frequency_label","learn_more_label","remove_body","remove_confirm","remove_deny","remove_from_cart","remove_title","removed_from_cart","removing_from_cart","sold_out_label","thank_you_button","thank_you_description","thank_you_title","title","upgrade_to_subscription","variant_option","variant_options","total_price_label","reviews","pay_full_price","subscribe_and_save_20","one_time_only","stock_guaranteed_6_weeks","stock_guaranteed_8_weeks","stock_guaranteed_10_weeks","super_title","description","at","de","en","getLocaleFromDomain","host","pathname","window","location","subdomain","split","pathSegments","filter","Boolean","includes","length","updateSmartCartLanguage","locale","translation","Object","assign","Rebuy","SmartCart","settings","language","announcement_bar","updateWidgetLanguage","widgetTranslation","id","globalTranslation","data","compileConfig","updateElementText","selector","text","replaceText","elements","querySelectorAll","forEach","el","innerText","textContent","innerHTML","replace","updateElementAttribute","attr","value","setAttribute","updateDOMText","updateRemaining","remainingAmount","querySelector","Cart","cart","item_count","tiers","buy_more_save_more","tier","index","discount","quantity","progressBar","bar","getCurrentTier","barEl","getElementById","helperShipping","helperProduct","type","formatMoney","Math","round","minimum","shippingExcludedSubtotal","products","setTimeout","detail","translateWidgets","constructor","localization","primary","async","e","Promise","all","map","product","this","updateProduct","render","storefrontHelper","ShopifyStorefrontHelper","fetchTranslation","mapTranslation","body_html","handle","link","product_type","tags","join","vendor","options","variants","selected_variant","updateProductJSON","error","console","query","country","response","fetch","crossDomain","method","headers","token","body","json","productData","option","parseInt","reverse","name","position","product_id","values","nodes","variant","rebuyVariant","find","v","price","amount","selectedVariantId","selectedVariant","option1","option2","option3"],"mappings":"AAAAA,SAASC,iBAAiB,oBAAqBC,QAC7C,MAAMC,aAAe,CACnBC,GAAI,CACFC,WAAY,CACVC,sBACE,8FACFC,WAAY,uBACZC,mBAAoB,+BACpBC,eAAgB,qBAChBC,wBAAyB,uBACzBC,sBAAuB,6BACvBC,oBAAqB,6BACrBC,yBAA0B,sCAC1BC,eAAgB,6BAChBC,WACE,kGACFC,sBAAuB,yDACvBC,wBACE,0FACFC,4BACE,4FACFC,YAAa,gCACbC,kBAAmB,yBACnBC,2BAA4B,sBAC5BC,qBAAsB,QACtBC,uBAAwB,QACxBC,gBAAiB,iBACjBC,wBAAyB,0BAE3BC,OAAQ,CACNC,YAAa,UACbC,cAAe,SACfC,eAAgB,kBAChBC,uBAAwB,0BACxBC,4BAA6B,6BAC7BC,mCAAoC,6BACpCC,SAAU,YACVC,QAAS,UACTC,yBAA0B,yBAC1BC,iBAAkB,iBAClBC,YAAa,kDACbC,eAAgB,iBAChBC,YAAa,cACbC,iBAAkB,sBAClBC,aAAc,wBACdC,kBAAmB,WACnBC,mBAAoB,0BACpBC,eAAgB,SAChBC,iBAAkB,QAClBC,sBAAuB,0BACvBC,gBAAiB,SACjBC,MAAO,wBACPC,wBAAyB,wBACzBC,eAAgB,SAChBC,gBAAiB,UACjBC,kBAAmB,eACnBC,QAAS,OACTC,eAAgB,sBAChBC,sBAAuB,mCACvBC,cAAe,iBACfC,yBAA0B,+CAC1BC,yBAA0B,+CAC1BC,0BAA2B,iDAE7B,MAAO,CACLhC,YAAa,UACbiC,YAAa,GACbZ,MAAO,yBACPa,YAAa,IAEf,MAAO,CACLlC,YAAa,oBACbiC,YAAa,GACbZ,MAAO,sCACPa,YAAa,GACbT,kBAAmB,mBAGvBU,GAAI,CACFzD,WAAY,CACVC,sBACE,uFACFC,WAAY,gCACZC,mBAAoB,gCACpBC,eAAgB,kBA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