// source --> https://portugal-vinho.de/wp-content/plugins/dispensary-age-verification/public/js/dispensary-age-verification-public.js?ver=3.0.1 
/**
 * AVWP Public JS
 * 
 * Age Verification for WordPress utilizes the following open source javascript plugin. Thanks Michael!
 *
 * Plugin: ageCheck.js
 * Description: A simple plugin to verify user's age. Uses sessionStorage API to store if user is verified - only kept until browser is closed.
 * Options can be passed for easy customization.
 * Author: Michael Soriano
 * Author's website: http://fearlessflyer.com
 *
 */
(function ($) {
  "use strict";
  $.ageCheck = function (options) {
    const settings = $.extend({
      bgImage: '',
      minAge: 18,
      redirectTo: "",
      redirectOnFail: "",
      title: "Age Verification",
      copy: "You must be [age] years old to enter.",
      btnYes: "YES",
      btnNo: "NO",
      successTitle: "Success!",
      successText: "You are now being redirected back to the site...",
      successMessage: "show",
      failTitle: "Sorry",
      failText: "You are not old enough to view this site...",
      failMessage: "show",
      cookieDays: 30,
      adminDebug: "",
      beforeContent: "",
      afterContent: "",
      logoHeight: "",
      logoWidth: "",
    }, options);

    const _this = {
      age: "",
      errors: [],
      setValues() {
        const month = $(".avwp-av .month").val();
        const day = $(".avwp-av .day").val();
        _this.month = month;
        _this.day = day.replace(/^0+/, ""); // remove leading zero
        _this.year = $(".avwp-av .year").val();
      },
      validate() {
        _this.errors = [];
        if (/^([0-9]|[12]\d|3[0-1])$/.test(_this.day) === false) {
          _this.errors.push("Day is invalid or empty");
        }
        if (/^(19|20)\d{2}$/.test(_this.year) === false) {
          _this.errors.push("Year is invalid or empty");
        }
        _this.clearErrors();
        _this.displayErrors();
        return _this.errors.length < 1;
      },
      clearErrors() {
        $(".errors").html("");
      },
      displayErrors() {
        let html = "<ul>";
        for (let i = 0; i < _this.errors.length; i++) {
          html += `<li><span>x</span>${_this.errors[i]}</li>`;
        }
        html += "</ul>";
        setTimeout(() => {
          $(".avwp-av .errors").html(html);
        }, 200);
      },
      reCenter(b) {
        b.css("top", `${Math.max(0, (($(window).height() - (b.outerHeight() + 150)) / 2))}px`);
        b.css("left", `${Math.max(0, (($(window).width() - b.outerWidth()) / 2))}px`);
      },
      buildHtml() {
        const copy = settings.copy;
        let html = "";
        html += "<div class=\"avwp-av-overlay\"></div>";
        html += "<div class=\"avwp-av\">";
        if (settings.beforeContent !== "") {
          html += settings.beforeContent;
        }
        if (settings.imgLogo !== "") {
          html += "<img src=\"" + settings.imgLogo + "\" alt=\"" + settings.title + "\" width=\"" + settings.logoWidth + "\" height=\"" + settings.logoHeight + "\" />";
        }
        if (settings.title !== "") {
          html += `<h2>${settings.title}</h2>`;
        }
        html += `<p>${copy.replace("[age]", `<strong>${settings.minAge}</strong>`)}`; + `</p>`;
        html += `<p><button class="yes">${settings.btnYes}</button><button class="no">${settings.btnNo}</button></p>`;
        if (settings.afterContent !== "") {
          html += settings.afterContent;
        }
        html += "</div></div>";
        $("body").append(html);

        $(".avwp-av-overlay").animate({
          opacity: 1,
        }, 500, () => {
          _this.reCenter($(".avwp-av"));
          $(".avwp-av").css({
            opacity: 1,
          });
        });

        $(".avwp-av .day, .avwp-av .year").focus(function () {
          $(this).removeAttr("placeholder");
        });
      },
      setAge() {
        _this.age = "";
        _this.age = Math.abs(Date.now() - 1970);
      },
      setSessionStorage(key, val) {
        try {
          sessionStorage.setItem(key, val);
          return true;
        } catch (e) {
          return false;
        }
      },
      handleSuccess() {
        const successMsg = `<h2>${settings.successTitle}</h2><p>${settings.successText}</p>`;
        if (settings.messageTime != 0) {
          $(".avwp-av").html(successMsg);
        }
        setTimeout(() => {
          $(".avwp-av").animate({
            top: "-350px",
          }, settings.successTime, () => {
            $(".avwp-av-overlay").animate({
              opacity: "0",
            }, settings.messageTime, () => {
              if (settings.redirectTo !== "") {
                window.location.replace(settings.redirectTo);
              } else {
                $(".avwp-av-overlay, .avwp-av").remove();
              }
            });
          });
        }, settings.messageTime);
      },
      handleUnderAge() {
        const underAgeMsg = `<h2>${settings.failTitle}</h2><p>${settings.failText}</p>`;
        $(".avwp-av").html(underAgeMsg);
        if (settings.redirectOnFail !== "") {
          setTimeout(() => {
            window.location.replace(settings.redirectOnFail);
          }, settings.messageTime);
        }
      },
    }; // end _this

    // Check for cookie and reture false if it's set.
    var cookiereader = readCookie("age-verification");
    if (cookiereader) {
      if (settings.adminDebug !== "") {
        eraseCookie("age-verification");
      } else {
        return false;
      }
    }

    // Create pop up.
    _this.buildHtml();

    // Successful "YES" button click.
    $(".avwp-av button.yes").on("click", () => {
      createCookie("age-verification", "true", settings.cookieDays);
      _this.handleSuccess();
    });

    // Successful "NO" button click.
    $(".avwp-av button.no").on("click", () => {
      _this.handleUnderAge();
    });

    $(window).resize(() => {
      _this.reCenter($(".avwp-av"));
      setTimeout(() => {
        _this.reCenter($(".avwp-av"));
      }, 500);
    });
  };
}(jQuery));

