{{ 'section-mega-menu-v4.css' | asset_url | stylesheet_tag }}
{% assign index_number = section.settings.index | append: '' %}

<template xo-mega-menu-name='header-mega-menu-v1' xo-mega-menu-index='{{ index_number }}'>
  <div data-id='{{ section.id }}' {% render 'section-attr' %}>
    {% render 'section-bg-image' %}
    <xo-container>
      <div class='container-header-v8'>
        <xo-grid>
          <div style='--xs: 12; --sm: 12; --lg: 8'>
            <xo-grid style='--col-width: 17rem;'>
              {%- if section.settings.menu_style1 != blank -%}
                <div class='menu-header-v8'>
                  {%- if section.settings.heading_1 != blank -%}
                    <h2 class='menu-header-v8__heading'>{{- section.settings.heading_1 -}}</h2>
                  {%- endif -%}
                  <ul class='menu-header-v8__list-item'>
                    {%- for link in section.settings.menu_style1.links -%}
                      <li class='menu-header-v8__item'>
                        {% if link.title contains '[' %}
                          <a
                            href='{{ link.url }}'
                            title='{{link.title | split: '[' | first }}'
                            class='header-v8-links'
                          >
                            {{- link.title | split: '[' | first }}
                            <span
                              class='header-v8-links__label header-v8-links__label--{{link.title | handleize}}-{{forloop.index}}'
                              {% if link.title contains '(' %}
                                style='background-color: {{link.title | split: '(' | last  | split: ')' | first}}; --border-label:{{link.title | split: '(' | last  | split: ')' | first}};'
                              {% endif %}
                            >
                              <span>{{ link.title | split: '[' | last | split: ']' | first }}</span>
                            </span>

                            <style>
                              .label_menu-{{link.title | handleize}}-{{forloop.index}}:before {
                                border-top: 4px solid {{link.title | split: '(' | last  | split: ')' | first}};
                              }
                            </style>
                          </a>
                        {% else %}
                          <a href='{{ link.url }}' title='{{link.title | split: '[' | first }}'>{{ link.title | split: '[' | first }}</a>
                        {% endif %}
                      </li>
                    {%- endfor -%}
                  </ul>
                </div>
              {%- endif -%}
              {%- if section.settings.menu_style2 != blank -%}
                <div class='menu-header-v8'>
                  {%- if section.settings.heading_2 != blank -%}
                    <h2 class='menu-header-v8__heading'>{{- section.settings.heading_2 -}}</h2>
                  {%- endif -%}
                  <ul class='menu-header-v8__list-item'>
                    {%- for link in section.settings.menu_style2.links -%}
                      <li class='menu-header-v8__item'>
                        {% if link.title contains '[' %}
                          <a
                            href='{{ link.url }}'
                            title='{{link.title | split: '[' | first }}'
                            class='header-v8-links'
                          >
                            {{- link.title | split: '[' | first }}
                            <span
                              class='header-v8-links__label header-v8-links__label--{{link.title | handleize}}-{{forloop.index}}'
                              {% if link.title contains '(' %}
                                style='background-color: {{link.title | split: '(' | last  | split: ')' | first}}; --border-label:{{link.title | split: '(' | last  | split: ')' | first}};'
                              {% endif %}
                            >
                              <span>{{ link.title | split: '[' | last | split: ']' | first }}</span>
                            </span>

                            <style>
                              .label_menu-{{link.title | handleize}}-{{forloop.index}}:before {
                                border-top: 4px solid {{link.title | split: '(' | last  | split: ')' | first}};
                              }
                            </style>
                          </a>
                        {% else %}
                          <a href='{{ link.url }}' title='{{link.title | split: '[' | first }}'>{{ link.title | split: '[' | first }}</a>
                        {% endif %}
                      </li>
                    {%- endfor -%}
                  </ul>
                </div>
              {%- endif -%}
              {%- if section.settings.menu_style3 != blank -%}
                <div class='menu-header-v8'>
                  {%- if section.settings.heading_3 != blank -%}
                    <h2 class='menu-header-v8__heading'>{{- section.settings.heading_3 -}}</h2>
                  {%- endif -%}
                  <ul class='menu-header-v8__list-item'>
                    {%- for link in section.settings.menu_style3.links -%}
                      <li class='menu-header-v8__item'>
                        {% if link.title contains '[' %}
                          <a
                            href='{{ link.url }}'
                            title='{{link.title | split: '[' | first }}'
                            class='header-v8-links'
                          >
                            {{- link.title | split: '[' | first }}
                            <span
                              class='header-v8-links__label header-v8-links__label--{{link.title | handleize}}-{{forloop.index}}'
                              {% if link.title contains '(' %}
                                style='background-color: {{link.title | split: '(' | last  | split: ')' | first}}; --border-label:{{link.title | split: '(' | last  | split: ')' | first}};'
                              {% endif %}
                            >
                              <span>{{ link.title | split: '[' | last | split: ']' | first }}</span>
                            </span>

                            <style>
                              .label_menu-{{link.title | handleize}}-{{forloop.index}}:before {
                                border-top: 4px solid {{link.title | split: '(' | last  | split: ')' | first}};
                              }
                            </style>
                          </a>
                        {% else %}
                          <a href='{{ link.url }}' title='{{link.title | split: '[' | first }}'>{{ link.title | split: '[' | first }}</a>
                        {% endif %}
                      </li>
                    {%- endfor -%}
                  </ul>
                </div>
              {%- endif -%}
              {%- if section.settings.menu_style4 != blank -%}
                <div class='menu-header-v8'>
                  {%- if section.settings.heading_4 != blank -%}
                    <h2 class='menu-header-v8__heading'>{{- section.settings.heading_4 -}}</h2>
                  {%- endif -%}
                  <ul class='menu-header-v8__list-item'>
                    {%- for link in section.settings.menu_style4.links -%}
                      <li class='menu-header-v8__item'>
                        {% if link.title contains '[' %}
                          <a
                            href='{{ link.url }}'
                            title='{{link.title | split: '[' | first }}'
                            class='header-v8-links'
                          >
                            {{- link.title | split: '[' | first }}
                            <span
                              class='header-v8-links__label header-v8-links__label--{{link.title | handleize}}-{{forloop.index}}'
                              {% if link.title contains '(' %}
                                style='background-color: {{link.title | split: '(' | last  | split: ')' | first}}; --border-label:{{link.title | split: '(' | last  | split: ')' | first}};'
                              {% endif %}
                            >
                              <span>{{ link.title | split: '[' | last | split: ']' | first }}</span>
                            </span>

                            <style>
                              .label_menu-{{link.title | handleize}}-{{forloop.index}}:before {
                                border-top: 4px solid {{link.title | split: '(' | last  | split: ')' | first}};
                              }
                            </style>
                          </a>
                        {% else %}
                          <a href='{{ link.url }}' title='{{link.title | split: '[' | first }}'>{{ link.title | split: '[' | first }}</a>
                        {% endif %}
                      </li>
                    {%- endfor -%}
                  </ul>
                </div>
              {%- endif -%}
            </xo-grid>
          </div>
          <div class='menu-v8-image {% if  section.settings.menu_type == 'drawer'%} menu-v8-image-none {% endif %}' style='--xs: 12; --sm: 12; --lg: 4'>
            <a
              href='
                {%- if section.settings.button_link1 != blank -%}
                  {{section.settings.button_link1 }} {%- else -%}
                  https://landing.shopilaunch.com/starter/go/
                {%- endif -%}
              '
            >
              {%- if section.settings.image != blank -%}
                {% render 'image', image: section.settings.image %}
              {%- else -%}
                <img src='https://landing.shopilaunch.com/starter/megamenu_banner.jpg' width='700' height='548' alt=''>
              {%- endif -%}
            </a>
          </div>
        </xo-grid>
      </div>
    </xo-container>
  </div>
</template>

{% schema %}
{
  "name": "t:sections.mega_menu_v4.name",
  "class": "section-mega-menu",
  "settings": [
    {
      "type": "select",
      "id": "index",
      "label": "t:sections.mega_menu_v4.settings.index_number.label",
      "default": "2",
      "options": [
        {
          "value": "0",
          "label": "t:sections.mega_menu_v4.settings.index_number.option_1.label"
        },
        {
          "value": "1",
          "label": "t:sections.mega_menu_v4.settings.index_number.option_2.label"
        },
        {
          "value": "2",
          "label": "t:sections.mega_menu_v4.settings.index_number.option_3.label"
        },
        {
          "value": "3",
          "label": "t:sections.mega_menu_v4.settings.index_number.option_4.label"
        },
        {
          "value": "4",
          "label": "t:sections.mega_menu_v4.settings.index_number.option_5.label"
        },
        {
          "value": "5",
          "label": "t:sections.mega_menu_v4.settings.index_number.option_6.label"
        }
      ]
    },
    {
      "type": "text",
      "id": "heading_1",
      "default": "Quick links",
      "label": "t:sections.mega_menu_v4.settings.heading_1.label"
    },
    {
      "type": "link_list",
      "id": "menu_style1",
      "label": "t:sections.mega_menu_v4.settings.menu_style1.label",
      "info": "t:sections.mega_menu_v4.settings.menu_style1.info"
    },
    {
      "type": "text",
      "id": "heading_2",
      "default": "Quick links",
      "label": "t:sections.mega_menu_v4.settings.heading_2.label"
    },
    {
      "type": "link_list",
      "id": "menu_style2",
      "label": "t:sections.mega_menu_v4.settings.menu_style2.label",
      "info": "t:sections.mega_menu_v4.settings.menu_style2.info"
    },
    {
      "type": "text",
      "id": "heading_3",
      "default": "Quick links",
      "label": "t:sections.mega_menu_v4.settings.heading_3.label"
    },
    {
      "type": "link_list",
      "id": "menu_style3",
      "label": "t:sections.mega_menu_v4.settings.menu_style3.label",
      "info": "t:sections.mega_menu_v4.settings.menu_style3.info"
    },
    {
      "type": "text",
      "id": "heading_4",
      "default": "Quick links",
      "label": "t:sections.mega_menu_v4.settings.heading_4.label"
    },
    {
      "type": "link_list",
      "id": "menu_style4",
      "label": "t:sections.mega_menu_v4.settings.menu_style4.label",
      "info": "t:sections.mega_menu_v4.settings.menu_style4.info"
    },
    {
      "type": "image_picker",
      "id": "image",
      "label": "t:sections.mega_menu_v4.settings.image.label",
      "info": "Support jpg, jpeg, png, svg"
    },
    {
      "type": "url",
      "id": "button_link1",
      "label": "t:sections.mega_menu_v4.settings.button_link1.label"
    },
    {
      "type": "header",
      "content": "t:sections.all.heading.content"
    },
    {
      "type": "color_scheme",
      "id": "color_scheme",
      "label": "t:sections.all.color_scheme.label"
    },
    {
      "type": "color",
      "id": "background_color",
      "label": "t:sections.all.bg_color.label"
    },
    {
      "type": "color_background",
      "id": "background_gradient",
      "label": "t:sections.all.bg_gradient.label"
    },
    {
      "type": "image_picker",
      "id": "background_image_desktop",
      "label": "t:sections.all.background_image_desktop.label"
    },
    {
      "type": "image_picker",
      "id": "background_image_mobile",
      "label": "t:sections.all.background_image_mobile.label"
    },
    {
      "type": "checkbox",
      "id": "use_parallax",
      "label": "t:sections.all.use_parallax.label",
      "default": true
    },
    {
      "type": "number",
      "id": "padding_top",
      "label": "t:sections.all.padding_top.label",
      "default": 50
    },
    {
      "type": "number",
      "id": "padding_bottom",
      "label": "t:sections.all.padding_bottom.label",
      "default": 50
    }
  ],
  "presets": [
    {
      "name": "t:sections.mega_menu_v4.presets.name"
    }
  ]
}
{% endschema %}
