<!DOCTYPE html>
<html dir="<?php echo $direction; ?>" lang="<?php echo $lang; ?>">
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <?php if ($description) { ?>
      <meta name="description" content="<?php echo $description; ?>" />
    <?php } ?>
    <?php if ($keywords) { ?>
      <meta name="keywords" content="<?php echo $keywords; ?>" />
    <?php } ?>
    <?php if (!isset($this->request->get['route']) || $this->request->get['route']=='common/home') { ?>
      <meta property="og:url"         content="<?php echo $base; ?>" />
      <meta property="og:type"        content="website" />
      <meta property="og:locale"      content="<?php echo $lang; ?>" />
      <meta property="og:title"       content="<?php echo $title; ?>" />
      <meta property="og:description" content="<?php echo $description; ?>" />
      <meta property="og:image"       content="<?php echo $logo['jpg']; ?>" />
    <?php } ?>
    <meta name="theme-color" content="<?php echo $this->config->get('wg24_btn_1bg_col')?>">
    <meta name="apple-mobile-web-app-status-bar-style" content="<?php echo $this->config->get('wg24_btn_1bg_col')?>">
    <meta name="msapplication-navbutton-color" content="<?php echo $this->config->get('wg24_btn_1bg_col')?>">
    <title><?php echo $title; ?></title>
    <base id="base-urls" href="<?php echo $base ?>" data-base-url-loja="<?php echo $base ?>">
    <script>
      Object.freeze(console);
    </script>

    <?php if ($icon) { ?>
      <link href="<?php echo $icon; ?>" rel="icon" />
    <?php } ?>
    <?php foreach ($links as $link) { ?>
      <link href="<?php echo $link['href']; ?>" rel="<?php echo $link['rel']; ?>" />
    <?php } ?>

    <?php foreach ($propertys as $property) { ?>
      <meta property="<?php echo $property['property']; ?>" content="<?php echo $property['content']; ?>" />
    <?php } ?>

    <meta name="robots" content="INDEX,FOLLOW">

    <?php foreach ($styles as $style) { ?>
      <link href="<?php echo $style['href']; ?>" rel="<?php echo $style['rel']; ?>" media="none" onload="this.media='all'">
      <noscript>
        <link href="<?php echo $style['href']; ?>" rel="<?php echo $style['rel']; ?>">
      </noscript>
    <?php } ?>

    <script src="<?php echo $lab; ?>"></script>
    <script>
      $LAB.setGlobalDefaults({AlwaysPreserveOrder:true});
      var base =  document.querySelector('base');
      if (base && base.href) {
        $LAB.setGlobalDefaults({AlwaysPreserveOrder:true, BasePath: base.href });
      }

      // CustomEvent polyfill
      (function () {
        if (typeof window.CustomEvent === "function") return false;

        function CustomEvent(event, params) {
          params = params || { bubbles: false, cancelable: false, detail: undefined };
          var evt = document.createEvent('CustomEvent');
          evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
          return evt;
        }

        CustomEvent.prototype = window.Event.prototype;
        window.CustomEvent = CustomEvent;
      })();

      // Dispara os eventos
      function triggerEvent(eventName) {
        var EVENT = new CustomEvent(eventName);
        window.dispatchEvent(EVENT);
      }

      /* Trabalha em conjunto com o arquivo 'dispatch-event-load-scripts.js' */
      window.scriptsLoaded = false;
      window.windowLoaded = false;
      window.documentReaded = false;

      // Indica se a janela foi carregada
      window.addEventListener('load', function () {
        window.windowLoaded = true;
        triggerEvent('window');
      });

      // Indica se o documento foi lido
      if (document.addEventListener) {
        document.addEventListener('DOMContentLoaded', function(){
          triggerEvent('document');
          window.documentReaded = true;
        });
      } else {
        document.attachEvent('onreadystatechange', function(){
          if (document.readyState=='complete') {
            triggerEvent('document');
            window.documentReaded = true;
          }
        });
      }

      // Mostra os eventos no console
      // window.addEventListener('scripts_document', function () {
      //   console.log('scripts_document');
      // });
      // window.addEventListener('scripts_window', function () {
      //   console.log('scripts_window');
      // });
      // window.addEventListener('scripts', function () {
      //   console.log('scripts');
      // });

      // Executa a função se o evento já foi disparado
      // ou atribui a função para ser executada no disparo do evento
      window.waitEvent = function(event, func) {
        switch (event) {
          case 'scripts':
            if (window.scriptsLoaded) {
              func();
            } else {
              window.addEventListener('scripts', function () {
                func();
              });
            }
            break;
          case 'document':
            if (window.documentReaded) {
              func();
            } else {
              window.addEventListener('document', function () {
                func();
              });
            }
            break;
          case 'scripts_document':
            if (window.documentReaded && window.scriptsLoaded) {
              func();
            } else {
              window.addEventListener('scripts_document', function () {
                func();
              });
            }
            break;
          case 'window':
            if (window.windowLoaded) {
              func();
            } else {
              window.addEventListener('window', function () {
                func();
              });
            }
            break;
          case 'scripts_window':
            if (window.windowLoaded && window.scriptsLoaded) {
              func();
            } else {
              window.addEventListener('scripts_window', function () {
                func();
              });
            }
            break;
          default:
            console.error('FUTURA - Evento inválido');
            break;
        }
      }

      var scripts = <?php echo json_encode($scripts) ?>;
      if (scripts) {
        for (var key in scripts) {
          if (scripts.hasOwnProperty(key)) {
            $LAB.setOptions({AllowDuplicates:true}).script(scripts[key]).wait();
          }
        }
      }
    </script>

    <script type="application/ld+json">
    {
      "@context": "http://schema.org",
      "@type": "WebSite",
      "url": "<?php echo $base; ?>",
      "potentialAction": {
        "@type": "SearchAction",
        "target": "<?php echo $base; ?>index.php?route=product/search&search={query}",
        "query-input": "required name=query"
      }
    }
    </script>

    <?php
      $fontsArray = array();
      if($this->config->get('wg24_body_font_source')=="google") {
        $fontName = $this->config->get("wg24_body_fontto_google");
        array_push($fontsArray, str_replace(' ', '+', substr($fontName, 0, (strrpos($fontName, ',')) ? strrpos($fontName, ',') : strlen($fontName))).':400,700');
      } else{
        $fontName = $this->config->get("wg24_body_fontto_system");
        array_push($fontsArray, str_replace(' ', '+', substr($fontName, 0, (strrpos($fontName, ',')) ? strrpos($fontName, ',') : strlen($fontName))).':400,700');
      }
      if($this->config->get('wg24_header_font_source')=="google"){
        $fontName = $this->config->get("wg24_header_fontto_google");
        array_push($fontsArray, str_replace(' ', '+', substr($fontName, 0, (strrpos($fontName, ',')) ? strrpos($fontName, ',') : strlen($fontName))).':400,700');
      } else{
        $fontName = $this->config->get("wg24_header_fontto_system");
        array_push($fontsArray, str_replace(' ', '+', substr($fontName, 0, (strrpos($fontName, ',')) ? strrpos($fontName, ',') : strlen($fontName))).':400,700');
      }

      $fontsArray = array_unique($fontsArray);
      $fontsArray = array_filter($fontsArray, function($item) {
        return strpos($item, 'servidor n') == false;
      });
    ?>

    <link href="https://fonts.googleapis.com/css?family=<?php echo implode('|', $fontsArray) ?>" rel="stylesheet" media="none" onload="this.media='all'">
    <noscript>
      <link href="https://fonts.googleapis.com/css?family=<?php echo implode('|', $fontsArray) ?>" rel="stylesheet">
    </noscript>

    <style type="text/css">
      body,
      input,
      textarea,
      select,
      button {
        font-family: <?php if($this->config->get('wg24_body_font_source') == "google") {
          echo str_replace('+', ' ', $this->config->get('wg24_body_fontto_google')).', sans-serif';
        } else {
          echo str_replace('+', ' ', $this->config->get('wg24_body_fontto_system'));
        } ?>;
      }

      [class*="heading-"],
      [class^="heading-"] {
        font-family: <?php if($this->config->get('wg24_header_font_source') == "google") {
          echo str_replace('+', ' ', $this->config->get('wg24_header_fontto_google')).', sans-serif';
        } else {
          echo str_replace('+', ' ', $this->config->get('wg24_header_fontto_system'));
        } ?>;
        text-transform: <?php echo $this->config->get('wg24_heading_transfrom')?>;
        color:<?php echo $this->config->get('wg24_l_header_color')?>;
        font-weight: normal;
      }

      <?php if(isset($wg24_l_add_custom_css)){
        echo html_entity_decode($wg24_l_add_custom_css[$default_lang]);
      } ?>

      <?php if($this->config->get('config_rating_status')=="0") { ?>
        .inner .ratings .rating-box { display:none !important; }
      <?php } ?>

      body {
        color:<?php echo $this->config->get('wg24_l_body_fc'); ?>;
        <?php if($this->config->get('wg24_backgroun_image_show')=="enable") { ?>
          <?php if($this->config->get('wg24_body_cus_pattan')) { ?>
            background: url("<?php  echo  $base.'image/'.$this->config->get('wg24_body_cus_pattan')?>") <?php echo $this->config->get('wg24_bg_repeat')?> <?php echo $this->config->get('wg24_bg_attachment')?> <?php echo $this->config->get('wg24_bg_positin')?> <?php echo $this->config->get('wg24_l_bodyb')?>;
          <?php } else { ?>
            background: url("catalog/view/theme/vista/image/theme_patterns/<?php echo $this->config->get('we24_default_parttern')?>.png") <?php echo $this->config->get('wg24_bg_repeat')?> <?php echo $this->config->get('wg24_bg_attachment')?> <?php echo $this->config->get('wg24_bg_positin')?> <?php echo $this->config->get('wg24_l_bodyb')?>;
          <?php } ?>
        <?php } ?>
        background-color:<?php echo $this->config->get('wg24_l_bodyb')?>;
      }

      .heading-1 {
        font-size: <?php echo $font_size['title_product']['mobile']['font_size'] ?>;
        line-height: <?php echo $font_size['title_product']['mobile']['line_height'] ?>;
      }
      .heading-2 {
        font-size: <?php echo $font_size['title_page']['mobile']['font_size'] ?>;
        line-height: <?php echo $font_size['title_page']['mobile']['line_height'] ?>;
      }
      .heading-3 {
        font-size: <?php echo $font_size['title_aside']['mobile']['font_size'] ?>;
        line-height: <?php echo $font_size['title_aside']['mobile']['line_height'] ?>;
      }
      /* 768px */
      @media only screen and (min-width: 48em) {
        .heading-1 {
          font-size: <?php echo $font_size['title_product']['tablet']['font_size'] ?>;
          line-height: <?php echo $font_size['title_product']['tablet']['line_height'] ?>;
        }
        .heading-2 {
          font-size: <?php echo $font_size['title_page']['tablet']['font_size'] ?>;
          line-height: <?php echo $font_size['title_page']['tablet']['line_height'] ?>;
        }
        .heading-3 {
          font-size: <?php echo $font_size['title_aside']['tablet']['font_size'] ?>;
          line-height: <?php echo $font_size['title_aside']['tablet']['line_height'] ?>;
        }
      }
      /* 992px */
      @media only screen and (min-width: 62em) {
        .heading-1 {
          font-size: <?php echo $font_size['title_product']['desktop']['font_size'] ?>;
          line-height: <?php echo $font_size['title_product']['desktop']['line_height'] ?>;
        }
        .heading-2 {
          font-size: <?php echo $font_size['title_page']['desktop']['font_size'] ?>;
          line-height: <?php echo $font_size['title_page']['desktop']['line_height'] ?>;
        }
        .heading-3 {
          font-size: <?php echo $font_size['title_aside']['desktop']['font_size'] ?>;
          line-height: <?php echo $font_size['title_aside']['desktop']['line_height'] ?>;
        }
      }

      #header {
        background-color: <?php echo $header_bg_color ?>;
        border-bottom: 1px solid #DDD;
        height: 132px;
        padding: 16px;
        text-align: center;
      }
      .radio-entry:checked + .radio-text::before,
      .checkbox-entry:checked + .checkbox-text::before,
      .btn-primary {
        background-color: <?php echo $buttom_bg_color ?>!important;
        color: <?php echo $buttom_color ?>!important;
      }
      a {
        color: <?php echo $link_color ?>!important;
      }
      .logo img {
        height: 100%;
        width: auto;
      }
    </style>

    <?php
      if ($this->config->get('wg24_seo_fer_facebook_status')=='enable'){
        if (!$this->config->get('wg24_seo_fer_facebook_pixel')==''){
          echo html_entity_decode($this->config->get('wg24_seo_fer_facebook_pixel'), ENT_QUOTES, 'UTF-8');
        }
      }
    ?>

    <?php echo $scripts_top; ?>

  </head>
  <body itemscope itemtype="http://schema.org/WebPage">
    <div class="notifications js-notifications"></div>

      <header id="header">
        <?php
          $this->language->load('common/extra_oc_lang');
        ?>

        <?php if ($logo) { ?>
          <a href="<?php echo $home; ?>" title="<?php echo $name; ?>" class="logo">
            <picture>
              <?php if($logo_responsivo) { ?>
                <source media="(max-width: 768px)" srcset="<?php echo str_replace(' ', '%20', $logo_responsivo); ?>">
              <?php } ?>
              <source srcset="<?php echo str_replace(' ', '%20', $logo['webp']); ?>">
              <img src="<?php echo str_replace(' ', '%20', $logo['jpg']); ?>" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" itemprop="image" width="<?php echo $logo_original_width ?>" height="<?php echo $logo_original_height ?>">
            </picture>
          </a>
        <?php } ?>
      </header>

      <?php if ($error) { ?>
        <div class="warning">
          <span><?php echo $error_warning; ?>
            <i class="btn-close fas fa-times" aria-hidden="true"></i>
          </span>
        </div>
      <?php } ?>