{"version":3,"sources":["jsdelivr-header.js","/gh/thegreendragoncbd/tgd-website-scripts@0e4beaf/quickview-multivariants.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,MAAM,SAAW,OAAO,SAAS,SACjC,IAAI,YAAa,EACb,kBAAmB,EAEvB,SAAS,oBACP,OACE,SAAS,SAAS,gCAClB,SAAS,SAAS,yBAClB,SAAS,SAAS,aAClB,SAAS,SAAS,uBAClB,SAAS,SAAS,qCAClB,SAAS,SAAS,YAClB,SAAS,SAAS,iCAClB,SAAS,SAAS,oBAClB,SAAS,SAAS,mBAClB,SAAS,SAAS,qBAClB,SAAS,SAAS,kBAClB,SAAS,SAAS,iBAClB,SAAS,SAAS,gBAClB,SAAS,SAAS,iBAClB,SAAS,SAAS,cAClB,SAAS,SAAS,mBAClB,SAAS,SAAS,gBAClB,SAAS,SAAS,mBAClB,SAAS,SAAS,mBAClB,SAAS,SAAS,oCAClB,SAAS,SAAS,mBAClB,SAAS,SAAS,oCAClB,SAAS,SAAS,YAClB,SAAS,SAAS,eAEtB,CACA,SAAS,iBAAiB,GACxB,MAAO,kBAAkB,KAAK,IAAa,EAAS,SAAS,uBAC/D,EACI,iBAAiB,WAAa,sBAChC,WAEE,MAAM,EAAgB,mBAChB,EAAc,iBACd,EAAgB,mBAChB,EAAkB,qBAClB,EAAc,iBACd,EAAiB,iBAEjB,EAAgB,GACtB,IAEI,EAFA,EAAe,GACf,EAAoB,CAAC,EAEzB,MAAM,EAAU,SAEhB,IAAI,EAAkB,SAAS,cAAc,uCAAuC,YAChF,YACA,EAAmB,SAAS,cAAc,uCAAuC,UACjF,EAAyB,SAAS,cACpC,uCACC,UACC,EAAqB,SAAS,cAAc,kCAAkC,UAClF,MAAM,EAAmB,SAAS,cAAc,mBAChD,IAAI,EAAiB,SAAS,cAAc,qBACxC,EAAyB,SAAS,cAAc,8BAChD,EAAyB,SAAS,cAAc,8BAChD,EAAwB,SAAS,cAAc,8BAC/C,EAAgB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cAAgB,GAE7C,MAAM,EAAsB,IACrB,EAAc,SACnB,IACA,IAA6B,EAG/B,OAAO,aAAa,KAClB,CACE,YACA,IAEE,EAAgB,SAAQ,IAEtB,EAAe,aAAa,GAAG,eAAe,IAC5C,EAAoB,EAAc,GAClC,GACF,GAGN,CACE,UACA,IAEE,MAAO,GAAgB,EAGvB,EAAa,GAAG,eAAe,IAC7B,EAAoB,EAAc,GAClC,GAIV,CAtEI,EAAsB,GAqrC3B,CApuCD","file":"/gh/thegreendragoncbd/tgd-website-scripts@0e4beaf/quickview-multivariants.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /gh/thegreendragoncbd/tgd-website-scripts@0e4beaf/quickview-multivariants.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const URL_PATH = window.location.pathname;\nlet anyInStock = false;\nlet isLegacySelector = false;\n\nfunction isProductListPage() {\n  return (\n    URL_PATH.includes(\"/product-parent-categories/\") ||\n    URL_PATH.includes(\"/product-categories/\") ||\n    URL_PATH.includes(\"/brands/\") ||\n    URL_PATH.includes(\"/shop-all-products\") ||\n    URL_PATH.includes(\"/shop-all-thc-cbd-glass-products\") ||\n    URL_PATH.includes(\"/brand/\") || \n    URL_PATH.includes(\"/product-primary-categories/\") ||\n    URL_PATH.includes(\"/subcategories/\") ||\n    URL_PATH.includes(\"/torch-gummies\") ||\n    URL_PATH.includes(\"/digiflavor-vape\") ||\n    URL_PATH.includes(\"/2-gram-carts\") ||\n    URL_PATH.includes(\"/ghost-carts\") ||\n    URL_PATH.includes(\"/ghost-vape\") ||\n    URL_PATH.includes(\"/hhc-gummies\") ||   \n    URL_PATH.includes(\"/hhc-vape\") ||   \n    URL_PATH.includes(\"/thca-diamonds\") || \n    URL_PATH.includes(\"/thc-drinks\") ||   \n    URL_PATH.includes(\"/thc-tinctures\") ||   \n    URL_PATH.includes(\"/simple-brands\")  ||\n    URL_PATH.includes(\"/disposable-thc-vape-pens-carts\") ||\n    URL_PATH.includes(\"/empire-brands\") || \n    URL_PATH.includes(\"/bulk-thca-flower-pounds-online\") ||\n    URL_PATH.includes(\"/pages/\") || \n    URL_PATH.includes(\"/sales-deals\")\n  );\n}\nfunction isProductCMSPage(URL_PATH) {\n  return /\\/(product)\\/.*/.test(URL_PATH) || URL_PATH.includes(\"/products-wholesale/\");\n}\nif (isProductCMSPage(URL_PATH) || isProductListPage()) {\n  (function () {\n    // Constants and variables\n    const STRAIN_DIV_ID = \"#variants-strain\";\n    const SIZE_DIV_ID = \"#variants-size\";\n    const FLAVOR_DIV_ID = \"#variants-flavor\";\n    const STRENGTH_DIV_ID = \"#variants-strength\";\n    const TYPE_DIV_ID = \"#variants-type\";\n    const RADIO_DISABLED = \"radio-disabled\";\n\n    const variantGroups = [];\n    let variantItems = [];\n    let productItemObject = {};\n    let selectedProductVariantInfo;\n    const element = document;\n\n    let priceLowElement = document.querySelector(\".product-price_low-to-high-wrapper\")?.firstChild\n      ?.nextSibling;\n    let priceHighElement = document.querySelector(\".product-price_low-to-high-wrapper\")?.lastChild;\n    let beforeSalePriceElement = document.querySelector(\n      \".product-price_before-sale-wrapper\"\n    )?.lastChild;\n    let activePriceElement = document.querySelector(\".product-price_active-wrapper\")?.lastChild;\n    const inventoryElement = document.querySelector(\"#foxy-inventory\");\n    let priceAddToCart = document.querySelector(\"input[name=price]\");\n    let wholesaleDollarPerUnit = document.querySelector(\".wholesale-dollar-per-unit\");\n    let wholesaleDollarPerCase = document.querySelector(\".wholesale-dollar-per-case\");\n    let wholesaleUnitsPerCase = document.querySelector(\".wholesale-number-per-case\");\n    let wholesaleMSRP = document.querySelector(\".wholesale-msrp\");\n    let isWholesale = \"\";\n    const isWholesalePage = URL_PATH.includes(\"/products-wholesale/\");\n\n    document.head.insertAdjacentHTML(\n      \"beforeend\",\n      \"<style>.radio-group .w-radio.radio-disabled{border: 1px dashed #ccc !important;background-color: white !important;border-radius: 5px !important;} .show-quickview{display: flex !important; opacity: 1!important; transform: translate3d(0px, 0px, 0px) scale3d(1, 1, 1) rotateX(0deg) rotateY(0deg) rotateZ(0deg) skew(0deg, 0deg) !important;    transform-style: preserve-3d!important;} </style>\"\n    );\n\n    // Init product detail page\n    if (isProductCMSPage(URL_PATH)) {\n      $(document).ready(() => {\n        init();\n      });\n    }\n    // Pages with Product Lists\n    if (isProductListPage()) {\n      $(document).ready(() => {\n        handleQuickViewSetUp();\n        setPricesForProductListings();\n        handleCmsFilterEvent();\n      });\n    }\n\n    function handleQuickViewSetUp() {\n      const allGridItems = document.querySelectorAll(\".foxy_product_collection-item\");\n\n      allGridItems.forEach((item, index) => {\n        const itemName = item\n          .querySelector(\".foxy_product_item_info .foxy_product_item_name\")\n          .innerText.split(\" \")[0].replace(/['\"]/g, '').replace(/[&]/g, '');\n          //itemName = itemName.replace(/['\"]/g, '\\\\$&');\n        item.setAttribute(\"id\", `${itemName}-${index}`);\n      });\n    }\n\n    function setPricesForProductListings() {\n      const allGridItems = document.querySelectorAll(\".foxy_product_collection-item\");\n\n      allGridItems.forEach(item => {\n        priceLowElement = item.querySelector(\".product-grid-price_low-to-high-wrapper\").firstChild\n          .nextSibling;\n        priceHighElement = item.querySelector(\".product-grid-price_low-to-high-wrapper\").lastChild;\n        beforeSalePriceElement = item.querySelector(\n          \".product-grid-price_before-sale-wrapper\"\n        ).lastChild;\n        activePriceElement = item.querySelector(\".product-grid-price_active-wrapper\").lastChild;\n        priceAddToCart = item.querySelector(\"input[name=price]\");\n\n        buildProductItemList(item.id);\n        buildVariantItemsList(item.id);\n        addPrice();\n      });\n    }\n\n    function handleCmsFilterEvent() {\n      window.fsAttributes = window.fsAttributes || [];\n\n      const handleRenderedItems = renderedItems => {\n        if (!renderedItems.length) return;\n        handleQuickViewSetUp();\n        setPricesForProductListings();\n      };\n\n      window.fsAttributes.push(\n        [\n          \"cmsfilter\",\n          filterInstances => {\n            // The callback passes a `filterInstances` array with all the `CMSFilters` instances on the page.\n            filterInstances.forEach(filterInstance => {\n              // The `renderitems` event runs whenever the list renders items after filtering.\n              filterInstance.listInstance.on(\"renderitems\", renderedItems => {\n                handleRenderedItems(renderedItems);\n              });\n            });\n          },\n        ],\n        [\n          \"cmsload\",\n          listInstances => {\n            // The callback passes a `listInstances` array with all the `CMSList` instances on the page.\n            const [listInstance] = listInstances;\n\n            // The `renderitems` event runs whenever the list renders items after switching pages.\n            listInstance.on(\"renderitems\", renderedItems => {\n              handleRenderedItems(renderedItems);\n            });\n          },\n        ]\n      );\n    }\n\n    function init() {\n      // Create Product and VariantItemsList\n      buildProductItemList();\n      buildVariantItemsList();\n\n      // Set quantity input defaults\n      const quantityInput = element.querySelector('input[name=\"quantity\"]');\n      quantityInput.value = 1;\n      quantityInput.setAttribute(\"min\", \"1\");\n\n      // Remove srcset from primary image element\n      element.querySelector(\"#foxy-image\").setAttribute(\"srcset\", \"\");\n\n      // Build variant/radio options\n      buildVariants();\n\n      //Add Price according to product\n      isWholesale = isWholesaler() !== false && isWholesaler() !== \"none\";\n      if (isWholesale && isWholesalePage) {\n        addPriceWholesale(isWholesaler());\n      } else {\n        addPrice();\n      }\n\n      // For non-variant products, notify the subscription widget of the effective\n      // price after addPrice() has resolved it. Variant products already dispatch\n      // dgc:variantSelected when the user picks a variant; this covers the\n      // non-variant case so the subscription widget gets the correct base price.\n      if (!variantItems.length) {\n        document.dispatchEvent(new CustomEvent('dgc:variantSelected', {\n          detail: {\n            variant: {\n              price:     productItemObject.salePrice || productItemObject.price || '',\n              salePrice: productItemObject.salePrice || ''\n            }\n          }\n        }));\n      }\n\n      // Set Inventory according to product\n      setInventory();\n\n      // Handle selected variants\n      element.querySelector(\"#foxy-form\").addEventListener(\"change\", handleVariantSelection);\n      handleOnPageLoadVariantSelection();\n      addImageChangeFunctionality();\n    }\n\n    function addImageChangeFunctionality() {\n      if (element !== document) return;\n\n      const galleryImages = element.querySelectorAll(\n        \".product_images-wrapper .multi_lightbox-link\"\n      );\n\n      const updateMainImageHandler = evt => {\n        const imageClicked = evt.target.src;\n\n        document.querySelector(\"#foxy-image\").src = imageClicked;\n      };\n\n      galleryImages.forEach(image => {\n        image.addEventListener(\"click\", updateMainImageHandler);\n      });\n    }\n\n    function handleOnPageLoadVariantSelection() {\n      if (element !== document) return;\n      const params = new URLSearchParams(window.location.search);\n\n      for (const [key, value] of params) {\n        const variantToSelect = document.querySelector(`#variants-${key} input[value=\"${value}\"]`);\n\n        if (variantToSelect) {\n          variantToSelect.click();\n        }\n      }\n    }\n\n    function buildVariantItemsList(elementID) {\n      variantItems = [];\n      let variants_item = isProductListPage()\n        ? `#${elementID} .foxy_variant_item`\n        : \".foxy_variant_item\";\n      $(variants_item).each(function () {\n        const name = $(this).find(\".foxy_variants_item-name\").text();\n        const price = $(this).find(\".foxy_variants_item-price\").text();\n        const salePrice = $(this).find(\".foxy_variants_item-sale-price\").text();\n        const weight = $(this).find(\".foxy_variants_item-weight\").text();\n        const inventory = $(this).find(\".foxy_variants_item-inventory\").text()\n          ? $(this).find(\".foxy_variants_item-inventory\").text()\n          : \"0\";\n        const image = $(this).find(\".foxy_variants_item-image\").attr(\"src\");\n        const code = $(this).find(\".foxy_variants_item-sku\").text();\n        const strain = $(this).find(\".foxy_variants_item-strain\").text();\n        const size = $(this).find(\".foxy_variants_item-size\").text();\n        const flavor = $(this).find(\".foxy_variants_item-flavor\").text();\n        const strength = $(this).find(\".foxy_variants_item-strength\").text();\n        const type = $(this).find(\".foxy_variants_item-type\").text();\n        const allowBackorders = $(this).find(\".foxy_variants_item-allow-backorders\").text();\n        const restrictedShipping = $(this).find(\".foxy_variants_item-restricted-shipping\").text();\n        const itemCertification = $(this).find(\".foxy_variants_item-certification-link\").prop(\"href\");\n        const wholesale = {\n          available: $(this).find(\".foxy_variants_item-wholesale-availability\").text(),\n          tier1: $(this).find(\".foxy_variants_item-wholesale-tier1\").text(),\n          tier2: $(this).find(\".foxy_variants_item-wholesale-tier2\").text(),\n          tier3: $(this).find(\".foxy_variants_item-wholesale-tier3\").text(),\n          msrp: $(this).find(\".foxy_variants_item_msrp\").text(),\n          tier1_baseunit: $(this).find(\".foxy_variants_item-base-unit-cost_tier1\").text(),\n          tier2_baseunit: $(this).find(\".foxy_variants_item-base-unit-cost_tier2\").text(),\n          tier3_baseunit: $(this).find(\".foxy_variants_item-base-unit-cost_tier3\").text(),\n          units_per_case: $(this).find(\".foxy_variants_item-wholesale-units-per-case\").text(),\n        };\n\n        variantItems.push(\n          filterEmpty({\n            name,\n            strain,\n            size,\n            flavor,\n            strength,\n            type,\n            code,\n            image,\n            inventory,\n            weight,\n            salePrice,\n            price,\n            allowBackorders,\n            restrictedShipping,\n            itemCertification,\n            wholesale,\n          })\n        );\n      });\n    }\n\n    function buildProductItemList(elementID) {\n      productItemObject = {};\n      let item_info = \".foxy_product_item_info\";\n      if (isProductListPage()) item_info = `#${elementID} .foxy_product_item_info`;\n      $(item_info).each(function () {\n        let name = $(this).find(\".foxy_product_item_name\").text();\n        let price = $(this).find(\".foxy_product_item_price\").text();\n        let salePrice = $(this).find(\".foxy_product_item_sale-price\").text();\n        let weight = $(this).find(\".foxy_product_item_weight\").text();\n        let inventory = $(this).find(\".foxy_product_item_inventory\").text()\n          ? $(this).find(\".foxy_product_item_inventory\").text()\n          : \"0\";\n        let sku = $(this).find(\".foxy_product_item_sku\").text();\n        let allowBackorders = $(this).find(\".foxy_product_item_allow-backorders\").text();\n        let restrictedShippingCode = $(this).find(\".foxy_product_item_restricted-shipping-code\").text();\n        const restrictedShipping = $(this).find(\".foxy_variants_item-restricted-shipping\").text();\n        const itemCertification = $(this).find(\".foxy_variants_item-certification-link\").prop(\"href\")\n          ? $(this).find(\".foxy_variants_item-certification-link\").prop(\"href\")\n          : \"none\";\n        const wholesale = {\n          available: $(this).find(\".foxy_product_item_wholesale-availability\").text(),\n          tier1: $(this).find(\".foxy_product_item_wholesale-tier1\").text(),\n          tier2: $(this).find(\".foxy_product_item_wholesale-tier2\").text(),\n          tier3: $(this).find(\".foxy_product_item_wholesale-tier3\").text(),\n          msrp: $(this).find(\".foxy_product_item_msrp\").text(),\n          tier1_baseunit: $(this).find(\".foxy_product_item_wholesale-tier1_base-unit-cost\").text(),\n          tier2_baseunit: $(this).find(\".foxy_product_item_wholesale-tier2_base-unit-cost\").text(),\n          tier3_baseunit: $(this).find(\".foxy_product_item_wholesale-tier3_base-unit-cost\").text(),\n          units_per_case: $(this).find(\".foxy_product_item_wholesale-units-per-case\").text(),\n        };\n\n        productItemObject = filterEmpty({\n          name: name,\n          sku: sku,\n          inventory: inventory,\n          weight: weight,\n          salePrice: salePrice,\n          price: price,\n          allowBackorders: allowBackorders,\n          restrictedShipping,\n          restrictedShippingCode,\n          itemCertification,\n          wholesale,\n        });\n      });\n    }\n\n    function addPrice() {\n      //--- Product doesn't have variants---\n      if (!variantItems.length) {\n        // Product has salesPrice or not\n        if (productItemObject.salePrice) {\n          beforeSalePriceElement.textContent = hasMembership()\n            ? productItemObject.salePrice\n            : productItemObject.price;\n          activePriceElement.textContent = getMembershipSpecialPrice(productItemObject.salePrice);\n          if (!isProductListPage()) priceAddToCart.value = productItemObject.salePrice;\n\n          beforeSalePriceElement.parentElement.style.display = \"inline-block\";\n          activePriceElement.parentElement.style.display = \"inline-block\";\n        } else {\n          activePriceElement.textContent = getMembershipSpecialPrice(productItemObject.price);\n          activePriceElement.classList.remove(\"w-dyn-bind-empty\");\n          activePriceElement.parentElement.style.display = \"inline-block\";\n          beforeSalePriceElement.parentElement.style.display = hasMembership()\n            ? \"inline-block\"\n            : \"none\";\n          beforeSalePriceElement.textContent = productItemObject.price;\n          if (!isProductListPage()) priceAddToCart.value = productItemObject.price;\n        }\n      }\n\n      //--- Product has variants---\n      if (variantItems.length > 0) {\n        // Variants that affect price\n        let allProductVariantsHaveSalePrices = [];\n        const sortedPrices = variantItems\n          .map(variant => {\n            if (Number(variant.salePrice)) {\n              allProductVariantsHaveSalePrices.push({\n                salePrice: variant.salePrice,\n                hasSalePrice: true,\n                price: variant.price,\n              });\n              return Number(variant.salePrice);\n            } else {\n              allProductVariantsHaveSalePrices.push({\n                salePrice: variant.salePrice,\n                hasSalePrice: false,\n                price: variant.price,\n              });\n              return Number(variant.price);\n            }\n          })\n          .sort((a, b) => a - b);\n\n        if (sortedPrices[0] !== sortedPrices[sortedPrices.length - 1]) {\n          priceLowElement.textContent = getMembershipSpecialPrice(sortedPrices[0]);\n          priceHighElement.textContent = getMembershipSpecialPrice(\n            sortedPrices[sortedPrices.length - 1]\n          );\n          priceLowElement.parentElement.style.display = \"block\";\n          beforeSalePriceElement.parentElement.style.display = \"none\";\n          activePriceElement.parentElement.style.display = \"none\";\n        } else {\n          // Variants that don't affect price with salePrice and without\n          if (\n            allProductVariantsHaveSalePrices.every(\n              productCheck => productCheck.hasSalePrice === true\n            )\n          ) {\n            beforeSalePriceElement.textContent = hasMembership()\n              ? allProductVariantsHaveSalePrices[0].salePrice\n              : allProductVariantsHaveSalePrices[0].price;\n            activePriceElement.textContent = getMembershipSpecialPrice(\n              allProductVariantsHaveSalePrices[0].salePrice\n            );\n            if (!isProductListPage())\n              priceAddToCart.value = allProductVariantsHaveSalePrices[0].salePrice;\n            beforeSalePriceElement.classList.remove(\"w-dyn-bind-empty\");\n            activePriceElement.classList.remove(\"w-dyn-bind-empty\");\n            beforeSalePriceElement.parentElement.style.display = \"inline-block\";\n            activePriceElement.parentElement.style.display = \"inline-block\";\n            return;\n          }\n          activePriceElement.textContent = getMembershipSpecialPrice(sortedPrices[0]);\n          if (!isProductListPage()) priceAddToCart.value = sortedPrices[0];\n          activePriceElement.classList.remove(\"w-dyn-bind-empty\");\n          beforeSalePriceElement.classList.remove(\"w-dyn-bind-empty\");\n          activePriceElement.parentElement.style.display = \"inline-block\";\n          beforeSalePriceElement.parentElement.style.display = hasMembership()\n            ? \"inline-block\"\n            : \"none\";\n          beforeSalePriceElement.textContent = sortedPrices[0];\n        }\n      }\n    }\n\n    function addPriceWholesale(wholesaleTier) {\n      if (!variantItems.length) {\n        const wholesalePrice = productItemObject.wholesale[wholesaleTier];\n        activePriceElement.textContent = wholesalePrice;\n        activePriceElement.classList.remove(\"w-dyn-bind-empty\");\n        activePriceElement.parentElement.style.display = \"inline-block\";\n        beforeSalePriceElement.parentElement.style.display = \"none\";\n        beforeSalePriceElement.textContent = productItemObject.price;\n        if (!isProductListPage()) priceAddToCart.value = wholesalePrice;\n        wholesaleDollarPerUnit.textContent =\n          productItemObject.wholesale[wholesaleTier + \"_baseunit\"];\n        const casePrice =\n          parseFloat(productItemObject.wholesale[\"units_per_case\"]) *\n          parseFloat(wholesaleDollarPerUnit.textContent);\n        wholesaleDollarPerCase.textContent = casePrice.toFixed(2);\n      }\n\n      //--- Product has variants---\n      if (variantItems.length > 0) {\n        const selectVariantText = \"Please choose options.\";\n        wholesaleDollarPerUnit.textContent = selectVariantText;\n        wholesaleDollarPerCase.textContent = selectVariantText;\n        wholesaleMSRP.textContent = selectVariantText;\n        wholesaleUnitsPerCase.textContent = selectVariantText;\n        // hide dollar sign\n        wholesaleMSRP.previousElementSibling.style.display = \"none\";\n        wholesaleDollarPerUnit.previousElementSibling.style.display = \"none\";\n        wholesaleDollarPerCase.previousElementSibling.style.display = \"none\";\n        const sortedPrices = variantItems\n          .map(variant => {\n            const wholesalePrice = variant.wholesale[wholesaleTier];\n            return Number(wholesalePrice).toFixed(2);\n          })\n          .sort((a, b) => a - b);\n\n        if (sortedPrices[0] === sortedPrices[sortedPrices.length - 1]) {\n          // Variants that don't affect price\n          activePriceElement.textContent = sortedPrices[0];\n          if (!isProductListPage()) priceAddToCart.value = sortedPrices[0];\n          activePriceElement.classList.remove(\"w-dyn-bind-empty\");\n          beforeSalePriceElement.classList.remove(\"w-dyn-bind-empty\");\n          activePriceElement.parentElement.style.display = \"inline-block\";\n          beforeSalePriceElement.parentElement.style.display = \"none\";\n          beforeSalePriceElement.textContent = sortedPrices[0];\n        } else {\n          // Variants that affect price\n          priceLowElement.textContent = sortedPrices[0];\n          priceHighElement.textContent = sortedPrices[sortedPrices.length - 1];\n          priceLowElement.parentElement.style.display = \"block\";\n          beforeSalePriceElement.parentElement.style.display = \"none\";\n          activePriceElement.parentElement.style.display = \"none\";\n        }\n      }\n    }\n\n    function setInventory() {\n      if (variantItems.length > 0) {\n        inventoryElement.textContent = \"Please choose options.\";\n        inventoryElement.classList.remove(\"w-dyn-bind-empty\");\n        inventoryElement.nextElementSibling?.style.setProperty(\"display\", \"none\");\n        return;\n      }\n\n      if (!variantItems.length) {\n        const { inventory, allowBackorders, wholesale } = productItemObject;\n        const quantity = element.querySelector(\"input[name=quantity]\").value;\n        const submitButton = element.querySelector(\"#foxy-form input[type=submit]\");\n\n        if (isWholesale && isWholesalePage && wholesale.available === \"false\") {\n          inventoryElement.textContent = \"Unavailable\";\n          inventoryElement.nextElementSibling?.style.setProperty(\"display\", \"none\");\n          submitButton.disabled = true;\n          submitButton.style.backgroundColor = \"#37b7728c\";\n          return;\n        }\n        if (isWholesale && isWholesalePage && wholesale.available === \"true\") {\n          inventoryElement.textContent = \"Available\";\n          inventoryElement.nextElementSibling?.style.setProperty(\"display\", \"none\");\n          return;\n        }\n\n        if (Number(inventory) > 0) {\n          inventoryElement.textContent = inventory;\n          inventoryElement.nextElementSibling?.style.setProperty(\"display\", \"inline\");\n          return;\n        }\n\n        if (Number(inventory) === 0 && allowBackorders === \"false\") {\n          inventoryElement.textContent = \"Out of stock.\";\n          inventoryElement.nextElementSibling?.style.setProperty(\"display\", \"none\");\n          submitButton.disabled = true;\n          submitButton.style.backgroundColor = \"#37b7728c\";\n          return;\n        }\n\n        if (\n          (Number(quantity) > Number(inventory) && allowBackorders === \"true\") ||\n          (Number(inventory) === 0 && allowBackorders === \"true\")\n        ) {\n          inventoryElement.textContent = \"Item Available for Backorder.\";\n          inventoryElement.classList.remove(\"margin-top-1-5\");\n          inventoryElement.nextElementSibling?.style.setProperty(\"display\", \"none\");\n          element\n            .querySelector(\"#foxy-form .w-embed\")\n            .insertAdjacentHTML(\n              \"beforeend\",\n              `<input type=\"hidden\" name=\"Delayed_shipping\" value=\"Item Available for Backorder.\">`\n            );\n          return;\n        }\n      }\n    }\n\n    function buildVariants(elementID) {\n      let variants_item = isProductListPage()\n        ? `#${elementID} .foxy_variant_item`\n        : \".foxy_variant_item\";\n\n\n      let variantCount = $(variants_item).length;\n      console.log(\"Total variants found:\", variantCount);\n\n      let dropdown = false;\n\n      if (variantCount <= 4) {\n        console.log('4 or less, use legacy selector')\n        dropdown = false;\n        isLegacySelector = true;\n      } else {\n        console.log('use new selector')\n        dropdown = true;\n      }\n\n      $(variants_item).each(function (index) {\n\n\n        let strain = $(this).find(\".foxy_variants_item-strain\").text();\n        let size = $(this).find(\".foxy_variants_item-size\").text();\n        let flavor = $(this).find(\".foxy_variants_item-flavor\").text();\n        let strength = $(this).find(\".foxy_variants_item-strength\").text();\n        let type = $(this).find(\".foxy_variants_item-type\").text();\n\n        // console.log('flavor: ', flavor)\n\n        if (dropdown) {\n          addVariantGroup(strain, STRAIN_DIV_ID, index);\n          addVariantGroup(size, SIZE_DIV_ID, index);\n          addVariantGroup(flavor, FLAVOR_DIV_ID, index);\n          addVariantGroup(strength, STRENGTH_DIV_ID, index);\n          addVariantGroup(type, TYPE_DIV_ID, index);\n        } else {\n          addVariantGroupLegacy(strain, STRAIN_DIV_ID, index);\n          addVariantGroupLegacy(size, SIZE_DIV_ID, index);\n          addVariantGroupLegacy(flavor, FLAVOR_DIV_ID, index);\n          addVariantGroupLegacy(strength, STRENGTH_DIV_ID, index);\n          addVariantGroupLegacy(type, TYPE_DIV_ID, index);\n        }\n        \n      });\n\n      if (!anyInStock && !isLegacySelector) {\n        \n        console.log('hide the selector')\n\n        document.querySelector(\"#flavor-wrapper > #variants-flavor\").style.display = \"none\";\n        document.getElementById('variant-flavor-text').textContent = 'Currently out of stock';\n        var qtySelector = document.querySelectorAll('#foxy-form > .product-description-basics')\n        qtySelector[2].style.display = 'none';\n\n\n      }\n    }\n\n    // original working version, no dropdown yet\n\n    function addVariantGroupLegacy(variantInfo, VariantContainer, index) {\n      const variantGroupName = capitalizeFirstLetter(VariantContainer.split(\"-\")[1]);\n      if (variantGroupName) variantGroups.push(variantGroupName);\n      const variant_container = VariantContainer;\n\n      if (variantInfo != \"\") {\n        // Show variant container\n        element.querySelector(VariantContainer).parentElement.style.display = \"block\";\n        let variantListed = 0;\n\n        document.querySelector(VariantContainer).style.display = \"grid\";\n\n        $(variant_container).append(\n          `<label class=\"radio-button-field w-radio\">\n            <div class=\"w-form-formradioinput w-form-formradioinput--inputType-custom radio-button w-radio-input\"></div>\n            <input type=\"radio\" name=\"${variantGroupName}\" id=\"${variantInfo}-${index}\" class=\"${variantInfo\n              .split(/\\s+/)\n              .join(\"\")\n              .toLowerCase()}\" value=\"${variantInfo}\" style=\"opacity:0;position:absolute;z-index:-1\" required>\n            <span class=\"radio-btn w-form-label\" for=\"${variantInfo}-${index}\">${variantInfo}</span>\n          </label>`\n        );\n        $(`${variant_container} .w-radio`).each(function () {\n          let label = $(this).find(\".w-form-label\").text();\n          if (variantInfo == label && variantListed == 0) {\n            variantListed = 1;\n          } else if (variantInfo == label && variantListed == 1) {\n            $(this).remove();\n          }\n            //strikethrough if its out of stock\n            \n            let obj;\n            console.log(variantGroupName.toLowerCase());\n          switch(variantGroupName.toLowerCase()){\n              case \"flavor\":  \n                obj = variantItems.find(o => o.flavor == `${label}` );\n              break;\n              case \"strain\":\n                  obj = variantItems.find(o => o.strain == `${label}` );\n              break;\n              case \"size\":\n                  obj = variantItems.find(o => o.size == `${label}` );\n              break;\n              case \"strength\":\n                  obj = variantItems.find(o => o.strength == `${label}` );\n              break;\n              case \"type\":\n                  obj = variantItems.find(o => o.type == `${label}` );\n              break;\n          }\n          if (Number(obj.inventory) === 0 && !isWholesalePage) {\n                $(this).find(\".w-form-label\")[0].style.textDecoration = \"line-through\";\n          }\n        });\n      } else {\n        $(variant_container).parent().remove();\n      }\n    }\n\n\n// version working with dropdown\n\n// let anyInStock = false;\n\nfunction addVariantGroup(variantInfo, VariantContainer, index) {\n  console.log('in addVariantGroup')\n  const variantGroupName = capitalizeFirstLetter(VariantContainer.split(\"-\")[1]);\n  if (variantGroupName) variantGroups.push(variantGroupName);\n  const variant_container = VariantContainer;\n\n  if (variantInfo !== \"\") {\n    element.querySelector(VariantContainer).parentElement.style.display = \"block\";\n\n    // Only add the custom select once (with a placeholder top option)\n    if ($(variant_container).find(\"select\").length === 0) {\n      $(variant_container).append(`\n        <label class=\"dropdown-label\">${variantGroupName}</label>\n        <select name=\"${variantGroupName}\" class=\"variant-dropdown w-select\" required>\n          <option value=\"\" disabled selected>Please select a ${variantGroupName}</option>\n        </select>\n      `);\n    }\n\n    const $select = $(`${variant_container} select`);\n    let alreadyExists = false;\n\n    // Check if option already exists\n    $select.find(\"option\").each(function () {\n      if ($(this).val() === variantInfo) {\n        alreadyExists = true;\n      }\n    });\n\n    if (!alreadyExists) {\n      let obj;\n      switch (variantGroupName.toLowerCase()) {\n        case \"flavor\":\n          obj = variantItems.find(o => o.flavor === variantInfo);\n          break;\n        case \"strain\":\n          obj = variantItems.find(o => o.strain === variantInfo);\n          break;\n        case \"size\":\n          obj = variantItems.find(o => o.size === variantInfo);\n          break;\n        case \"strength\":\n          obj = variantItems.find(o => o.strength === variantInfo);\n          break;\n        case \"type\":\n          obj = variantItems.find(o => o.type === variantInfo);\n          break;\n      }\n\n      const isOutOfStock = obj && Number(obj.inventory) === 0 && !isWholesalePage;\n      const displayText = isOutOfStock ? `${variantInfo} (Out of stock)` : variantInfo;\n\n      if (!isOutOfStock) {\n        anyInStock = true; // Set flag if any variant is in stock\n      }\n\n      // Add the option to the select (disabled if OOS)\n      $select.append(`<option value=\"${variantInfo}\" ${isOutOfStock ? \"disabled\" : \"\"}>${displayText}</option>`);\n\n      // Append a hidden radio for FoxyCart (remains required to enforce selection)\n      $(variant_container).append(`\n        <input\n          type=\"radio\"\n          name=\"${variantGroupName}\"\n          id=\"${variantInfo}-${index}\"\n          value=\"${variantInfo}\"\n          class=\"fc-hidden-radio\"\n          style=\"display: none;\"\n          ${isOutOfStock ? \"disabled\" : \"\"}\n          required\n        >\n      `);\n    }\n\n    // how about we do the selector right here?\n    var radioGroupElement = document.querySelector('.radio-group')\n    // radioGroupElement.classList.add('radio-group-position')\n    var radioGroupElement = document.querySelector('.radio-group');\n\nradioGroupElement.style.display = 'grid';\nradioGroupElement.style.gridTemplateColumns = 'minmax(0, 100px) minmax(0, 270px)';\n\n    // Sync select changes to radio selection\n    $select.off(\"change\").on(\"change\", function () {\n      const selectedValue = $(this).val();\n\n      // If placeholder (empty) is selected, ensure no radio is checked\n      if (!selectedValue) {\n        $(`${variant_container} input[type=radio][name=\"${variantGroupName}\"]`).prop(\"checked\", false);\n        return;\n      }\n\n      // Check the matched hidden radio\n      $(`${variant_container} input[type=radio][value=\"${selectedValue}\"]`).prop(\"checked\", true);\n    });\n  } else {\n    $(variant_container).parent().remove();\n  }\n\n  console.log('anyInStock:', anyInStock);\n}\n\n\n\n\n\n// function addVariantGroup(variantInfo, VariantContainer, index) {\n//   const variantGroupName = capitalizeFirstLetter(VariantContainer.split(\"-\")[1]);\n//   if (variantGroupName) variantGroups.push(variantGroupName);\n//   const variant_container = VariantContainer;\n\n//   if (variantInfo !== \"\") {\n//     element.querySelector(VariantContainer).parentElement.style.display = \"block\";\n\n//     // Count how many options we already have (before adding new one)\n//     let currentCount = $(`${variant_container} input[type=radio]`).length;\n\n//     // If fewer than 4 after adding this one, just display message\n//     if (currentCount < 3) { // < 3 here because we're about to add 1 more\n//       if ($(variant_container).find(\".variant-message\").length === 0) {\n//         $(variant_container).append(`<div class=\"variant-message\">less than 4 options</div>`);\n//       }\n//     } else {\n//       // Only add the custom select once\n//       if ($(variant_container).find(\"select\").length === 0) {\n//         $(variant_container).append(`\n//           <label class=\"dropdown-label\">${variantGroupName}</label>\n//           <select name=\"${variantGroupName}\" class=\"variant-dropdown w-select\" required></select>\n//         `);\n//       }\n\n//       const $select = $(`${variant_container} select`);\n//       let alreadyExists = false;\n\n//       // Check if option already exists\n//       $select.find(\"option\").each(function () {\n//         if ($(this).val() === variantInfo) {\n//           alreadyExists = true;\n//         }\n//       });\n\n//       if (!alreadyExists) {\n//         let obj;\n//         switch (variantGroupName.toLowerCase()) {\n//           case \"flavor\":\n//             obj = variantItems.find(o => o.flavor === variantInfo);\n//             break;\n//           case \"strain\":\n//             obj = variantItems.find(o => o.strain === variantInfo);\n//             break;\n//           case \"size\":\n//             obj = variantItems.find(o => o.size === variantInfo);\n//             break;\n//           case \"strength\":\n//             obj = variantItems.find(o => o.strength === variantInfo);\n//             break;\n//           case \"type\":\n//             obj = variantItems.find(o => o.type === variantInfo);\n//             break;\n//         }\n\n//         const isOutOfStock = obj && Number(obj.inventory) === 0 && !isWholesalePage;\n//         const displayText = isOutOfStock ? `${variantInfo} (Out of stock)` : variantInfo;\n\n//         // Add the option to the select\n//         $select.append(`<option value=\"${variantInfo}\" ${isOutOfStock ? \"disabled\" : \"\"}>${displayText}</option>`);\n\n//         // Append a hidden radio for FoxyCart\n//         $(variant_container).append(`\n//           <input\n//             type=\"radio\"\n//             name=\"${variantGroupName}\"\n//             id=\"${variantInfo}-${index}\"\n//             value=\"${variantInfo}\"\n//             class=\"fc-hidden-radio\"\n//             style=\"display: none;\"\n//             ${isOutOfStock ? \"disabled\" : \"\"}\n//             required\n//           >\n//         `);\n//       }\n\n//       // Sync select changes to radio selection\n//       $select.off(\"change\").on(\"change\", function () {\n//         const selectedValue = $(this).val();\n//         $(`${variant_container} input[type=radio][value=\"${selectedValue}\"]`).prop(\"checked\", true);\n//       });\n//     }\n//   } else {\n//     $(variant_container).parent().remove();\n//   }\n// }\n\n\n\n\n\n\n\n\n\n\n\n\n    function handleVariantSelection(e) {\n      const variants_item = \".foxy_variant_item\";\n      const variantSelection = e.target.value;\n      const variantSelectionGroup = e.target.name;\n      if (!variantSelectionGroup) return;\n\n      // Handle quantity change to update availability when variant is chosen.\n      if (variantSelectionGroup === \"quantity\" && isVariantsSelectionComplete())\n        return handleQuantityChange();\n\n      // remove RADIO_DISABLED class on current target\n      e.target.parentElement.classList.remove(RADIO_DISABLED);\n      element\n        .querySelector(`#variants-${variantSelectionGroup.toLowerCase()}`)\n        .classList.add(\"option-selected\");\n\n      // Possible product and variant combinations and their product info\n      const availableProductsPerVariant = [];\n      // TODO refactor this to only do this once check this variable variantItems\n      $(variants_item).each(function () {\n        const name = $(this).find(\".foxy_variants_item-name\").text();\n        let price = $(this).find(\".foxy_variants_item-price\").text();\n        let salePrice = $(this).find(\".foxy_variants_item-sale-price\").text();\n        let weight = $(this).find(\".foxy_variants_item-weight\").text();\n        let inventory = $(this).find(\".foxy_variants_item-inventory\").text()\n          ? $(this).find(\".foxy_variants_item-inventory\").text()\n          : \"0\";\n        let image = $(this).find(\".foxy_variants_item-image\").attr(\"src\");\n        let code = $(this).find(\".foxy_variants_item-sku\").text();\n        let strain = $(this).find(\".foxy_variants_item-strain\").text();\n        let size = $(this).find(\".foxy_variants_item-size\").text();\n        let flavor = $(this).find(\".foxy_variants_item-flavor\").text();\n        let strength = $(this).find(\".foxy_variants_item-strength\").text();\n        let type = $(this).find(\".foxy_variants_item-type\").text();\n        let allowBackorders = $(this).find(\".foxy_variants_item-allow-backorders\").text();\n        const restrictedShipping = $(this).find(\".foxy_variants_item-restricted-shipping\").text();\n        const itemCertification = $(this).find(\".foxy_variants_item-certification-link\").prop(\"href\")\n          ? $(this).find(\".foxy_variants_item-certification-link\").prop(\"href\")\n          : \"none\";\n        const wholesale = {\n          available: $(this).find(\".foxy_variants_item-wholesale-availability\").text(),\n          tier1: $(this).find(\".foxy_variants_item-wholesale-tier1\").text(),\n          tier2: $(this).find(\".foxy_variants_item-wholesale-tier2\").text(),\n          tier3: $(this).find(\".foxy_variants_item-wholesale-tier3\").text(),\n          msrp: $(this).find(\".foxy_variants_item_msrp\").text(),\n          tier1_baseunit: $(this).find(\".foxy_variants_item-base-unit-cost_tier1\").text(),\n          tier2_baseunit: $(this).find(\".foxy_variants_item-base-unit-cost_tier2\").text(),\n          tier3_baseunit: $(this).find(\".foxy_variants_item-base-unit-cost_tier3\").text(),\n          units_per_case: $(this).find(\".foxy_variants_item-wholesale-units-per-case\").text(),\n        };\n        let currentProduct = [\n          name,\n          strain,\n          size,\n          flavor,\n          strength,\n          type,\n          code,\n          image,\n          inventory,\n          weight,\n          salePrice,\n          price,\n          allowBackorders,\n          restrictedShipping,\n          itemCertification,\n          wholesale,\n        ];\n\n        if (currentProduct.includes(variantSelection)) {\n          availableProductsPerVariant.push(\n            filterEmpty({\n              name,\n              strain: strain,\n              size: size,\n              flavor: flavor,\n              strength: strength,\n              type: type,\n              code: code,\n              image: image,\n              inventory: inventory,\n              weight: weight,\n              salePrice: salePrice,\n              price: price,\n              allowBackorders: allowBackorders,\n              restrictedShipping: restrictedShipping,\n              itemCertification: itemCertification,\n              wholesale,\n            })\n          );\n        }\n      });\n      updateVariantOptions(availableProductsPerVariant, variantSelectionGroup);\n      updateProductInfo(availableProductsPerVariant);\n    }\n\n    function handleQuantityChange() {\n      const { inventory, allowBackorders, wholesale } = !variantItems.length\n        ? productItemObject\n        : selectedProductVariantInfo;\n      const quantity = element.querySelector(\"input[name=quantity]\").value;\n      const submitButton = element.querySelector(\"#foxy-form input[type=submit]\");\n\n      if (isWholesale && isWholesalePage && wholesale.available === \"false\") {\n        inventoryElement.textContent = \"Unavailable\";\n        inventoryElement?.nextSibling?.style.setProperty(\"display\", \"none\");\n        submitButton.disabled = true;\n        submitButton.style.backgroundColor = \"#37b7728c\";\n        return;\n      }\n      if (isWholesale && isWholesalePage && wholesale.available === \"true\") {\n        inventoryElement.textContent = \"Available\";\n        inventoryElement?.nextSibling?.style.setProperty(\"display\", \"none\");\n        submitButton.disabled = false;\n        submitButton.style.backgroundColor = \"#37b772\";\n        return;\n      }\n\n      if (\n        (Number(inventory) === 0 && allowBackorders === \"false\") ||\n        (Number(quantity) > Number(inventory) && allowBackorders === \"false\")\n      ) {\n        inventoryElement.textContent = \"Out of stock.\";\n        inventoryElement.nextElementSibling.style.display = \"none\";\n        if (element.querySelector(\"input[name=Delayed_shipping]\"))\n          element.querySelector(\"input[name=Delayed_shipping]\").remove();\n        submitButton.disabled = true;\n        submitButton.style.backgroundColor = \"#37b7728c\";\n        return;\n      }\n\n      if (\n        (Number(quantity) > Number(inventory) && allowBackorders === \"true\") ||\n        (Number(inventory) === 0 && allowBackorders === \"true\")\n      ) {\n        inventoryElement.textContent = \"Item Available for Backorder.\";\n        inventoryElement.classList.remove(\"margin-top-1-5\");\n        inventoryElement.nextElementSibling.style.display = \"none\";\n        element.querySelector(`input[name=\"quantity_max\"]`).value = \"\";\n        element\n          .querySelector(\"#foxy-form .w-embed\")\n          .insertAdjacentHTML(\n            \"beforeend\",\n            `<input type=\"hidden\" name=\"Delayed_shipping\" value=\"Item Available for Backorder.\">`\n          );\n        submitButton.disabled = false;\n        submitButton.style.backgroundColor = \"#37b772\";\n        return;\n      }\n      if (Number(quantity) <= Number(inventory)) {\n        inventoryElement.textContent = inventory;\n        inventoryElement.nextSibling.style.display = \"inline\";\n        if (element.querySelector(\"input[name=Delayed_shipping]\"))\n          element.querySelector(\"input[name=Delayed_shipping]\").remove();\n        submitButton.disabled = false;\n        submitButton.style.backgroundColor = \"#37b772\";\n        return;\n      }\n    }\n\n    function updateVariantOptions(availableProductsPerVariant, variantSelectionGroup) {\n      const otherVariantGroups = variantGroups.filter(\n        variantGroup => variantGroup !== variantSelectionGroup\n      );\n\n      otherVariantGroups.forEach(otherGroup => {\n        // Check if other groups have selections\n        const otherGroupParent = element.querySelector(`#variants-${otherGroup.toLowerCase()}`);\n        let hasSelection = null;\n        if (otherGroupParent) {\n          hasSelection = element\n            .querySelector(`#variants-${otherGroup.toLowerCase()}`)\n            .classList.contains(\"option-selected\");\n        }\n\n        //Get all values from other groups / remove all dashes\n        const otherGroupInputsValues = [];\n        element.querySelectorAll(`input[name=${otherGroup}]`).forEach(input => {\n          otherGroupInputsValues.push(input.value);\n          input.parentElement.classList.remove(RADIO_DISABLED);\n        });\n\n        const availableProductNames = availableProductsPerVariant.map(\n          e => e[otherGroup.toLowerCase()]\n        );\n\n        const unavailableOptions = otherGroupInputsValues.filter(\n          value => availableProductNames.indexOf(value) == -1\n        );\n\n        unavailableOptions.forEach(option => {\n          element\n            .querySelector(`input[value=\"${option}\"]`)\n            .parentElement.classList.add(RADIO_DISABLED);\n            \n        });\n\n        if (hasSelection && unavailableOptions.length !== 0) {\n          unavailableOptions.forEach(option => {\n            const unavailableElement = element.querySelector(`input[value=\"${option}\"]:checked`);\n            if (unavailableElement) {\n              unavailableElement.checked = false;\n              unavailableElement.parentElement.classList.add(RADIO_DISABLED);\n              unavailableElement.previousElementSibling.classList.remove(\"w--redirected-checked\");\n              unavailableElement.parentElement.parentElement.classList.remove(\"option-selected\");\n            }\n          });\n        }\n      });\n    }\n\n    function updateProductInfo(availableProductsPerVariant) {\n      if (isVariantsSelectionComplete()) {\n        // Hide Range Price\n        priceLowElement.parentElement.style.display = \"none\";\n\n        // Save the selected product variant\n        let selectedProductVariant = {};\n        element.querySelectorAll(\"#foxy-form input:checked\").forEach(variant => {\n          selectedProductVariant[variant.name] = variant.value;\n        });\n\n        // Find Selected Product Variant Total Information\n        selectedProductVariantInfo = availableProductsPerVariant.find(product => {\n          let isProduct = [];\n          Object.keys(selectedProductVariant).forEach(key => {\n            product[key.toLowerCase()] === selectedProductVariant[key]\n              ? isProduct.push(true)\n              : isProduct.push(false);\n          });\n          return isProduct.every(productCheck => productCheck === true);\n        });\n\n        // Notify subscription widget — fires BEFORE price input is updated below\n        // so the widget reads the price from selectedProductVariantInfo directly\n        // via the event detail rather than input[name=price] (which hasn't changed yet).\n        document.dispatchEvent(new CustomEvent('dgc:variantSelected', {\n          detail: { variant: selectedProductVariantInfo }\n        }));\n\n        // Update Hidden Add to Cart Inputs with Variant Data and\n        //DOM customer facing elements with product info\n        Object.keys(selectedProductVariantInfo).forEach(key => {\n          const inputToUpdate = element.querySelector(`input[name=\"${key}\"]`);\n          if (inputToUpdate) inputToUpdate.value = selectedProductVariantInfo[key];\n\n          switch (key) {\n            case \"inventory\":\n              // Update max quantity\n              /*\n              if (!isWholesale || !isWholesalePage) {\n                element.querySelector(`input[name=\"quantity_max\"]`).value =\n                  selectedProductVariantInfo[\"inventory\"];\n              }\n                  */\n              handleQuantityChange();\n              break;\n            case \"price\":\n              if (isWholesale && isWholesalePage) {\n                const wholesalePrice = selectedProductVariantInfo.wholesale[isWholesaler()];\n                priceAddToCart.value = wholesalePrice;\n                activePriceElement.textContent = wholesalePrice;\n                activePriceElement.parentElement.style.display = \"inline-block\";\n                activePriceElement.classList.remove(\"w-dyn-bind-empty\");\n                break;\n              }\n              if (selectedProductVariantInfo[\"salePrice\"]) {\n                priceAddToCart.value = selectedProductVariantInfo[\"salePrice\"];\n\n                activePriceElement.textContent = getMembershipSpecialPrice(\n                  selectedProductVariantInfo[\"salePrice\"]\n                );\n                beforeSalePriceElement.textContent = hasMembership()\n                  ? selectedProductVariantInfo[\"salePrice\"]\n                  : selectedProductVariantInfo[key];\n\n                activePriceElement.classList.remove(\"w-dyn-bind-empty\");\n                beforeSalePriceElement.classList.remove(\"w-dyn-bind-empty\");\n                activePriceElement.parentElement.style.display = \"inline-block\";\n                beforeSalePriceElement.parentElement.style.display = \"inline-block\";\n                break;\n              }\n              beforeSalePriceElement.parentElement.style.display = hasMembership()\n                ? \"inline-block\"\n                : \"none\";\n              activePriceElement.textContent = getMembershipSpecialPrice(\n                selectedProductVariantInfo[key]\n              );\n              activePriceElement.parentElement.style.display = \"inline-block\";\n              activePriceElement.classList.remove(\"w-dyn-bind-empty\");\n              break;\n            case \"image\":\n              element.querySelector(\"#foxy-image\").src = selectedProductVariantInfo[key];\n              break;\n            case \"restrictedShipping\":\n              element.querySelector(\"input[name=Restricted_Shipping]\").value =\n                selectedProductVariantInfo[key];\n              break;\n            case \"restrictedShippingCode\":\n              element.querySelector(\"input[name=Restricted_Shipping_Code]\").value =\n                selectedProductVariantInfo[key];\n              break;\n            case \"itemCertification\":\n              const certification = element.querySelector(\".product_quickview_certification-link\");\n              if (selectedProductVariantInfo[key] === \"none\") {\n                certification.style.display = \"none\";\n              }\n              certification.href = selectedProductVariantInfo[key];\n              certification.style.display = \"block\";\n              break;\n            case \"wholesale\":\n              if (isWholesale && isWholesalePage) {\n                const wholesaleTier = isWholesaler();\n                const baseUnitForTier =\n                  selectedProductVariantInfo.wholesale[`${wholesaleTier}_baseunit`];\n                wholesaleDollarPerUnit.textContent = baseUnitForTier;\n                const unitsPerCase = selectedProductVariantInfo.wholesale[\"units_per_case\"];\n\n                const casePrice = Number(unitsPerCase) * Number(baseUnitForTier);\n                wholesaleDollarPerCase.textContent = casePrice.toFixed(2);\n\n                wholesaleMSRP.textContent = selectedProductVariantInfo.wholesale.msrp;\n                wholesaleUnitsPerCase.textContent = unitsPerCase;\n\n                // show dollar sign\n                wholesaleMSRP.previousElementSibling.style.display = \"inline-block\";\n                wholesaleDollarPerUnit.previousElementSibling.style.display = \"inline-block\";\n                wholesaleDollarPerCase.previousElementSibling.style.display = \"inline-block\";\n\n                // Update wholesale-unit-case\n                if (unitsPerCase)\n                  element.querySelector(`input[type=\"hidden\"][name=\"wholesale-case-count\"]`).value =\n                    unitsPerCase;\n              }\n              break;\n          }\n        });\n        return;\n      }\n\n      // Selection is no longer complete — notify subscription widget to revert price\n      document.dispatchEvent(new CustomEvent('dgc:variantCleared'));\n\n      if (isWholesale && isWholesalePage) {\n        addPriceWholesale(isWholesaler());\n      } else {\n        addPrice();\n      }\n\n      setInventory();\n      const certification = element.querySelector(\".product_quickview_certification-link\");\n      if (productItemObject[\"itemCertification\"] === \"none\") {\n        certification.style.display = \"none\";\n        return;\n      }\n      certification.href = productItemObject[\"itemCertification\"];\n      certification.style.display = \"block\";\n    }\n    // Utilities / helper functions --\n\n    /* @return {boolean || string} \n      returns the value of the attribute of the specified name, false if it doesn't exist\n    */\n    function isWholesaler() {\n      const wholesale = \"wholesale_tier\";\n      return FC.custom.getAttributeByName(wholesale);\n    }\n\n    function hasMembership() {\n      return (\n        FC.custom.hasSubscriptionByCode(\"dragon-slayer\") ||\n        FC.custom.hasSubscriptionByCode(\"dragon-master\")\n      );\n    }\n\n    function filterEmpty(obj) {\n      return Object.entries(obj).reduce((a, [k, v]) => (v ? ((a[k] = v), a) : a), {});\n    }\n\n    function capitalizeFirstLetter(string) {\n      return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();\n    }\n\n    function isVariantsSelectionComplete() {\n      if (element.querySelector(\"#foxy-form\").querySelectorAll(\"[required]:invalid\").length === 0) {\n        return true;\n      }\n      return false;\n    }\n\n    function getMembershipSpecialPrice(priceToDiscountFrom) {\n      // If it has subscription then return the discounted rate add discount text, else return the same rate\n      const hasDragonSlayerSub = FC.custom.hasSubscriptionByCode(\"dragon-slayer\");\n      const hasDragonMasterSub = FC.custom.hasSubscriptionByCode(\"dragon-master\");\n      const percentFromAmmount = (amount, percent) => (amount * percent) / 100;\n      const handlePriceDiscount = (priceToDiscountFrom, discountPercent, membershipName) => {\n        const ammountToDiscount = percentFromAmmount(priceToDiscountFrom, discountPercent);\n        if (!element.querySelector(\"#membership-discount-label-applied\")) {\n          element\n            .querySelector(\".product-price_component\")\n            .insertAdjacentHTML(\n              \"afterend\",\n              `<div class=\"margin-top-1-5\" id=\"membership-discount-label-applied\"><strong>${membershipName} membership discount applied.</strong></div>`\n            );\n        }\n        return (priceToDiscountFrom - ammountToDiscount).toFixed(2);\n      };\n      if (hasDragonSlayerSub) {\n        return handlePriceDiscount(priceToDiscountFrom, 5, \"DragonSlayer\");\n      }\n      if (hasDragonMasterSub) {\n        return handlePriceDiscount(priceToDiscountFrom, 10, \"DragonMaster\");\n      }\n      return Number(priceToDiscountFrom).toFixed(2);\n    }\n  })();\n}"]}