"use strict";var core=require("@gem-sdk/core"),helpers=require("../../../../helpers.js"),classes=require("./classes.js"),parse=require("html-react-parser"),system=require("@gem-sdk/system"),styles=require("./styles.js");const renderPaginatorItem=({setting:e,builderProps:t,pageContext:s},a)=>"liquid"===a?renderPaginatorLive({setting:e,builderProps:t,pageContext:s}):renderPaginatorEditor({setting:e,builderProps:t,pageContext:s}),renderPaginatorLive=({setting:e,builderProps:t,pageContext:s})=>{let a=getPreviousTextVal({setting:e,builderProps:t,pageContext:s},"liquid"),r=getNextTextVal({setting:e,builderProps:t,pageContext:s},"liquid"),l=e?.numberOfProducts||s?.numberOfProductOfProductList||0,i=l>0?l:4,c=e=>e?.replace(/"/g,'\\"')??"",o=`"${c(a??"")}"`,n=`"${c(r??"")}"`;return`
    {% paginate collection.products by ${i} %}
      {% assign previousText = ${s?.isPreviewing?o:a||'""'} %}
      {% assign nextText = ${s?.isPreviewing?n:r||'""'} %}

      {{ paginate | default_pagination: previous: previousText, next: nextText }}
    {% endpaginate %}
  `},renderPaginatorEditor=({setting:e,builderProps:t,pageContext:s})=>{let{pageQuantity:a,typo:r,normalColor:l,activeColor:i}=e??{},c=[],o=parseInt(a??"0"),n=6;6>o&&(n=o-1);let m=n>1?n-1:0,u=getPreviousTextVal({setting:e,builderProps:t,pageContext:s},"react"),y=getNextTextVal({setting:e,builderProps:t,pageContext:s},"react"),g=system.createClass({...classes.customClass("prev",l,e)}),p=system.createClass({...classes.customClass("page",l,e)}),d=system.createClass({...classes.customClass("deco",l,e)}),x=t=>system.createClass({...classes.customClass("page",t===m?i:l,e)}),P=system.createClass({...classes.customClass("deco",l,e)}),C=system.createClass({...classes.customClass("page",l,e)}),v=system.createClass({...classes.customClass("next",l,e)}),S=t=>system.createStyle({...styles.getPaginatorStyle(t===m,styles.getCustomStyle(e),i)}),h=system.createStyle({...styles.getCustomStyle(e),...core.makeStyle({w:"auto"})}),I=system.createStyle({...styles.getCustomStyle(e)}),q=system.createStyle({...styles.getCustomStyle(e),...core.makeStyle({w:"auto"})});m>0&&c.push(createPaginatorItem({key:"prev",text:r?.attrs?.transform==="capitalize"?u?.toLocaleLowerCase():u,className:g,style:h})),m>2&&c.push(createPaginatorItem({key:1,text:1,className:p,style:I})),m>3&&c.push(createPaginatorItem({key:"deco",text:"...",className:d,style:I}));for(let e=Math.max(0,m-2);e<=Math.min(m+2,o-1);e++)c.push(createPaginatorItem({key:e+1,text:e+1,className:x(e),style:S(e)}));return m<o-4&&c.push(createPaginatorItem({key:"deco-2",text:"...",className:P,style:I})),m<o-3&&c.push(createPaginatorItem({key:o,text:o,className:C,style:I})),m!==o-1&&0!==o&&c.push(createPaginatorItem({key:"next",text:r?.attrs?.transform==="capitalize"?y?.toLocaleLowerCase():y,className:v,style:q})),c.map(e=>parse(e))},createPaginatorItem=({key:e,text:t,className:s,style:a})=>core.template`<span key="${e}" className="${s}" style="${a}"> ${t} </span>`,getPreviousTextVal=({setting:e,builderProps:t,pageContext:s},a)=>{let{previousText:r,typo:l,translate:i}=e??{};return"liquid"===a?helpers.getDynamicSourceLocales({val:r,uid:t?.uid,settingId:"previousText",pageContext:s,isLiquid:!0,isCapitalize:l?.attrs?.transform==="capitalize",translate:i}).toString():r},getNextTextVal=({setting:e,builderProps:t,pageContext:s},a)=>{let{nextText:r,typo:l,translate:i}=e??{};return"liquid"===a?helpers.getDynamicSourceLocales({val:r,uid:t?.uid,settingId:"nextText",pageContext:s,isLiquid:!0,isCapitalize:l?.attrs?.transform==="capitalize",translate:i}).toString():r};exports.renderPaginatorItem=renderPaginatorItem;
