1import{H as U,d as V,A as T,B as S,i as z,v as N,l as A,ab as Y,o as s,g as y,a as v,u as a,c as C,m as $,b as x,w as I,e as H,t as w,p as E,aD as M,aE as Z,M as W,x as L,L as G}from"./app-bd5230ae.js";import{_ as J}from"./AddToCart.vue_vue_type_style_index_0_scoped_fdd1e5e3_lang-b9d8af1e.js";import{S as K}from"./IconClose-4d4b3326.js";import{S as X}from"./SimpleSelect-f8ddff81.js";import B from"./IconSandTimer-8158a925.js";import{f as R}from"./deliveryRange-0e145085.js";import{A as P,_ as ee}from"./AdvancedTable-1473b1db.js";import{_ as te}from"./SimpleTooltip.vue_vue_type_script_setup_true_lang-773964b5.js";import{Q as ae}from"./QuantityInput-2305fb1a.js";import ie from"./IconCartFull-00cfd6eb.js";import{_ as D}from"./_plugin-vue_export-helper-c27b6911.js";import{_ as se,a as le}from"./RelationBadge.vue_vue_type_script_setup_true_lang-2f1dc3b1.js";import"./PrimaryButton-149c4664.js";import"./IconSort.vue_vue_type_script_setup_true_lang-e723d817.js";import"./SecondaryButton.vue_vue_type_script_setup_true_lang-e448f7b7.js";import"./SimpleModal.vue_vue_type_script_setup_true_lang-4fbde407.js";const Q=u=>{const l=u.pack_quantity||1;return Math.max(Math.ceil((u.minimum_order_quantity||0)/l),1)*l},O=u=>u.quantity_limit<Q(u),re=(u,l,p)=>{const h=Q(u),_=Math.min(l,u.quantity_limit);return _>=h?_:_>p&&!O(u)?h:0},j=(u,l)=>{const p=u[l];return l==="weight"&&Number(p)===0?"â":typeof p=="number"&&U(+p||0)||(p??"")},oe={class:"py-[1px]"},ne={key:0,class:"relative flex justify-center items-center h-full"},de={class:"absolute left-3"},ue={key:1,class:"flex justify-center items-center h-full"},ce=["data-tooltip-target"],me=["disabled"],pe=500,_e=V({__name:"AddToCart",props:{item:{}},setup(u){const l=u,{cartItems:p,loading:h}=T(S()),_=z(()=>Q(l.item)),c=z(()=>O(l.item));N(()=>{var i;l.item.quantity=((i=p.value.get(l.item.id))==null?void 0:i.quantity)??0});const g=A(null),k=Y.debounce(async(i,r,f)=>{g.value=r,i>0?await S().patchItem(f,i):await S().removeItem(f),g.value=null},pe),q=async i=>{const r=l.item,f=p.value.get(r.id),b=re(r,i,r.quantity);r.quantity=b,f?k(b,r,f):b&&(g.value=r,await S().addItem(r),g.value=null)};return(i,r)=>{var f,b;return s(),y("div",oe,[i.item.quantity?(s(),y("div",ne,[v("div",de,[((f=g.value)==null?void 0:f.id)===i.item.id&&a(h)?(s(),C(a(J),{key:0,class:"absolute",size:"xs"})):$("",!0)]),(s(),C(a(ae),{id:`tooltip-test-trigger-${i.item.id}`,key:`${i.item.id}`,min:0,max:i.item.quantity_limit,delta:i.item.pack_quantity||1,disabled:((b=g.value)==null?void 0:b.id)===i.item.id&&a(h),"model-value":i.item.quantity,"onUpdate:modelValue":q},null,8,["id","max","delta","disabled","model-value"]))])):(s(),y("div",ue,[x(a(te),{id:`tooltip-add-to-cart-${i.item.id}`},{default:I(()=>[H(w(c.value?i.__("Available quantity is below the minimum"):i.__("Add to cart")),1)]),_:1},8,["id"]),v("span",{class:E(["mx-auto flex items-center justify-center",{"cursor-not-allowed":c.value}]),"data-tooltip-target":`tooltip-add-to-cart-${i.item.id}`,"data-tooltip-placement":"top"},[v("button",{class:E(["p-0 m-0 outline-none opacity-80 hover:opacity-100 cursor-pointer text-center flex items-center justify-center disabled:opacity-30 disabled:pointer-events-none",{"animate-pulse":g.value===i.item}]),disabled:c.value,onClick:r[0]||(r[0]=t=>q(_.value))},[x(a(ie),{class:"h-5 w-5",stroke:"none"})],10,me)],10,ce)]))])}}}),F=D(_e,[["__scopeId","data-v-fdd1e5e3"]]),fe={key:0,class:"px-4"},ve={class:"w-full md:col-span-6 my-5"},ye={class:"flex flex-col justify-center"},he={class:"px-1 py-1 leading-none text-primary-500 animate-pulse duration-75 flex w-fit mx-auto"},be={key:1,class:"analogs-block pt-2"},ge={class:"px-4 pb-2"},we={class:"text-lg font-semibold"},ke={class:"text-sm text-gray-500"},xe={key:2,class:"grid-table__cell-value"},qe={key:3,class:"grid-table__cell-value"},$e=V({__name:"AnalogsBlock",props:{columns:{}},setup(u){const l=u,{query:p}=T(M()),{loading:h,resolved:_,filter:c,dedupedItems:g,visibleItems:k}=T(Z()),q=[{title:"All",value:""},{title:"Analogs",value:"analog"},{title:"Replacements",value:"replacement"}],i=z({get:()=>c.value==="all"?"":c.value,set:t=>c.value=t||"all"}),r=z(()=>{const t=l.columns.map(e=>({...e})),o=t.findIndex(e=>e.field==="partnumber");return t.splice(o+1,0,{field:"relation_type",title:"Link Type",width:110,minWidth:100,resizable:!0,visible:!0}),t}),{cartItems:f}=T(S()),b=A([]);return W(()=>{b.value=k.value.map(t=>{var o,e,n,d;return{...t,quantity:((o=f.value.get(t.id))==null?void 0:o.quantity)??0,offer_id:t.id,amount:0,product_name:{en:((e=t.product_name)==null?void 0:e.en)||"",ru:((n=t.product_name)==null?void 0:n.ru)||((d=t.product_name)==null?void 0:d.en)||""}}})}),(t,o)=>a(h)?(s(),y("div",fe,[v("div",ve,[v("div",ye,[v("div",he,[x(a(B),{
1class:"h-6 w-6 transition text-red animate-bounce duration-75 opacity-50"}),v("span",null,w(t.__("Searching analogs & replacements"))+"...",1)])])])])):a(_)&&a(g).length>0?(s(),y("div",be,[v("div",ge,[v("h3",we,w(t.__("Analogs & Replacements")),1),v("p",ke,w(t.__("for requested number :pn",{pn:a(p)})),1)]),x(a(P),{"columns-settings":r.value,key:"analog-offers","table-name":"analog-offers",rows:b.value,"hide-empty-table":"",loading:!1},{FILTER:I(()=>[x(a(se),{class:"grid-table__filter",modelValue:i.value,"onUpdate:modelValue":o[0]||(o[0]=e=>i.value=e),options:q},null,8,["modelValue"])]),CELL:I(({item:e,columnName:n})=>[n==="quantity"?(s(),C(F,{key:e.id,class:"grid-table__cell_add-to-cart",item:e},null,8,["item"])):n==="relation_type"?(s(),C(le,{key:1,type:e.relation_type},null,8,["type"])):n==="max_delivery_days"?(s(),y("div",xe,w(a(R)(e.min_delivery_days,e.max_delivery_days)),1)):n==="quantity_limit"||n==="weight"?(s(),y("div",qe,w(a(j)(e,n)),1)):$("",!0)]),_:1},8,["columns-settings","rows"])])):$("",!0)}}),Ce={class:"search-prices"},Te={key:1,class:"grid-table__cell-value"},Ie={key:2,class:"grid-table__cell-value"},Se={key:0,class:"px-4"},Ae={class:"w-full md:col-span-6 my-5"},ze={class:"flex flex-col justify-center"},Ve={key:0,class:"px-1 py-1 leading-none text-primary-500 animate-pulse duration-75 flex w-fit mx-auto"},Qe={key:1,class:"px-1 py-1 leading-none text-center text-primary-500"},Ee=V({__name:"Search",setup(u){var b;const{offers:l,query:p,loading:h,filters:_}=T(M()),c=A(((b=new URLSearchParams(window.location.search))==null?void 0:b.get("q"))||"");L(c,t=>p.value=t,{immediate:!0});const g=()=>k.value=k.value==="asc"?"desc":"asc",k=A("asc"),q=z(()=>{var o;const t=new Set;return((o=l.value)==null?void 0:o.map(e=>e.price_list_name).filter(e=>t.has(e)?!1:(t.add(e),!0)).map(e=>({title:e,value:e})))||[]});L(q,()=>{_.value.price_list_name=null});const i=A([]);W(()=>{var o;const t=[];(o=l.value)==null||o.filter(e=>!_.value.price_list_name||_.value.price_list_name===e.price_list_name).forEach(e=>{var n,d,m;t.push({...e,quantity:0,offer_id:e.id,amount:0,product_name:{en:((n=e.product_name)==null?void 0:n.en)||"",ru:((d=e.product_name)==null?void 0:d.ru)||((m=e.product_name)==null?void 0:m.en)||""}})}),i.value=t.sort((e,n)=>k.value==="asc"?+e.price-+n.price:k.value==="desc"?+n.price-+e.price:0)});const r=[{field:"brand_name",title:"Brand",width:100,minWidth:100,resizable:!0,visible:!0},{field:"partnumber",title:"Part Number",width:150,minWidth:150,resizable:!0,visible:!0},{field:"product_name",title:"Part Name",width:"minmax(150px,1fr)",minWidth:150,resizable:!0,visible:!0},{field:"weight",title:"Weight, kg",width:100,resizable:!0,align:"center",visible:!0},{field:"max_delivery_days",title:"Delivery, days",width:150,minWidth:150,resizable:!0,align:"right",visible:!0},{field:"price",title:"Price",width:80,minWidth:80,sortable:!0,resizable:!0,visible:!0},{field:"currency_code",title:"Currency",width:80,minWidth:80,resizable:!0,visible:!0},{field:"quantity_limit",title:"QTY",tooltip:"QTY tooltip",width:90,minWidth:90,resizable:!0,align:"right",visible:!0},{field:"minimum_order_quantity",title:"MOQ",tooltip:"MOQ tooltip",width:90,minWidth:90,resizable:!0,align:"right",visible:!0},{field:"pack_quantity",title:"MPQ",tooltip:"MPQ tooltip",width:120,align:"right",resizable:!0,visible:!0}],{restrictions:f}=T(G());return!f.value.has("cart")&&!f.value.has("offers")&&r.push({field:"quantity",title:"Add To Cart",width:150,minWidth:140,resizable:!0,visible:!0}),(t,o)=>{var e,n;return s(),y("div",Ce,[x(a(P),{"columns-settings":r,key:"search-prices","table-name":"search-prices",rows:i.value,"hide-empty-table":"",loading:a(h)},{FILTER:I(()=>{var d;return[x(a(K),{class:"grid-table__filter lg:!col-span-4 md:!col-span-6","submit-by":"button",modelValue:c.value,"onUpdate:modelValue":o[0]||(o[0]=m=>c.value=m),modelModifiers:{trim:!0},regexp:/[^a-zA-Z0-9]/g,"lens-left":"",rounded:!1,"input-classes":"rounded-l-md",loading:a(h),"show-search-button":"",placeholder:c.value?t.__("Search by partnumber"):t.__("Partnumber, like: :a",{a:`<a href='/prices/search?q=0888083716' 2 style='color: rgb(67 117 176); 3 text-decoration: underline;'> 4 0888083716</a>`})},null,8,["modelValue","loading","placeholder"]),(d=q.value)!=null&&d.length?(s(),C(a(X),{key:0,class:"grid-table__filter",placeholder:t.__("Filter by Price List"),modelValue:a(_).price_list_name,"onUpdate:modelValue":o[1]||(o[1]=m=>a(_).price_list_name=m),options:q.value},null,8,["placeholder","modelValue","options"])):$("",!0)]}),SORTER:I(({column:d,columnName:m})=>[d!=null&&d.sortable?(s(),C(a(ee),{key:0,direction:k.value,active:m==="price",onToggled:g},null,8,["direction","active"])):$("",!0)]),CELL:I(({item:d,columnName:m})=>[m==="quantity"?(s(),C(a(F),{key:d.id,class:"grid-table__cell_add-to-cart",item:d},null,8,["item"])):m==="max_delivery_days"?(s(),y("div",Te,w(a(R)(d.min_delivery_days,d.max_delivery_days)),1)):m==="quantity_limit"||m==="weight"?(s(),y("div",Ie,w(a(j)(d,m)),1)):$("",!0)]),_:1},8,["rows","loading"]),x(a($e),{columns:r}),a(h)||c.value&&!((e=i.value)!=null&&e.length)?(s(),y("div",Se,[v("div",Ae,[v("div",ze,[a(h)?(s(),y("div",Ve,[x(a(B),{
4class:"h-6 w-6 transition text-red animate-bounce duration-75 opacity-50"}),v("span",null,w(t.__("Searching"))+"...",1)])):c.value&&!((n=i.value)!=null&&n.length)?(s(),y("div",Qe,w(t.__("Nothing to show")),1)):$("",!0)])])])):$("",!0)])}}});const Je=D(Ee,[["__scopeId","data-v-dd714bfd"]]);export{Je 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.