"use strict";var core=require("@gem-sdk/core"),system=require("@gem-sdk/system"),_const=require("./common/const.js");const renderOptionValuesNewFormatSwatches=e=>{let{renderVariantItem:s,variantPresetsLiquid:i}=e;return core.template`
    ${system.Liquid("{%- assign optionRendered = false -%}")}
    ${system.Liquid("{%- assign swatches = shop.metafields.GEMPAGES.swatchesJSONFormat.value -%}")}

    ${system.Liquid(`{% for swatch in swatches %}
      {%- assign optionTitle = swatch.optionTitle -%}
      {%- assign optionType = swatch.optionType -%}
      {%- assign labelsString = "" -%}
      {%- assign colorArraysString = "" -%}
      {%- assign imageUrlsString = "" -%}

      {% for optionValue in swatch.optionValues %}
        {%- assign labelsString = labelsString | append: optionValue.label | append: '${_const.OPTION_VALUES_DELIMITER}' -%}
        {%- assign colorsJoined = optionValue.colors | join: '${_const.OPTION_VALUES_DELIMITER}' -%}
        {%- assign colorArraysString = colorArraysString | append: colorsJoined | append: '${_const.OPTION_VALUES_DELIMITER}' -%}
        {%- assign imageUrlsString = imageUrlsString | append: optionValue.imageUrl | append: '${_const.OPTION_VALUES_DELIMITER}' -%}
      {% endfor %}

      {%- assign labels = labelsString | split: '${_const.OPTION_VALUES_DELIMITER}' | slice: 0, labelsString.size -%}
      {%- assign colorStrings = colorArraysString | split: '${_const.OPTION_VALUES_DELIMITER}' | slice: 0, colorArraysString.size -%}
      {%- assign imageUrls = imageUrlsString | split: '${_const.OPTION_VALUES_DELIMITER}' | slice: 0, imageUrlsString.size -%}

      {% if optionTitle == option.name %}
        {%- assign variantPresetString = "${i}" -%}
        {%- assign optionName = option.name | replace: "'", "&apos;" | replace: '"', "&quot;" -%}
        {%- assign items = variantPresetString | split: '($2)' -%}
        {%- assign type = 'dropdown' -%}

        {% for item in items %}
          {%- assign itemPreset = item | split: '($1)' -%}
          {% if itemPreset[0] == optionName %}{%- assign type = itemPreset[1] -%}{% endif %}
          {% if itemPreset[0] == 'base' %}{%- assign type = itemPreset[1] -%}{% endif %}
        {% endfor %}
        {%- assign optionRendered = true -%}

        ${s({showDropdown:!0})}
      {% endif %}
    {% endfor %}`)}

    ${system.LiquidIf("optionRendered == false",s({showDropdown:!1,isRenderDefault:!0,typeOfOption:"optionType"}))}
  `};exports.renderOptionValuesNewFormatSwatches=renderOptionValuesNewFormatSwatches;
