import{Liquid as e,LiquidFor as s,LiquidIf as t}from"@gem-sdk/system";import{template as i}from"@gem-sdk/core";let a=a=>{let{renderVariantItem:n,variantPresetsLiquid:o}=a;return i`
    ${e("{%- assign optionRendered = false -%}")}
    ${e("{%- assign swatches = shop.metafields.GEMPAGES.swatches -%}")}
    ${e("{%- assign swatchesItems = swatches | split: '($1)' -%}")}

    ${e(`{%- assign variantPresetString = "${o}" -%}
      {%- 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 %}`)}

    ${s("swatchesItem in swatchesItems",`
      ${e('{%- assign colorArraysString = "" -%}')}
      ${e('{%- assign labelsString = "" -%}')}
      ${e('{%- assign imageUrlsString = "" -%}')}
      ${e("{%- assign attrItems = swatchesItem | split: '($3)' -%}")}

      ${s("attrItem in attrItems",`
          ${e("{%- assign attrs = attrItem | split: '($2)' -%}")}
          ${e("{%- assign optionKey = attrs[0] -%}")}
          ${e("{%- assign optionValue = attrs[1] -%}")}
          ${e(`
            {% if optionKey == 'optionTitle' %}
              {% assign optionTitle = optionValue %}
            {% elsif optionKey == 'optionType' %}
              {% assign optionType = optionValue %}
            {% endif %}
          `)}

          ${t('optionKey == "optionValues"',`
            ${e("{%- assign opValueItems = optionValue | split: '($4)' -%}")}
            ${s("opValueItem in opValueItems",`
                ${e("{%- assign opValueItemAttrs = opValueItem | split: '($6)' -%}")}
                ${s("opValueItemAttr in opValueItemAttrs",`
                    ${e("{%- assign attrs = opValueItemAttr | split: '($5)' -%}")}
                    ${e("{%- assign opValueItemKey = attrs[0] -%}")}
                    ${e("{%- assign opValueItemValue = attrs[1] -%}")}

                    ${t('opValueItemKey == "label"',`${e("{%- assign labelsString = labelsString | append: opValueItemValue -%}")}
                       ${e('{%- assign labelsString = labelsString | append: "($8)" -%}')}`)}

                    ${t('opValueItemKey == "colors"',`${e("{%- assign colorArraysString = colorArraysString | append: opValueItemValue -%}")}
                       ${e('{%- assign colorArraysString = colorArraysString | append: "($8)" -%}')}`)}

                    ${t('opValueItemKey == "imageUrl"',`${e("{%- assign imageUrlsString = imageUrlsString | append: opValueItemValue -%}")}
                       ${e('{%- assign imageUrlsString = imageUrlsString | append: "($8)" -%}')}`)}
                  `)}
              `)}
            `)}
        `)}

      ${e("{%- assign labels = labelsString | split: '($8)' -%}")}
      ${e("{%- assign colorStrings = colorArraysString | split: '($8)' -%}")}
      ${e("{%- assign imageUrls = imageUrlsString | split: '($8)' -%}")}

      ${t("optionTitle == option.name",`
        ${e("{%- assign optionRendered = true -%}")}
        ${n({showDropdown:!0})}
      `)}
    `)}

    ${t("optionRendered == false",n({showDropdown:!0,isRenderDefault:!0,typeOfOption:"optionType"}))}
  `};export{a as renderOptionValuesOld};
