import{j as e,a4 as G,H as Q,L as $,al as J,S as A,u as q,am as K}from"./main-7700519c.js";import{r as f}from"./chunk-react-caacd912.js";import{H as V,a as Y,F as U,b as X}from"./chunk-index-aeddd6b3.js";import{m as v,C as P,G as c,d as C,e as Z,ag as D,ah as ee,H as w,L as re,g as R,ai as se,n as oe,B as ne,E as te,J as ie,aj as pe}from"./chunk-material-ui-241eb317.js";import{B as ce,a as de}from"./chunk-index-66a32329.js";import{P as me,D as le}from"./chunk-index-ce60d2b6.js";import{C as xe,F as ue,a as he,b as ae}from"./chunk-index-c27df9dc.js";import{Page404 as je}from"./chunk-index-44c2d602.js";import"./chunk-lodash-6114c6d4.js";import"./chunk-index-3cb6e55a.js";import"./chunk-index-cacabe40.js";import"./chunk-index-5977a1b4.js";import"./chunk-index-b119c954.js";import"./chunk-ListItemButton-d39e9cca.js";import"./chunk-useThemeProps-28fa4885.js";import"./chunk-index-d61a2e64.js";import"./chunk-index-f9cec726.js";import"./chunk-index-8609782e.js";import"./chunk-index-26eed4ba.js";import"./chunk-index-69956742.js";import"./chunk-createSvgIcon-f41b980c.js";import"./chunk-index-8c6f9339.js";import"./chunk-index-79cf7d9a.js";import"./chunk-index-f0886601.js";import"./chunk-index-355ad0d2.js";import"./chunk-index-e1b40fd5.js";import"./chunk-effect-fade-17bfa8f3.js";import"./chunk-index-81727111.js";import"./chunk-pagination-55bdba61.js";const ye=v(s=>({pageHeaderWrapper:{backgroundColor:s.color.black20},pageHeaderContainer:{"@media (min-width: 1280px)":{paddingTop:"24px",paddingBottom:"24px"}}}),{name:"PageHeader"});function ge({children:s}){const o=ye();return e.jsx(P,{disableGutters:!0,maxWidth:!1,className:o.pageHeaderWrapper,children:e.jsx(P,{fixed:!0,maxWidth:"xl",classes:{root:o.pageHeaderContainer},children:e.jsx(c,{container:!0,spacing:3,children:s})})})}const fe=v(s=>({mainBlock:{padding:9,"@media (max-width: 1280px)":{paddingBlockStart:0}},headerRoot:{"@media (min-width: 1280px)":{paddingTop:s.spacing(2)}},headerText:{"@media (min-width: 390px)":{fontSize:s.typography.pxToRem(37),lineHeight:s.typography.pxToRem(37)},"@media (max-width: 360px)":{fontSize:s.typography.pxToRem(31),lineHeight:s.typography.pxToRem(31)}},categoryBtn:{padding:0},textLink:{"&:not(:last-child)":{paddingBottom:6}}}),{name:"CatalogHeader"}),Se=({categoryName:s,subCategoryLinks:o,seoBlock:p={}})=>{const i=fe(),r=p==null?void 0:p.h1,t=p==null?void 0:p.seo_popular_query,d=G(t),[m,h]=f.useState(!1),{meta_desc:l,meta_title:x}=p;return e.jsxs(e.Fragment,{children:[e.jsxs(Q,{children:[e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:title",content:x}),e.jsx("meta",{property:"og:description",content:l}),e.jsx("meta",{property:"og:image",content:location.origin+"/local/traektoria_ta/build/img/logo_traektoria.svg"}),e.jsx("meta",{property:"og:url",content:location.href}),e.jsx("meta",{property:"og:site_name",content:"Траектория"})]}),e.jsxs(c,{xs:12,classes:{root:i.mainBlock},children:[e.jsxs(c,{container:!0,item:!0,alignItems:"baseline",classes:{root:i.headerRoot},spacing:3,children:[e.jsx(c,{item:!0,xs:"auto",children:e.jsx(C,{variant:"h1",classes:{root:i.headerText},children:r||s})}),Array.isArray(o)&&!!o.length&&e.jsx(c,{item:!0,xs:"auto",children:e.jsx(Z,{classes:{root:i.categoryBtn},variant:"text",color:"default",onClick:()=>h(!m),endIcon:m?e.jsx(ee,{}):e.jsx(D,{}),children:"категории"})}),m&&e.jsx(w,{mdDown:!0,children:e.jsx(c,{item:!0,xs:12,children:e.jsx(c,{style:{maxHeight:90},container:!0,item:!0,direction:"column",justifyContent:"space-between",children:o&&o.map(a=>e.jsx(c,{classes:{root:i.textLink},item:!0,xs:"auto",children:e.jsx(C,{variant:"body1",children:e.jsx(re,{underline:"none",component:$,to:a.url,children:a.name})})},a.id))})})})]}),Array.isArray(d)&&e.jsx(me,{popularQuerySeoArray:d})]})]})},B=v(s=>({headerPopular:{"@media (max-width: 1024px)":{height:41}},chipRoot:{background:"#FFFFFF",borderRadius:"10px",fontSize:"0.85rem",lineHeight:"20px",color:"#5D6871"},chipIcon:{color:s.color.black60,"&:hover":{color:s.color.black60}},chipSkeleton:{width:200,height:32,backgroundColor:s.color.black40,borderRadius:10}}));function be({items:s}){const o=B();return f.useMemo(()=>e.jsx(e.Fragment,{children:s.map((p,i)=>e.jsx(c,{item:!0,xs:"auto",sm:"auto",md:"auto",lg:"auto",xl:"auto",children:e.jsx(oe,{variant:"rect",classes:{root:o.chipSkeleton},animation:"wave"})},i))}),[s])}function Pe({popularTags:s}){const o=B(),p=J(8),i=()=>{console.info("You clicked the delete icon.")};return s?e.jsx(w,{mdDown:!0,children:e.jsxs(c,{item:!0,spacing:3,container:!0,alignItems:"center",justifyContent:"flex-start",className:o.headerPopular,children:[s.map((r,t)=>e.jsx(c,{item:!0,xs:"auto",sm:"auto",md:"auto",lg:"auto",xl:"auto",children:e.jsx(R,{classes:{root:o.chipRoot},label:r.title},t)},t)),e.jsx(c,{item:!0,xs:"auto",sm:"auto",md:"auto",lg:"auto",xl:"auto",children:e.jsx(R,{classes:{root:o.chipRoot,deleteIcon:o.chipIcon},onClick:i,onDelete:i,label:"еще",deleteIcon:e.jsx(se,{color:"primary"})})})]})}):e.jsx(w,{mdDown:!0,children:e.jsx(c,{container:!0,spacing:3,alignItems:"center",justifyContent:"flex-start",className:o.headerPopular,children:e.jsx(be,{items:p})})})}const ve=v(s=>({catalogWrapper:{backgroundColor:"#FFFFFF",position:"relative"},blogWrapper:{backgroundColor:"#3A474E",padding:"80px 0"},blogHeaderText:{"@media (max-width: 479px)":{fontSize:s.typography.pxToRem(20)}},blogSectionHeader:{paddingBottom:40},Backdrop:{zIndex:s.zIndex.drawer,position:"absolute",backgroundColor:"rgba(255, 255, 255, 0.5)"},loader:{position:"absolute",top:300},errorText:{fontSize:s.typography.pxToRem(33),lineHeight:s.typography.pxToRem(40),fontFamily:"TTFirsNeue-Medium, sans-serif","@media (max-width: 960px)":{textAlign:"center",fontSize:s.typography.pxToRem(27)}},errorGrid:{marginBlockStart:60}}),{name:"CatalogPage"}),Ie=({headerContent:s,page:o,isLoading:p,setPage:i,catalogData:r,error:t})=>{var F,H,T,k,_;const d=ve(),[m,h]=f.useState(),l=(F=r==null?void 0:r.products)==null?void 0:F.length,x=(T=(H=t==null?void 0:t.MAIN)==null?void 0:H[0])==null?void 0:T.message,a=!!l||x,j=s==null?void 0:s.SEO_BLOCK,S=r==null?void 0:r.breadcrumb,E=!!(S!=null&&S.length),N="Catalog",y=(k=r==null?void 0:r.products)==null?void 0:k.filter(n=>n.colors_list.length),z=n=>y.find(({product_id:u})=>u==n),W=n=>y.findIndex(({product_id:u})=>u==n),[L]=A(),M=n=>{const u=n.map(g=>{var b;return{id:g,price:(b=z(g))==null?void 0:b.colors_list[0].retail_price,index:W(g)}});L({type:"showProducts",products:JSON.stringify(u)})},O=f.useMemo(()=>{try{new IntersectionObserver((n,u)=>{if(r!=null&&r.products){const g=n.map(b=>b.target.dataset.id);M(g)}},{threshold:.5})}catch{}},[r==null?void 0:r.products]),I=!(r!=null&&r.sorts.filter(({code:n})=>n!=="sort").some(({is_active:n})=>n))&&(r==null?void 0:r.name)==="Одежда"?[...y].sort((n,u)=>u.badges.length-n.badges.length):y;return((_=t==null?void 0:t[0])==null?void 0:_.code)==="404"?e.jsx(je,{}):e.jsxs(e.Fragment,{children:[p?e.jsx(P,{fixed:!0,maxWidth:"xl",children:e.jsx(c,{container:!0,spacing:4,children:e.jsx(xe,{count:12})})}):a&&e.jsxs(ne,{className:d.catalogWrapper,children:[e.jsxs(ge,{children:[E&&e.jsx(ce,{items:S,children:e.jsx(de,{})}),e.jsx(Se,{subCategoryLinks:r==null?void 0:r.subsections,categoryName:r==null?void 0:r.name,seoBlock:j}),Array.isArray(r==null?void 0:r.popular_tags)&&!!(r!=null&&r.popular_tags.length)&&e.jsx(c,{item:!0,xs:12,children:e.jsx(Pe,{popularTags:r==null?void 0:r.popular_tags})})]}),e.jsxs(P,{fixed:!0,maxWidth:"xl",children:[e.jsx(ue,{headerContent:s,page:o,filterData:r}),e.jsx(c,{container:!0,spacing:4,itemProp:"hasOfferCatalog",itemScope:!0,itemType:"http://schema.org/OfferCatalog",children:y&&(I==null?void 0:I.map((n,u)=>e.jsx(he,{product:n,pageName:N,catalogName:r==null?void 0:r.name,productPosition:u+1,setShowDisplayProductSizes:h,showDisplayProductSiazes:m===(n==null?void 0:n.product_id),observer:O},n.product_id)))}),x&&e.jsx(c,{spacing:4,classes:{root:d.errorGrid},children:e.jsx(C,{variant:"body1",classes:{root:d.errorText},children:x})}),e.jsx(ae,{headerContent:s,items:r==null?void 0:r.navigation,sumProducs:l}),e.jsx(le,{seoBlock:j})]})]}),e.jsx(te,{classes:{root:d.Backdrop},invisible:p,open:p??!1,children:e.jsx(ie,{classes:{root:d.loader},color:"primary"})})]})},Ce=({data:s,isFetching:o,aditionalEventData:p})=>{var m,h,l,x;const i=(m=s==null?void 0:s.data)==null?void 0:m.HEADER,r=(l=(h=s==null?void 0:s.data)==null?void 0:h.MAIN)==null?void 0:l.content,t=(x=s==null?void 0:s.data)==null?void 0:x.FOOTER,d=s==null?void 0:s.errors;return e.jsxs(e.Fragment,{children:[e.jsx(V,{content:i,aditionalEventData:p,children:e.jsx(Y,{isFetching:o})}),e.jsx(Ie,{isLoading:o,headerContent:i,catalogData:r,error:d}),e.jsx(U,{content:t,children:e.jsx(pe,{container:document.getElementById("footer"),children:e.jsx(X,{isLoading:o})})})]})},sr=s=>{var m,h;const o=q(),[p]=A(),{data:i,isFetching:r}=K({pathname:o.pathname,params:o.search}),t=(h=(m=i==null?void 0:i.data)==null?void 0:m.MAIN)==null?void 0:h.content;f.useEffect(()=>{t&&p({type:"viewCategory",section_id:t.id})},[t]);const d=t==null?void 0:t.products.filter(l=>l.colors_list.length).reduce((l,x,a)=>{var j;return{...l,[`contentIds[${a}][ID]`]:x.product_id,[`contentIds[${a}][PRICE]`]:(j=x.colors_list[0])==null?void 0:j.retail_price}},{});return e.jsx(Ce,{data:i,isFetching:r,aditionalEventData:d})};export{sr as Catalog,Ce as Page};