1import{_ as M,u as E}from"./BHlYAlU_.js";import{_ as H,a as O}from"./Bjo3JR9U.js";import{_ as V}from"./BtvgJs0s.js";import{_ as J}from"./CApzk0W6.js";import{d as z,i as A,j as Q,u as W,l as v,D as Z,r as G,s as K,v as X,c as l,a as u,f as n,b as a,t as C,g as Y,F as w,y as tt,w as ot,h as et,z as at,a0 as nt,m as st,o as i,x as rt,_ as it}from"./C-pd9DEJ.js";import{u as ct}from"./D2B5WWut.js";import{u as lt}from"./Duz9RtaY.js";import{p as ut}from"./Ca23IvZj.js";import{u as dt}from"./BAlfmL2h.js";import"./CoEOHCpo.js";import"./D9LKWYn9.js";import"./qM7-IeY-.js";import"./B4xBkiJh.js";import"./mZBpJLHC.js";import"./DNik6tLO.js";import"./DEvEIS_X.js";import"./BRmPP25_.js";const _t={class:"catalog"},mt={class:"container"},pt={class:"catalog__header"},gt={class:"catalog__header-top"},ft={class:"catalog__title"},yt={key:0,class:"catalog__count"},ht={class:"catalog__layout"},bt={class:"catalog__sidebar"},vt={class:"catalog__main"},Ct={key:0,class:"catalog__loading"},wt={key:1,class:"catalog__empty"},kt={class:"grid grid--products"},xt=z({__name:"productos",async setup(It){let c,d;const m=A(),f=Q(),e=ct(),k=lt(),{storeName:p,catalogConfig:x}=W();function y(){const t=m.query,{categoryId:o,subcategoryId:s}=ut(t.categoria,t.subcategoria);return{search:t.q||"",categoryId:o,subcategoryId:s,brandId:t.marca||null,gammaId:t.gamma||null,minPrice:t.precio_min?Number(t.precio_min):null,maxPrice:t.precio_max?Number(t.precio_max):null,sortBy:t.orden||x.value.defaultSort||"newest",page:t.pagina?Number(t.pagina):1}}function I(t){const o={};t.search&&(o.q=t.search),t.categoryId&&(o.categoria=t.categoryId),t.subcategoryId&&(o.subcategoria=t.subcategoryId),t.brandId&&(o.marca=t.brandId),t.gammaId&&(o.gamma=t.gammaId),t.minPrice&&(o.precio_min=String(t.minPrice)),t.maxPrice&&(o.precio_max=String(t.maxPrice)),t.sortBy&&t.sortBy!=="newest"&&(o.orden=t.sortBy),t.page&&t.page>1&&(o.pagina=String(t.page)),f.replace({query:o})}function h(t){return t?e.categories.find(o=>o.slug===t||o.id===t):null}function F(t,o){return!t||!o?null:h(t)?.children?.find(r=>r.slug===o||r.id===o)}function P(t){return t?e.brands.find(o=>o.slug===t||o.id===t):null}const _=et(()=>{const t=h(e.filters.categoryId),o=F(e.filters.categoryId,e.filters.subcategoryId),s=P(e.filters.brandId),r=[];return t&&r.push(t.name),o&&r.push(o.name),s&&r.push(s.name),r.length>0?r.join(" - "):e.filters.search?`Búsqueda: ${e.filters.search}`:"Productos"}),B=y();e.setFilters(B),[c,d]=v(async()=>st(`catalog-${m.fullPath}`,async()=>(await e.fetchCatalog(),!0),{getCachedData(t,o){if(o.isHydrating)return o.payload.data[t]}})),await c,d();const b=at(!1);Z(()=>{b.value=!0}),G(()=>m.query,async(t,o)=>{if(!b.value||JSON.stringify(t)===JSON.stringify(o))return;const s=y();e.setFilters(s),await e.fetchCatalog()},{deep:!0});function S(t){const o={...e.filters,page:t};e.setFilters({page:t}),I(o),e.fetchProducts(),window.scrollTo({top:0,behavior:"smooth"})}function $(){e.resetFilters(),f.replace({query:{}}),e.fetchCatalog()}const q=dt();K({title:()=>`${_.value} | ${p.value}`,link:[{rel:"canonical",href:`${q.origin}/productos`}]}),X({description:()=>`Explora ${_.value.toLowerCase()} en ${p.value}. Encuentra los mejores productos al mejor precio.`,ogTitle:()=>`${_.value} | ${p.value}`,ogType:"website"});const{headerBlocks:N,footerBlocks:T}=([c,d]=v(()=>E(2)),c=await c,d(),c);return(t,o)=>{const s=M,r=H,L=V,j=J,R=O,U=nt;return i(),l("div",_t,[u(s,{blocks:n(N)},null,8,["blocks"]),a("div",mt,[a("header",pt,[a("div",gt,[a("div",null,[a("h1",ft,C(n(_)),1),n(e).pagination.totalItems?(i(),l("p",yt,C(n(e).pagination.totalItems)+" productos encontrados ",1)):Y("",!0)]),a("button",{class:"catalog__filter-btn","aria-label":"Filtros",onClick:o[0]||(o[0]=g=>n(k).openMobileFilters("/productos"))},[...o[1]||(o[1]=[a("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[a("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})],-1),a("span",null,"Filtros",-1)])])])]),a("div",ht,[a("aside",bt,[u(r)]),a("div",vt,[n(e).isLoading?(i(),l("div",Ct,[...o[2]||(o[2]=[a("div",{class:"loading-spinner"},null,-1)])])):n(e).hasProducts?(i(),l(w,{key:2},[a("div",kt,[(i(!0),l(w,null,tt(n(e).products,(g,D)=>(i(),rt(L,{key:g.id,product:g,eager:D<4},null,8,["product","eager"]))),128))]),u(j,{"current-page":n(e).pagination.currentPage,"total-pages":n(e).pagination.totalPages,onChange:S},null,8,["current-page","total-pages"])],64)):(i(),l("div",wt,[o[3]||(o[3]=a("p",null,"No se encontraron productos.",-1)),a("button",{class:"btn btn--secondary",onClick:$}," Limpiar filtros ")]))])])]),u(s,{blocks:n(T)},null,8,["blocks"]),u(U,null,{default:ot(()=>[u(R)]),_:1})])}}}),Vt=it(xt,[["__scopeId","data-v-c54d756c"]]);export{Vt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.