jQuery(document).ready(function($) {
    $.ageCheck({
        "bgImage" : object_name.bgImage,
        "minAge" : object_name.minAge,
        "imgLogo" : object_name.imgLogo,
        "logoWidth" : object_name.logoWidth,
        "logoHeight" : object_name.logoHeight,
        "title" : object_name.title,
        "copy" : object_name.copy,
        "btnYes" : object_name.btnYes,
        "btnNo" : object_name.btnNo,
        "redirectOnFail" : object_name.redirectOnFail,
        "successTitle" : object_name.successTitle,
        "successText" : object_name.successText,
        "successMessage" : object_name.successMessage,
        "failTitle" : object_name.failTitle,
        "failText" : object_name.failText,
        "messageTime" : object_name.messageTime,
        "cookieDays" : object_name.cookieDays,
        "adminDebug" : object_name.adminDebug,
        "beforeContent" : object_name.beforeContent,
        "afterContent" : object_name.afterContent
    });

    if (typeof object_name !== "undefined" && object_name.bgImage) {
        let overlay = document.querySelector(".avwp-av-overlay");
        if (overlay) {
            overlay.style.backgroundImage = `url(${object_name.bgImage})`;
            overlay.style.backgroundRepeat = "no-repeat";
            overlay.style.backgroundPosition = "center";
            overlay.style.backgroundSize = "cover";
            overlay.style.backgroundAttachment = "fixed";
            overlay.style.boxSizing = "border-box";
        }

        let avwpAv = document.querySelector(".avwp-av");
        if (avwpAv) {
            avwpAv.style.boxShadow = "none";
        }
    }
});
// source --> https://portugal-vinho.de/wp-content/plugins/woocommerce/assets/js/js-cookie/js.cookie.min.js?ver=2.1.4-wc.10.6.2 
/*! js-cookie v3.0.5 | MIT */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self,function(){var n=e.Cookies,o=e.Cookies=t();o.noConflict=function(){return e.Cookies=n,o}}())}(this,function(){"use strict";function e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}return function t(n,o){function r(t,r,i){if("undefined"!=typeof document){"number"==typeof(i=e({},o,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var c="";for(var u in i)i[u]&&(c+="; "+u,!0!==i[u]&&(c+="="+i[u].split(";")[0]));return document.cookie=t+"="+n.write(r,t)+c}}return Object.create({set:r,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var t=document.cookie?document.cookie.split("; "):[],o={},r=0;r<t.length;r++){var i=t[r].split("="),c=i.slice(1).join("=");try{var u=decodeURIComponent(i[0]);if(o[u]=n.read(c,u),e===u)break}catch(f){}}return e?o[e]:o}},remove:function(t,n){r(t,"",e({},n,{expires:-1}))},withAttributes:function(n){return t(this.converter,e({},this.attributes,n))},withConverter:function(n){return t(e({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(o)},converter:{value:Object.freeze(n)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"})});