1import{d as Be,b as h,c as T,A as Te,w as W,L as Ae,o as n,k as d,v as s,D as De,E as Ie,x as w,C as Ue,t as A,F as te,l as Ve,u as y,j as Q,e as F,n as He}from"./vendor-K4I91jqf.js";import{u as Ne,a as ze}from"./vendor-vue-router-C4CeeMdV.js";import{b as D,_ as Ee}from"./personal-CeObxwUr.js";import{u as Qe,a as ve,s as fe,_ as Me,P as je,b as Ke,c as Ge,d as We,e as Oe,f as Je,r as Xe,m as se,g as O,h as he,i as Ye,j as Ze,k as de,l as ea,n as aa,o as ta,p as sa,q as ra,t as la,v as na,w as oa,x as ia}from"./index-B2bcFn_Z.js";const ua={class:"container page-search"},ca={class:"search-form__field"},va={key:0,class:"error-text"},fa={key:1,class:"search-history","aria-label":"Ðедавние запÑоÑÑ"},ha={class:"search-history__list"},da=["onClick"],ya={class:"search-history__text"},ma=["onClick"],pa={key:2,class:"search-empty-hint"},ga={class:"search-layout__content"},_a={key:0,class:"search-toolbar"},ba={class:"catalog-sort"},wa=["value","disabled"],ka={class:"catalog-view-switch catalog-view-switch--search"},Sa={class:"catalog-view",role:"group","aria-label":"Ðид ÑезÑлÑÑаÑов"},qa=["aria-busy"],Ca={key:2,class:"catalog-products__series-chunk"},La=Be({__name:"SearchPage",props:{layout:{}},setup(Pa){const o=Ne(),M=ze(),r=h(null),c=h(null),k=h(null),j=h(""),v=h(!1),q=h(!1);let _=0;const $=h(!1),H=h(!1),m=h(""),x=h(""),J=h(null),X=h(null),p=h(typeof window<"u"?window.matchMedia("(min-width: 1024px)").matches:!0),I=h(!1);let U=Promise.resolve(),N=null,Y=0;function ye(){Y+=1;const a=Y;U=new Promise(e=>{N=()=>{a===Y&&e()}})}function K(){N==null||N(),N=null,U=Promise.resolve()}const me=T(()=>!p.value&&!String(o.query.q??"").trim()&&!v.value&&fe.value.length>0),{productView:C,setProductView:pe,showSectionBriefEnabled:re,setShowSectionBriefEnabled:ge}=Oe(),{filtersCollapsed:le}=Je(),{gridPageSize:Z}=Qe(le,p,"search"),ee=T(()=>p.value&&C.value==="table"),_e=T(()=>v.value),ne=T(()=>v.value&&r.value!==null),oe=ve(T(()=>v.value&&r.value===null),0),be=ve(T(()=>v.value&&r.value===null),0),we=T(()=>{const a=String(o.query.q??"").trim();if(!a)return"";const e=new URLSearchParams({q:a});return O(e,o.query),e.toString()}),S=new Map;let R=null,L=0;function z(a,e){return`${a.toLowerCase()}|${e}`}function ke(a,e,t){const l=new URLSearchParams({q:a,page:String(e),lite:t==="lite"?"1":"0"});return O(l,o.query),l.set("pageSize",String(ee.value?30:Z.value)),l.toString()}function E(){const a=new URLSearchParams;O(a,o.query);const e=a.toString(),t=`|ps${ee.value?30:Z.value}`;return e?`|${e}${t}`:t}async function Se(a,e,t){const l=`${z(a,e)}|${t}${E()}`,i=S.get(l);if(i)return i;const u=await D(`/search?${ke(a,e,t)}`);return S.set(l,u),u}async function ie(){const a=String(o.query.q??"").trim(),e=++_;if(!a){c.value=null,k.value=null,j.value="",$.value=!1,H.value=!1;return}const t=a.toLowerCase();j.value!==t&&(k.value=null,j.value=t);const l=c.value===null;l?$.value=!0:H.value=!0;try{if(Xe(o.query)){if(!k.value||!!k.value.countsPending||(k.value.properties??[]).some(b=>(b.values??[]).some(f=>f.count===null||f.count===void 0)||b.type!=="range"&&b.uiType!=="range"&&(b.values??[]).length===0)){const b=await D(`/search/filters?${new URLSearchParams({q:a,phase:"schema"}).toString()}`);if(e!==_||(c.value||(c.value=b,$.value=!1),await U,e!==_))return;const f=await D(`/search/filters?${new URLSearchParams({q:a,phase:"counts"}).toString()}`);if(e!==_)return;k.value=se(b,f)}else if(await U,e!==_)return;const P=new URLSearchParams({q:a,phase:"counts"});O(P,o.query);const g=await D(`/search/filters?${P.toString()}`);if(e!==_)return;c.value=se(k.value,g)}else{const u=await D(`/search/filters?${new URLSearchParams({q:a,phase:"schema"}).toString()}`);if(e!==_||(k.value=u,c.value=u,$.value=!1,H.value=!0,await U,e!==_))return;const P=await D(`/search/filters?${new URLSearchParams({q:a,phase:"counts"}).toString()}`);if(e!==_)return;const g=se(u,P);k.value=g,c.value=g}}catch{e===_&&l&&(c.value=null)}finally{e===_&&($.value=!1,H.value=!1)}}async function G(a=1){const e=String(o.query.q??"").trim(),t=p.value&&C.value==="table",l=t?"full":"lite";if(x.value=e,ye(),!e){r.value={query:"",items:[],pagination:{page:1,pageSize:30,total:0,pageCount:0}},v.value=!1,q.value=!1,m.value="",K();return}const i=he(e);if(i.isNoise){r.value={query:e,items:[],suggestions:[],pagination:{page:1,pageSize:30,total:0,pageCount:0}},v.value=!1,q.value=!1,m.value=i.message,K();return}const u=`${z(e,a)}|${l}${E()}`,P=S.get(u);if(P){r.value=P,v.value=!1,q.value=!1,m.value="",I.value&&(window.scrollTo({top:0,behavior:"smooth"}),I.value=!1),K();return}const g=++L,b=r.value===null;v.value=!0,q.value=t,m.value="";try{if(t&&!b){const V=`${z(e,a)}|lite${E()}`,B=S.get(V);B&&(r.value=B)}else if(t&&b){const V=`${z(e,a)}|lite${E()}`,B=S.get(V);B&&(r.value=B,v.value=!1)}
1let f=await Se(e,a,l);if(g!==L)return;if(r.value=f,v.value=!1,t){const V=Ye(f);if(V.length>0)try{const B=await D(`/catalog/prices?ids=${V.join(",")}`);if(g!==L)return;f=Ze(f,B.prices??{}),S.set(u,f),r.value=f}catch{}finally{g===L&&(q.value=!1)}else q.value=!1}else q.value=!1;S.set(u,f),m.value="",I.value&&(window.scrollTo({top:0,behavior:"smooth"}),I.value=!1)}catch(f){if(g!==L)return;b&&(r.value=null),m.value=f instanceof Error?f.message:"ÐÑибка поиÑка",I.value=!1,v.value=!1,q.value=!1}finally{g===L&&(v.value&&(v.value=!1),K())}}function qe(){const a=x.value.trim(),e=he(a);if(e.isNoise){m.value=e.message;return}m.value="",a&&de(a),M.push({name:"search",query:a?{q:a}:{}})}function Ce(){var a;x.value="",(a=J.value)==null||a.focus()}function Pe(a){x.value=a,de(a),m.value="",M.push({name:"search",query:{q:a}})}function $e(a,e){a.preventDefault(),a.stopPropagation(),ea(e)}function Re(){aa()}function ue(a){var e;I.value=!0,(e=X.value)==null||e.scrollIntoView({behavior:"smooth",block:"start"}),M.push({name:"search",query:{...o.query,q:o.query.q,page:String(a)}})}function ce(a){var l;if(C.value===a||(pe(a),!((l=r.value)!=null&&l.query)))return;const e=Number(o.query.page)||1,t=`${z(r.value.query,e)}|full${E()}`;if(a==="table"&&S.has(t)){r.value=S.get(t);return}G(e)}function Fe(){const a={};for(const[e,t]of Object.entries(o.query))typeof t=="string"&&t!==""?a[e]=t:Array.isArray(t)&&typeof t[0]=="string"&&t[0]!==""&&(a[e]=t[0]);return a}function xe(a){const e=c.value;if(!e)return;const t=ra(e,a);if(!t)return;const l=Fe(),i=e.properties.map(g=>g.code),u=la(l,i),P=t.kind==="range"?na(u,t.property.code,t.min,t.max):oa(u,t.property.code,t.valueKey);M.replace({name:"search",query:ia(P,{q:l.q,sort:l.sort,page:"1"})})}function Le(a){ge(a.target.value==="1")}function ae(){p.value=(R==null?void 0:R.matches)??!0}return Te(async()=>{R=window.matchMedia("(min-width: 1024px)"),ae(),R.addEventListener("change",ae),await G(Number(o.query.page)||1),ie(),!p.value&&!String(o.query.q??"").trim()&&requestAnimationFrame(()=>{var a;(a=J.value)==null||a.focus({preventScroll:!0})})}),W(()=>String(o.query.q??"").trim(),(a,e)=>{a!==e&&(c.value=null,k.value=null,j.value="",r.value=null,L+=1)}),W(()=>o.fullPath,()=>{G(Number(o.query.page)||1)}),W(we,async(a,e)=>{if(!a){c.value=null;return}await Promise.resolve(),await U,ie(),e&&a!==e&&He(()=>{var t;(t=X.value)==null||t.scrollIntoView({behavior:"smooth",block:"start"})})}),W(Z,(a,e)=>{if(a===e||ee.value||!String(o.query.q??"").trim())return;if(S.clear(),(Number(o.query.page)||1)>1){ue(1);return}G(1)}),Ae(()=>{R==null||R.removeEventListener("change",ae)}),(a,e)=>{var t,l;return n(),d("div",ua,[e[13]||(e[13]=s("h1",{class:"page-search__title"}," ÐоиÑк ",-1)),s("form",{class:"search-form",onSubmit:Ue(qe,["prevent"])},[s("div",ca,[e[4]||(e[4]=s("span",{class:"search-form__icon","aria-hidden":"true"},[s("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"none"},[s("circle",{cx:"11",cy:"11",r:"6.5",stroke:"currentColor","stroke-width":"1.8"}),s("path",{d:"M16.2 16.2 20 20",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round"})])],-1)),De(s("input",{ref_key:"searchInputRef",ref:J,"onUpdate:modelValue":e[0]||(e[0]=i=>x.value=i),type:"search",class:"search-form__input",placeholder:"ÐÑÑикÑл или название",autocomplete:"off",enterkeyhint:"search",inputmode:"search","aria-label":"ÐоиÑк по каÑалогÑ"},null,512),[[Ie,x.value]]),x.value.trim().length>0?(n(),d("button",{key:0,type:"button",class:"search-form__clear","aria-label":"ÐÑиÑÑиÑÑ Ð¿Ð¾Ð¸Ñк",onClick:Ce},[...e[3]||(e[3]=[s("span",{"aria-hidden":"true"},"Ã",-1)])])):w("",!0),e[5]||(e[5]=s("button",{type:"submit",class:"search-form__submit search-form__submit--icon","aria-label":"ÐайÑи"},[s("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none","aria-hidden":"true"},[s("circle",{cx:"11",cy:"11",r:"6.5",stroke:"currentColor","stroke-width":"1.8"}),s("path",{d:"M16.2 16.2 20 20",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round"})])],-1))]),e[6]||(e[6]=s("button",{type:"submit",class:"btn btn--primary search-form__submit search-form__submit--label"}," ÐайÑи ",-1))],32),m.value?(n(),d("p",va,A(m.value),1)):w("",!0),me.value?(n(),d("section",fa,[s("div",{class:"search-history__head"},[e[7]||(e[7]=s("h2",{class:"search-history__title"}," Ðедавние запÑоÑÑ ",-1)),s("button",{type:"button",class:"search-history__clear",onClick:Re}," ÐÑиÑÑиÑÑ ")]),s("ul",ha,[(n(!0),d(te,null,Ve(y(fe),i=>(n(),d("li",{key:i,class:"search-history__item"},[s("button",{type:"button",class:"search-history__btn",onClick:u=>Pe(i)},[e[8]||(e[8]=s("span",{class:"search-history__icon","aria-hidden":"true"},"âº",-1)),s("span",ya,A(i),1)],8,da),s("button",{type:"button",class:"search-history__remove","aria-label":"УдалиÑÑ Ð¸Ð· иÑÑоÑии",onClick:u=>$e(u,i)},[...e[9]||(e[9]=[s("span",{"aria-hidden":"true"},"Ã",-1)])],8,ma)]))),128))])])):!p.value&&!String(y(o).query.q??"").trim()&&!m.value?(n(),d("p",pa," ÐведиÑе аÑÑикÑл, название или бÑенд ")):w("",!0),r.value||v.value?(n(),d(te,{key:3},[s("div",{ref_key:"resultsAnchorRef",ref:X},null,512),(t=r.value)!=null&&t.query?(n(),d("p",{key:0,class:Q(["search-summary",{"search-summary--refreshing":ne.value}])}," Ðо запÑоÑÑ Â«"+A(r.value.query)+"» найдено: "+A(r.value.pagination.total),3)):y(be)?(n(),F(Ee,{key:1,width:"280px",height:"18px",class:"search-summary-skeleton"})):w("",!0),(l=r.value)!=null&&l.query||y(oe)?(n(),d("div",{key:2,class:Q(["search-layout",{"search-layout--no-filters":!c.value&&!$.value,"search-layout--filters-collapsed":p.value&&y(le)&&(c.value||$.value)}])},[c.value?(n(),F(Me,{key:0,filters:c.value,"route-name":"search","preserve-query-keys":["q"],refreshing:H.value},null,8,["filters","refreshing"])):$.value?(n(),F(ta,{key:1})):w("",!0),s("div",ga,[p.value?(n(),d("div",_a,[s("label",ba,[e[11]||(e[11]=s("span",null,"ТеÑ
. опиÑание:",-1)),s("select",{class:"site-select",value:y(re)?"1":"0",disabled:y(C)!=="table",onCh
1ange:Le},[...e[10]||(e[10]=[s("option",{value:"1"}," ÐоказаÑÑ ",-1),s("option",{value:"0"}," СкÑÑÑÑ ",-1)])],40,wa)]),s("div",ka,[e[12]||(e[12]=s("span",null,"Ðид:",-1)),s("div",Sa,[s("button",{type:"button",class:Q(["catalog-view__btn",{"catalog-view__btn--active":y(C)==="grid"}]),onClick:e[1]||(e[1]=i=>ce("grid"))}," ÐаÑÑоÑки ",2),s("button",{type:"button",class:Q(["catalog-view__btn",{"catalog-view__btn--active":y(C)==="table"}]),onClick:e[2]||(e[2]=i=>ce("table"))}," ТаблиÑа ",2)])])])):w("",!0),s("div",{class:"catalog-products__list","aria-busy":_e.value},[y(oe)?(n(),d(te,{key:0},[p.value&&y(C)==="table"?(n(),F(je,{key:0,"with-brief":y(re)},null,8,["with-brief"])):(n(),F(sa,{key:1}))],64)):r.value?(n(),d("div",{key:1,class:Q(["catalog-products__list-body content-reveal",{"catalog-products__list-body--refreshing":ne.value}])},[p.value&&y(C)==="table"?(n(),F(Ke,{key:0,items:r.value.items,groups:r.value.groups??[],"prices-pending":q.value,filters:c.value,onFilterByParam:xe},null,8,["items","groups","prices-pending","filters"])):(n(),F(Ge,{key:1,items:r.value.items},null,8,["items"])),p.value&&y(C)==="table"&&r.value.pagination.mode==="series_pack"&&r.value.pagination.seriesChunkCount&&r.value.pagination.seriesChunkCount>1?(n(),d("p",Ca," СеÑиÑ, ÑаÑÑÑ "+A(r.value.pagination.seriesChunk)+" из "+A(r.value.pagination.seriesChunkCount)+" ("+A(r.value.pagination.seriesTotalSku)+" поз.) ",1)):w("",!0),r.value.pagination.pageCount>1?(n(),F(We,{key:3,pagination:r.value.pagination,onChange:ue},null,8,["pagination"])):w("",!0)],2)):w("",!0)],8,qa)])],2)):w("",!0)],64)):w("",!0)])}}});export{La 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.