'use client';
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@gem-sdk/core"),helpers$1=require("../common/helpers.js"),helpers=require("../../helpers.js");const ArticleList=e=>{let{styles:l,setting:t,className:i,children:r,builderProps:a,advanced:s,style:o}=e??{},{border:c,rounded:n,hasBoxShadow:g,boxShadow:d}=s??{},[p]=core.splitStyle(["pos","top","left","bottom","right","z","d"],o),m=core.composeAdvanceStyle({border:c,rounded:n,hasBoxShadow:g,boxShadow:d,"spacing-setting":s?.["spacing-setting"]}),u=t?.articleSetting,y=t?.articleOrderBy??"UPDATED_AT_REVERSE",b=u?.articlePickType??"manually",h="manually"===b&&u?.articleHandles?.length?u?.articleHandles:[],S="manually"===b&&u?.articleBlogTitles?.length?u?.articleBlogTitles:[],_=u?.blogHandle??"",v=helpers.convertUnitToNumber(t?.numberOfArticle,4);return core.template`
    <div
    style="${p}"
    data-id="${a?.uid}"
      items-repeat
    >
      <div style="${{...m,...core.makeStyleWithDefault("w",core.makeWidth(l?.width),{desktop:"--g-ct-w",tablet:"--g-ct-w",mobile:"--g-ct-w"}),...core.makeStyleResponsive("rg",l?.horizontalGutter),...core.makeStyleResponsive("cg",l?.verticalGutter),...core.getStyleBackgroundByDevice(t?.background),...core.getGradientBgrStyleByDevice(t?.background),...core.makeStyleResponsive("gtc",{desktop:`repeat(${core.getResponsiveValueByScreen(t?.slideToShow,"desktop")}, minmax(0, 1fr))`,tablet:t?.slideToShow?.tablet&&`repeat(${core.getResponsiveValueByScreen(t?.slideToShow,"tablet")}, minmax(0, 1fr))`,mobile:t?.slideToShow?.mobile&&`repeat(${core.getResponsiveValueByScreen(t?.slideToShow,"mobile")}, minmax(0, 1fr))`})}}"
          class="${core.cls(i,"gp-grid !gp-m-auto gp-w-full",s?.cssClass)}"
        >
        {% liquid
            assign articlePickType = '${b}'
            assign articleHandles = '${h.toString()}'| split: ","
            assign articleBlogTitle = "${helpers$1.convertSpecialCharacter(S.toString())}" | split: ","
            assign limit = "${"manually"===b?u?.articleIds?.length:v}"
            assign blogTitle = ''
            assign all_articles = null | sort

            if articlePickType == 'manually'
              for handle in articleHandles
                assign articleByHandle = articles[handle] | sort
                assign all_articles = all_articles | concat: articleByHandle
              endfor
            else
              assign current_blog_handle = blogs['${_}']
              if gp_enable_custom_dynamic_blog == true
                assign current_blog_handle = blogs[blog.handle]
              endif
              assign all_articles = current_blog_handle.articles | limit: limit | sort: "${y.replace("_REVERSE","").toLowerCase()}" ${y.includes("_REVERSE")?"| reverse":""}
              assign blogTitle = current_blog_handle.title
            endif

        %}
        {% for article in all_articles limit: limit %}
          {% if articlePickType == 'manually' %}
              {% assign blogTitle = articleBlogTitle[forloop.index0] %}
          {% endif %}
          <div>${r??""}</div>
        {% endfor %}
      </div>
    </div>

  `};exports.default=ArticleList;
