import{d as j,r as p,l as C,i as M,w as y,G as h,c as o,o as l,b as t,h as g,t as u,F as w,p as k,n as x,a as S,u as m,f as B,A as D,E,W as N}from"./app-DJb_CRLj.js";import{u as L}from"./useToastify-DqLaHt3f.js";const T=["id"],U={class:"filter-groups-tabs"},z={class:"row"},G={class:"col-12"},O={class:"card filter-box-container"},W={class:"card-body px-4 pb-0"},A={key:0,class:"title text-dark lts-05 text-center fw-bold fs-6 mb-3 mt-2"},P={class:"wg-tabs br-15 mt-1"},Q={class:"simplebar-container w-100",style:{"max-width":"100%"}},R={class:"lts-05"},q=["onClick"],H={class:"card filter-box-section w-100"},I={class:"card-body d-flex align-items-center justify-content-center flex-column w-100 p-4"},J={class:"row filter-keys d-flex align-items-center justify-content-center mb-3"},K={class:"label lts-05 d-block mb-2 text-dark"},X={key:1,class:"col-12"},Y={class:"mb-0 w-100 d-block text-center lts-05 fs-8 text-light-gray"},Z={class:"filters-footer w-100 d-flex align-items-center justify-content-betweens px-2"},ee={key:0,class:"ri-arrow-left-s-line"},te={key:1,class:"ri-refresh-line i-spin",style:{"border-radius":"50px"}},oe=j({__name:"FilterBox",props:{status:{},component_id:{},data:{}},setup(V){const d=V,f=p(!1);let _=null;C(()=>{typeof window<"u"&&(_=M("Dropdown"),f.value=!0)});const a=p(null);d.data.filters.length!==0&&(a.value=d.data.filters[0]),y(()=>d.data.filters,e=>{e.length!==0&&(a.value=d.data.filters[0])});const c=p(!1);let i=h({});const F=()=>{if(Object.keys(i).length===0){L(E("messages.at_least_one_item_must_be_selected"));return}N.get(`/products?${$()}`,{},{onStart(){c.value=!0},onFinish(){c.value=!1},onError(){c.value=!0}})};function $(){const e=new URLSearchParams;return Object.entries(i).forEach(([n,r])=>{r&&e.append(`filters[${n}][0]`,r)}),e.toString()}return y(a,e=>{i=h({})}),(e,n)=>{var r,v;return l(),o("div",{id:"component-"+e.component_id,class:x({container:!0,readonly:e.status=="dev"}),style:D("margin-top:"+((r=e.data.style)==null?void 0:r.margin.top)+"px; margin-bottom:"+(((v=e.data.style)==null?void 0:v.margin.bottom)??20)+"px;")},[t("div",U,[t("div",z,[t("div",G,[t("div",O,[t("div",W,[e.data.content.title!=null&&e.data.content.title!=""?(l(),o("div",A,u(e.data.content.title),1)):g("",!0),t("div",P,[t("div",Q,[t("ul",R,[a.value!=null?(l(!0),o(w,{key:0},k(e.data.filters,s=>(l(),o("li",{key:s.id,onClick:b=>a.value=s,class:x({clickable:!0,"text-dark":!0,active:a.value.id==s.id})},u(s.title),11,q))),128)):g("",!0)])])]),t("div",H,[t("div",I,[t("div",J,[f.value&&a.value!=null&&a.value.keys!=null?(l(!0),o(w,{key:0},k(a.value.keys,s=>(l(),o("div",{key:s.id,class:"col-md-6 col-12 mb-3"},[t("span",K,u(s.title)+":",1),S(m(_),{class:"pvc-dropdown",modelValue:m(i)[s.title],"onUpdate:modelValue":b=>m(i)[s.title]=b,options:s.values,display:"chip",filter:"",appendTo:"self",placeholder:e.$t("messages.sentence.select_one_item"),emptyMessage:e.$t("messages.sentence.no_items_found"),emptyFilterMessage:e.$t("messages.sentence.no_items_found")},null,8,["modelValue","onUpdate:modelValue","options","placeholder","emptyMessage","emptyFilterMessage"])]))),128)):(l(),o("div",X,[t("p",Y,u(e.$t("messages.sentence.no_any_filters_selected")),1)]))]),t("div",Z,[n[1]||(n[1]=t("div",{class:"divider"},null,-1)),t("button",{onClick:F,type:"button",class:"btn btn-search mx-3"},[n[0]||(n[0]=B(" اعمال فیلتر ")),c.value?(l(),o("i",te)):(l(),o("i",ee))]),n[2]||(n[2]=t("div",{class:"divider"},null,-1))])])])])])])])])],14,T)}}});export{oe as default};
